mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-15 05:14:53 +00:00
(js) Move Settings to a value in Common ng module
Also removed explicit settings and defaults that were imported in various app modules. We now always use the Preferences ng service.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
angular.extend(Acl, {
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL, Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL'), Settings.activeUser()),
|
||||
$User: User
|
||||
});
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
function AlarmService($timeout, Settings, Resource, $mdToast) {
|
||||
angular.extend(Alarm, {
|
||||
$timeout: $timeout,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL + 'Calendar', Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),
|
||||
$toast: $mdToast
|
||||
});
|
||||
|
||||
|
||||
@@ -4,14 +4,22 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.Common', ['ngMaterial'])
|
||||
.constant('sgSettings', {
|
||||
baseURL: ApplicationBaseURL,
|
||||
activeUser: {
|
||||
login: UserLogin,
|
||||
identification: UserIdentification,
|
||||
language: UserLanguage,
|
||||
folderURL: UserFolderURL,
|
||||
isSuperUser: IsSuperUser
|
||||
.value('sgSettings', {
|
||||
baseURL: function() {
|
||||
return ApplicationBaseURL || null;
|
||||
},
|
||||
activeUser: function(param) {
|
||||
var settings = {
|
||||
login: UserLogin || null,
|
||||
identification: UserIdentification || null,
|
||||
language: UserLanguage || null,
|
||||
folderURL: UserFolderURL || null,
|
||||
isSuperUser: IsSuperUser || null
|
||||
};
|
||||
if (param)
|
||||
return settings[param];
|
||||
else
|
||||
return settings;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
angular.extend(User, {
|
||||
$q: $q,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL, Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL'), Settings.activeUser()),
|
||||
$gravatar: Gravatar
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
navController.$inject = ['$scope', '$timeout', '$interval', '$http', '$mdSidenav', '$mdBottomSheet', '$mdMedia', '$log', 'sgConstant', 'sgSettings', 'Alarm'];
|
||||
function navController($scope, $timeout, $interval, $http, $mdSidenav, $mdBottomSheet, $mdMedia, $log, sgConstant, sgSettings, Alarm) {
|
||||
|
||||
$scope.activeUser = sgSettings.activeUser;
|
||||
$scope.activeUser = sgSettings.activeUser();
|
||||
|
||||
// Show current day in top bar
|
||||
$scope.currentDay = window.currentDay;
|
||||
@@ -23,7 +23,7 @@
|
||||
$scope.currentDay = data;
|
||||
});
|
||||
}, 24 * 3600 * 1000);
|
||||
}, window.secondsBeforeTomorrow * 1000);
|
||||
}, window.currentDay.secondsBeforeTomorrow * 1000);
|
||||
|
||||
$scope.toggleLeft = function () {
|
||||
$mdSidenav('left').toggle()
|
||||
|
||||
@@ -5,19 +5,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.ContactsUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.PreferencesUI'])
|
||||
|
||||
.constant('sgSettings', {
|
||||
baseURL: ApplicationBaseURL,
|
||||
activeUser: {
|
||||
login: UserLogin,
|
||||
identification: UserIdentification,
|
||||
language: UserLanguage,
|
||||
folderURL: UserFolderURL,
|
||||
isSuperUser: IsSuperUser
|
||||
}
|
||||
})
|
||||
|
||||
.config(configure);
|
||||
.config(configure)
|
||||
.run(runBlock);
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
@@ -138,4 +127,14 @@
|
||||
return stateAddressbook.$getCard($stateParams.cardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
runBlock.$inject = ['$rootScope'];
|
||||
function runBlock($rootScope) {
|
||||
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
|
||||
console.error(event, current, previous, rejection);
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL + 'Contacts', Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Contacts', Settings.activeUser()),
|
||||
$Card: Card,
|
||||
$$Acl: Acl,
|
||||
$Preferences: Preferences,
|
||||
|
||||
@@ -38,12 +38,17 @@
|
||||
* @desc The factory we'll use to register with Angular.
|
||||
* @returns the Card constructor
|
||||
*/
|
||||
Card.$factory = ['$timeout', 'sgSettings', 'Resource', 'Gravatar', function($timeout, Settings, Resource, Gravatar) {
|
||||
Card.$factory = ['$timeout', 'sgSettings', 'Resource', 'Preferences', 'Gravatar', function($timeout, Settings, Resource, Preferences, Gravatar) {
|
||||
angular.extend(Card, {
|
||||
$$resource: new Resource(Settings.activeUser.folderURL + 'Contacts', Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Contacts', Settings.activeUser()),
|
||||
$timeout: $timeout,
|
||||
$gravatar: Gravatar,
|
||||
$categories: window.UserDefaults.SOGoContactsCategories
|
||||
$gravatar: Gravatar
|
||||
});
|
||||
// Initialize categories from user's defaults
|
||||
Preferences.ready().then(function() {
|
||||
if (Preferences.defaults.SOGoContactsCategories) {
|
||||
Card.$categories = Preferences.defaults.SOGoContactsCategories;
|
||||
}
|
||||
});
|
||||
|
||||
return Card; // return constructor
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.baseURL, Settings.activeUser),
|
||||
$$resource: new Resource(Settings.baseURL(), Settings.activeUser()),
|
||||
$Mailbox: Mailbox,
|
||||
$Message: Message
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL + 'Mail', Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),
|
||||
$Message: Message,
|
||||
$$Acl: Acl,
|
||||
$Preferences: Preferences,
|
||||
|
||||
@@ -35,18 +35,20 @@
|
||||
* @desc The factory we'll use to register with Angular
|
||||
* @returns the Message constructor
|
||||
*/
|
||||
Message.$factory = ['$q', '$timeout', '$log', '$sce', 'sgSettings', 'Resource', function($q, $timeout, $log, $sce, Settings, Resource) {
|
||||
Message.$factory = ['$q', '$timeout', '$log', '$sce', 'sgSettings', 'Resource', 'Preferences', function($q, $timeout, $log, $sce, Settings, Resource, Preferences) {
|
||||
angular.extend(Message, {
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$sce: $sce,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL + 'Mail', Settings.activeUser)
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser())
|
||||
});
|
||||
// Initialize tags form user's defaults
|
||||
Preferences.ready().then(function() {
|
||||
if (Preferences.defaults.SOGoMailLabelsColors) {
|
||||
Message.$tags = Preferences.defaults.SOGoMailLabelsColors;
|
||||
}
|
||||
});
|
||||
|
||||
if (window.UserDefaults && window.UserDefaults.SOGoMailLabelsColors) {
|
||||
Message.$tags = window.UserDefaults.SOGoMailLabelsColors;
|
||||
}
|
||||
|
||||
return Message; // return constructor
|
||||
}];
|
||||
|
||||
@@ -4,22 +4,9 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.ContactsUI', []);
|
||||
angular.module('SOGo.MailerUI', []);
|
||||
|
||||
angular.module('SOGo.PreferencesUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.MailerUI', 'SOGo.ContactsUI', 'SOGo.Authentication'])
|
||||
|
||||
.constant('sgSettings', {
|
||||
baseURL: ApplicationBaseURL,
|
||||
activeUser: {
|
||||
login: UserLogin,
|
||||
identification: UserIdentification,
|
||||
language: UserLanguage,
|
||||
folderURL: UserFolderURL,
|
||||
isSuperUser: IsSuperUser
|
||||
}
|
||||
})
|
||||
.config(configure);
|
||||
.config(configure)
|
||||
.run(runBlock);
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
@@ -84,5 +71,15 @@
|
||||
function statePreferences(Preferences) {
|
||||
return Preferences;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
runBlock.$inject = ['$rootScope'];
|
||||
function runBlock($rootScope) {
|
||||
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
|
||||
console.error(event, current, previous, rejection);
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL, Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL'), Settings.activeUser()),
|
||||
activeUser: Settings.activeUser,
|
||||
$User: User
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL + 'Calendar', Settings.activeUser),
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),
|
||||
$Component: Component,
|
||||
$$Acl: Acl,
|
||||
activeUser: Settings.activeUser
|
||||
|
||||
@@ -38,24 +38,26 @@
|
||||
$log: $log,
|
||||
$Preferences: Preferences,
|
||||
$gravatar: Gravatar,
|
||||
$$resource: new Resource(Settings.baseURL, Settings.activeUser),
|
||||
$categories: window.UserDefaults.SOGoCalendarCategoriesColors,
|
||||
$$resource: new Resource(Settings.baseURL(), Settings.activeUser()),
|
||||
timeFormat: "%H:%M",
|
||||
// Filter parameters common to events and tasks
|
||||
$query: { value: '', search: 'title_Category_Location' },
|
||||
// Filter paramaters specific to events
|
||||
$queryEvents: { sort: 'start', asc: 1, filterpopup: 'view_next7' },
|
||||
// Filter parameters specific to tasks
|
||||
$queryTasks: { sort: 'status', asc: 1, filterpopup: 'view_incomplete' }
|
||||
$queryTasks: { sort: 'status', asc: 1, filterpopup: 'view_next7' } //'view_incomplete' }
|
||||
});
|
||||
// Initialize filter parameters from user's settings
|
||||
Preferences.ready().then(function() {
|
||||
// Initialize filter parameters from user's settings
|
||||
Component.$queryEvents.filterpopup = Preferences.settings.CalendarDefaultFilter;
|
||||
Component.$queryTasks.show_completed = parseInt(Preferences.settings.ShowCompletedTasks);
|
||||
// Initialize categories from user's defaults
|
||||
Component.$categories = Preferences.defaults.SOGoCalendarCategoriesColors;
|
||||
// Initialize time format from user's defaults
|
||||
if (Preferences.defaults.SOGoTimeFormat) {
|
||||
Component.timeFormat = Preferences.defaults.SOGoTimeFormat;
|
||||
}
|
||||
});
|
||||
if (window.UserDefaults && window.UserDefaults.SOGoTimeFormat)
|
||||
Component.timeFormat = window.UserDefaults.SOGoTimeFormat;
|
||||
else
|
||||
Component.timeFormat = "%H:%M";
|
||||
|
||||
return Component; // return constructor
|
||||
}];
|
||||
|
||||
Reference in New Issue
Block a user