perf(web): don't wait on Sieve server to render UIxPageFrame.wox
This commit is contained in:
parent
bc963d53c6
commit
3e6cd3c53c
|
@ -76,15 +76,14 @@ static SoProduct *preferencesProduct = nil;
|
||||||
return labelsDictionary;
|
return labelsDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
- (WOResponse *) activeExternalSieveScriptsAction
|
||||||
// Used internally
|
|
||||||
//
|
|
||||||
- (BOOL) _hasActiveExternalSieveScripts
|
|
||||||
{
|
{
|
||||||
NGSieveClient *client;
|
NGSieveClient *client;
|
||||||
|
NSDictionary *data;
|
||||||
SOGoMailAccount *account;
|
SOGoMailAccount *account;
|
||||||
SOGoMailAccounts *folder;
|
SOGoMailAccounts *folder;
|
||||||
SOGoSieveManager *manager;
|
SOGoSieveManager *manager;
|
||||||
|
WOResponse *response;
|
||||||
|
|
||||||
folder = [[[context activeUser] homeFolderInContext: context] mailAccountsFolder: @"Mail" inContext: context];
|
folder = [[[context activeUser] homeFolderInContext: context] mailAccountsFolder: @"Mail" inContext: context];
|
||||||
account = [folder lookupName: @"0" inContext: context acquire: NO];
|
account = [folder lookupName: @"0" inContext: context acquire: NO];
|
||||||
|
@ -92,9 +91,20 @@ static SoProduct *preferencesProduct = nil;
|
||||||
client = [manager clientForAccount: account];
|
client = [manager clientForAccount: account];
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
return [manager hasActiveExternalSieveScripts: client];
|
{
|
||||||
|
if ([manager hasActiveExternalSieveScripts: client])
|
||||||
|
response = [self responseWith204];
|
||||||
|
else
|
||||||
|
response = [self responseWithStatus: 404];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@"An error occured while communicating with the Sieve server", @"message", nil];
|
||||||
|
response = [self responseWithStatus: 500 andJSONRepresentation: data];
|
||||||
|
}
|
||||||
|
|
||||||
return NO;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (WOResponse *) jsonDefaultsAction
|
- (WOResponse *) jsonDefaultsAction
|
||||||
|
@ -431,8 +441,8 @@ static SoProduct *preferencesProduct = nil;
|
||||||
[values setObject: vacation forKey: @"Vacation"];
|
[values setObject: vacation forKey: @"Vacation"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect if an external Sieve script is active
|
// Ignore hasActiveExternalSieveScripts as it will be requested on demand
|
||||||
[values setObject: [NSNumber numberWithBool: [self _hasActiveExternalSieveScripts]] forKey: @"hasActiveExternalSieveScripts"];
|
[values removeObjectForKey: @"hasActiveExternalSieveScripts"];
|
||||||
|
|
||||||
return [values jsonRepresentation];
|
return [values jsonRepresentation];
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,11 @@
|
||||||
protectedBy = "View";
|
protectedBy = "View";
|
||||||
pageName = "UIxIdentities";
|
pageName = "UIxIdentities";
|
||||||
};
|
};
|
||||||
|
activeExternalSieveScripts = {
|
||||||
|
protectedBy = "View";
|
||||||
|
pageName = "UIxJSONPreferences";
|
||||||
|
actionName = "activeExternalSieveScripts";
|
||||||
|
};
|
||||||
jsonDefaults = {
|
jsonDefaults = {
|
||||||
protectedBy = "View";
|
protectedBy = "View";
|
||||||
pageName = "UIxJSONPreferences";
|
pageName = "UIxJSONPreferences";
|
||||||
|
|
|
@ -370,7 +370,7 @@
|
||||||
$window.recovered = true;
|
$window.recovered = true;
|
||||||
$window.location.href = $window.ApplicationBaseURL + $state.href($state.current);
|
$window.location.href = $window.ApplicationBaseURL + $state.href($state.current);
|
||||||
}
|
}
|
||||||
else {
|
else if (!rejection.data.quiet) {
|
||||||
// Broadcast the response error
|
// Broadcast the response error
|
||||||
$rootScope.$broadcast('http:Error', rejection);
|
$rootScope.$broadcast('http:Error', rejection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,45 @@
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function quietFetch
|
||||||
|
* @memberof Resource.prototype
|
||||||
|
* @desc Fetch resource using a specific folder, action and/or parameters, but disable the global
|
||||||
|
* error interceptor.
|
||||||
|
* @param {string} folderId - the folder on which the action will be applied (ex: addressbook, calendar)
|
||||||
|
* @param {string} action - the action to be used in the URL
|
||||||
|
* @param {Object} params - Object parameters injected through the $http service
|
||||||
|
* @return a promise
|
||||||
|
*/
|
||||||
|
Resource.prototype.quietFetch = function(folderId, action, params) {
|
||||||
|
var deferred = this._q.defer(),
|
||||||
|
path = [this._path];
|
||||||
|
if (folderId) path.push(folderId.split('/'));
|
||||||
|
if (action) path.push(action);
|
||||||
|
path = _.compact(_.flatten(path)).join('/');
|
||||||
|
|
||||||
|
this._http({
|
||||||
|
method: 'GET',
|
||||||
|
url: path,
|
||||||
|
params: params,
|
||||||
|
transformResponse: function(data) {
|
||||||
|
var jsonData;
|
||||||
|
try {
|
||||||
|
jsonData = angular.fromJson(data);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
jsonData = {};
|
||||||
|
}
|
||||||
|
return angular.extend({ quiet: true }, jsonData);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(function(response) {
|
||||||
|
return deferred.resolve(response.data);
|
||||||
|
}, deferred.reject);
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function newguid
|
* @function newguid
|
||||||
* @memberof Resource.prototype
|
* @memberof Resource.prototype
|
||||||
|
|
|
@ -253,6 +253,35 @@
|
||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function hasActiveExternalSieveScripts
|
||||||
|
* @memberof Preferences.prototype
|
||||||
|
* @desc Check if the user has an external Sieve script enabled.
|
||||||
|
*/
|
||||||
|
Preferences.prototype.hasActiveExternalSieveScripts = function(value) {
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
|
if (typeof value !== 'undefined') {
|
||||||
|
this.defaults.hasActiveExternalSieveScripts = value;
|
||||||
|
}
|
||||||
|
else if (typeof this.defaults.hasActiveExternalSieveScripts !== 'undefined') {
|
||||||
|
return this.defaults.hasActiveExternalSieveScripts;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Fetch information from server
|
||||||
|
this.defaults.hasActiveExternalSieveScripts = false; // default until we receive an answer
|
||||||
|
Preferences.$$resource.quietFetch('activeExternalSieveScripts')
|
||||||
|
.then(function() {
|
||||||
|
_this.defaults.hasActiveExternalSieveScripts = true;
|
||||||
|
}, function(response) {
|
||||||
|
_this.defaults.hasActiveExternalSieveScripts = false;
|
||||||
|
if (response.status === 404) {
|
||||||
|
return Preferences.$q.resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function $save
|
* @function $save
|
||||||
* @memberof Preferences.prototype
|
* @memberof Preferences.prototype
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
if (Preferences.defaults.SOGoAlternateAvatar)
|
if (Preferences.defaults.SOGoAlternateAvatar)
|
||||||
User.$alternateAvatar = Preferences.defaults.SOGoAlternateAvatar;
|
User.$alternateAvatar = Preferences.defaults.SOGoAlternateAvatar;
|
||||||
|
|
||||||
|
this.preferences.hasActiveExternalSieveScripts();
|
||||||
this.updateVacationDates();
|
this.updateVacationDates();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -285,7 +286,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
this.manageSieveScript = function(form) {
|
this.manageSieveScript = function(form) {
|
||||||
this.preferences.defaults.hasActiveExternalSieveScripts = false;
|
this.preferences.hasActiveExternalSieveScripts(false);
|
||||||
form.$setDirty();
|
form.$setDirty();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue