mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-12 20:05:08 +00:00
(js) New file structure for Angular modules
JavaScript files are now merged by the 'js' Grunt task.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* JavaScript for SOGoPreferences */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
AccountDialogController.$inject = ['$scope', '$mdDialog', 'account', 'accountId', 'mailCustomFromEnabled'];
|
||||
function AccountDialogController($scope, $mdDialog, account, accountId, mailCustomFromEnabled) {
|
||||
$scope.account = account;
|
||||
$scope.accountId = accountId;
|
||||
$scope.customFromIsReadonly = function() {
|
||||
if (accountId > 0)
|
||||
return false;
|
||||
|
||||
return !mailCustomFromEnabled;
|
||||
};
|
||||
$scope.cancel = function() {
|
||||
$mdDialog.cancel();
|
||||
};
|
||||
$scope.save = function() {
|
||||
$mdDialog.hide();
|
||||
};
|
||||
}
|
||||
|
||||
angular
|
||||
.module('SOGo.PreferencesUI')
|
||||
.controller('AccountDialogController', AccountDialogController);
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,98 @@
|
||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* JavaScript for SOGoPreferences */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
FiltersDialogController.$inject = ['$scope', '$mdDialog', 'filter', 'mailboxes', 'labels'];
|
||||
function FiltersDialogController($scope, $mdDialog, filter, mailboxes, labels) {
|
||||
$scope.filter = filter;
|
||||
$scope.mailboxes = mailboxes;
|
||||
$scope.labels = labels;
|
||||
|
||||
$scope.fieldLabels = {
|
||||
"subject": l("Subject"),
|
||||
"from": l("From"),
|
||||
"to": l("To"),
|
||||
"cc": l("Cc"),
|
||||
"to_or_cc": l("To or Cc"),
|
||||
"size": l("Size (Kb)"),
|
||||
"header": l("Header"),
|
||||
"body": l("Body")
|
||||
};
|
||||
|
||||
$scope.methodLabels = {
|
||||
"addflag": l("Flag the message with:"),
|
||||
"discard": l("Discard the message"),
|
||||
"fileinto": l("File the message in:"),
|
||||
"keep": l("Keep the message"),
|
||||
"redirect": l("Forward the message to:"),
|
||||
"reject": l("Send a reject message:"),
|
||||
"vacation": l("Send a vacation message"),
|
||||
"stop": l("Stop processing filter rules")
|
||||
};
|
||||
|
||||
$scope.numberOperatorLabels = {
|
||||
"under": l("is under"),
|
||||
"over": l("is over")
|
||||
};
|
||||
|
||||
$scope.textOperatorLabels = {
|
||||
"is": l("is"),
|
||||
"is_not": l("is not"),
|
||||
"contains": l("contains"),
|
||||
"contains_not": l("does not contain"),
|
||||
"matches": l("matches"),
|
||||
"matches_not": l("does not match"),
|
||||
"regex": l("matches regex"),
|
||||
"regex_not": l("does not match regex")
|
||||
};
|
||||
|
||||
$scope.flagLabels = {
|
||||
"seen": l("Seen"),
|
||||
"deleted": l("Deleted"),
|
||||
"answered": l("Answered"),
|
||||
"flagged": l("Flagged"),
|
||||
"junk": l("Junk"),
|
||||
"not_junk": l("Not Junk")
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$mdDialog.cancel();
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
$mdDialog.hide();
|
||||
};
|
||||
|
||||
$scope.addMailFilterRule = function(event) {
|
||||
if (!$scope.filter.rules)
|
||||
$scope.filter.rules = [];
|
||||
|
||||
$scope.filter.rules.push({});
|
||||
};
|
||||
|
||||
$scope.removeMailFilterRule = function(index) {
|
||||
$scope.filter.rules.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.addMailFilterAction = function(event) {
|
||||
if (!$scope.filter.actions)
|
||||
$scope.filter.actions = [];
|
||||
|
||||
$scope.filter.actions.push({});
|
||||
};
|
||||
|
||||
$scope.removeMailFilterAction = function(index) {
|
||||
$scope.filter.actions.splice(index, 1);
|
||||
};
|
||||
}
|
||||
|
||||
angular
|
||||
.module('SOGo.PreferencesUI')
|
||||
.controller('FiltersDialogController', FiltersDialogController);
|
||||
|
||||
})();
|
||||
+41
-41
@@ -13,45 +13,45 @@
|
||||
this.defaults = {};
|
||||
this.settings = {};
|
||||
|
||||
this.mailboxes = Preferences.$Mailbox.$find({ id: 0 });
|
||||
|
||||
Preferences.$$resource.fetch("jsonDefaults").then(function(data) {
|
||||
Preferences.$timeout(function() {
|
||||
this.mailboxes = Preferences.$Mailbox.$find({ id: 0 });
|
||||
|
||||
Preferences.$$resource.fetch("jsonDefaults").then(function(data) {
|
||||
Preferences.$timeout(function() {
|
||||
|
||||
// We swap $key -> _$key to avoid an Angular bug (https://github.com/angular/angular.js/issues/6266)
|
||||
var labels = _.object(_.map(data.SOGoMailLabelsColors, function(value, key) {
|
||||
if (key.charAt(0) == '$')
|
||||
return ['_' + key, value];
|
||||
return [key, value];
|
||||
}));
|
||||
|
||||
data.SOGoMailLabelsColors = labels;
|
||||
// We swap $key -> _$key to avoid an Angular bug (https://github.com/angular/angular.js/issues/6266)
|
||||
var labels = _.object(_.map(data.SOGoMailLabelsColors, function(value, key) {
|
||||
if (key.charAt(0) == '$')
|
||||
return ['_' + key, value];
|
||||
return [key, value];
|
||||
}));
|
||||
|
||||
// We convert our list of autoReplyEmailAddresses/forwardAddress into a string.
|
||||
if (data.Vacation && data.Vacation.autoReplyEmailAddresses)
|
||||
data.Vacation.autoReplyEmailAddresses = data.Vacation.autoReplyEmailAddresses.join(",");
|
||||
data.SOGoMailLabelsColors = labels;
|
||||
|
||||
if (data.Forward && data.Forward.forwardAddress)
|
||||
data.Forward.forwardAddress = data.Forward.forwardAddress.join(",");
|
||||
|
||||
angular.extend(_this.defaults, data);
|
||||
});
|
||||
});
|
||||
Preferences.$$resource.fetch("jsonSettings").then(function(data) {
|
||||
Preferences.$timeout(function() {
|
||||
// We convert our list of autoReplyEmailAddresses/forwardAddress into a string.
|
||||
if (data.Vacation && data.Vacation.autoReplyEmailAddresses)
|
||||
data.Vacation.autoReplyEmailAddresses = data.Vacation.autoReplyEmailAddresses.join(",");
|
||||
|
||||
|
||||
// We convert our PreventInvitationsWhitelist hash into a array of user
|
||||
if (data.Calendar && data.Calendar.PreventInvitationsWhitelist)
|
||||
data.Calendar.PreventInvitationsWhitelist = _.map(data.Calendar.PreventInvitationsWhitelist, function(value, key) {
|
||||
return new Preferences.$User({uid: key, shortFormat: value});
|
||||
});
|
||||
else
|
||||
data.Calendar.PreventInvitationsWhitelist = [];
|
||||
|
||||
angular.extend(_this.settings, data);
|
||||
});
|
||||
});
|
||||
if (data.Forward && data.Forward.forwardAddress)
|
||||
data.Forward.forwardAddress = data.Forward.forwardAddress.join(",");
|
||||
|
||||
angular.extend(_this.defaults, data);
|
||||
});
|
||||
});
|
||||
Preferences.$$resource.fetch("jsonSettings").then(function(data) {
|
||||
Preferences.$timeout(function() {
|
||||
|
||||
|
||||
// We convert our PreventInvitationsWhitelist hash into a array of user
|
||||
if (data.Calendar && data.Calendar.PreventInvitationsWhitelist)
|
||||
data.Calendar.PreventInvitationsWhitelist = _.map(data.Calendar.PreventInvitationsWhitelist, function(value, key) {
|
||||
return new Preferences.$User({uid: key, shortFormat: value});
|
||||
});
|
||||
else
|
||||
data.Calendar.PreventInvitationsWhitelist = [];
|
||||
|
||||
angular.extend(_this.settings, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@
|
||||
* @desc The factory we'll use to register with Angular
|
||||
* @returns the Preferences constructor
|
||||
*/
|
||||
Preferences.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'sgResource', 'sgMailbox', 'sgUser', function($q, $timeout, $log, Settings, Resource, Mailbox, User) {
|
||||
Preferences.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Mailbox', 'User', function($q, $timeout, $log, Settings, Resource, Mailbox, User) {
|
||||
angular.extend(Preferences, {
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
@@ -75,14 +75,14 @@
|
||||
|
||||
/* Factory registration in Angular module */
|
||||
angular.module('SOGo.PreferencesUI')
|
||||
.factory('sgPreferences', Preferences.$factory);
|
||||
.factory('Preferences', Preferences.$factory);
|
||||
|
||||
/**
|
||||
* @function $save
|
||||
* @memberof Preferences.prototype
|
||||
* @desc Save the preferences to the server.
|
||||
*/
|
||||
Preferences.prototype.$save = function() {
|
||||
/*Preferences.prototype.$save = function() {
|
||||
var _this = this;
|
||||
console.debug("save in model...");
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
//_this.$shadowData = _this.$omit(true);
|
||||
return data;
|
||||
});
|
||||
};
|
||||
};*/
|
||||
|
||||
/**
|
||||
* @function $omit
|
||||
@@ -103,7 +103,7 @@
|
||||
* @param {Boolean} [deep] - make a deep copy if true
|
||||
* @return an object literal copy of the Preferences instance
|
||||
*/
|
||||
Preferences.prototype.$omit = function(deep) {
|
||||
/*Preferences.prototype.$omit = function(deep) {
|
||||
var preferences = {};
|
||||
angular.forEach(this, function(value, key) {
|
||||
if (key != 'constructor' && key[0] != '$') {
|
||||
@@ -139,6 +139,6 @@
|
||||
}
|
||||
|
||||
return preferences;
|
||||
};
|
||||
};*/
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,198 @@
|
||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* JavaScript for SOGoPreferences */
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
PreferencesController.$inject = ['$scope', '$timeout', '$q', '$mdDialog', 'Preferences', 'User', 'statePreferences', 'Authentication'];
|
||||
function PreferencesController($scope, $timeout, $q, $mdDialog, Preferences, User, statePreferences, Authentication) {
|
||||
var vm = this;
|
||||
|
||||
vm.preferences = statePreferences;
|
||||
vm.passwords = { newPassword: null, newPasswordConfirmation: null };
|
||||
|
||||
vm.addCalendarCategory = addCalendarCategory;
|
||||
vm.removeCalendarCategory = removeCalendarCategory;
|
||||
vm.addContactCategory = addContactCategory;
|
||||
vm.removeContactCategory = removeContactCategory;
|
||||
vm.addMailAccount = addMailAccount;
|
||||
vm.editMailAccount = editMailAccount;
|
||||
vm.removeMailAccount = removeMailAccount;
|
||||
vm.addMailLabel = addMailLabel;
|
||||
vm.removeMailLabel = removeMailLabel;
|
||||
vm.addMailFilter = addMailFilter;
|
||||
vm.editMailFilter = editMailFilter;
|
||||
vm.removeMailFilter = removeMailFilter;
|
||||
vm.userFilter = userFilter;
|
||||
vm.save = save;
|
||||
vm.canChangePassword = canChangePassword;
|
||||
vm.changePassword = changePassword;
|
||||
|
||||
function addCalendarCategory() {
|
||||
vm.preferences.defaults.SOGoCalendarCategoriesColors["New category"] = "#aaa";
|
||||
vm.preferences.defaults.SOGoCalendarCategories.push("New category");
|
||||
}
|
||||
|
||||
function removeCalendarCategory(index) {
|
||||
var key = vm.preferences.defaults.SOGoCalendarCategories[index];
|
||||
vm.preferences.defaults.SOGoCalendarCategories.splice(index, 1);
|
||||
delete vm.preferences.defaults.SOGoCalendarCategoriesColors[key];
|
||||
}
|
||||
|
||||
function addContactCategory() {
|
||||
vm.preferences.defaults.SOGoContactsCategories.push("");
|
||||
}
|
||||
|
||||
function removeContactCategory(index) {
|
||||
vm.preferences.defaults.SOGoContactsCategories.splice(index, 1);
|
||||
}
|
||||
|
||||
function addMailAccount(ev) {
|
||||
var account;
|
||||
|
||||
vm.preferences.defaults.AuxiliaryMailAccounts.push({});
|
||||
account = _.last(vm.preferences.defaults.AuxiliaryMailAccounts);
|
||||
account['name'] = "New account";
|
||||
account['identities'] = [];
|
||||
account['identities'][0] = {};
|
||||
account['identities'][0]['fullName'] = "";
|
||||
account['identities'][0]['email'] = "";
|
||||
account['receipts'] = {};
|
||||
account['receipts']['receiptAction'] = "ignore";
|
||||
account['receipts']['receiptNonRecipientAction'] = "ignore";
|
||||
account['receipts']['receiptOutsideDomainAction'] = "ignore";
|
||||
account['receipts']['receiptAnyAction'] = "ignore";
|
||||
|
||||
$mdDialog.show({
|
||||
controller: 'AccountDialogController',
|
||||
templateUrl: 'editAccount?account=new',
|
||||
targetEvent: ev,
|
||||
locals: {
|
||||
account: account,
|
||||
accountId: (vm.preferences.defaults.AuxiliaryMailAccounts.length-1),
|
||||
mailCustomFromEnabled: window.mailCustomFromEnabled
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editMailAccount(index) {
|
||||
var account = vm.preferences.defaults.AuxiliaryMailAccounts[index];
|
||||
$mdDialog.show({
|
||||
controller: 'AccountDialogController',
|
||||
templateUrl: 'editAccount?account=' + index,
|
||||
targetEvent: null,
|
||||
locals: {
|
||||
account: account,
|
||||
accountId: index,
|
||||
mailCustomFromEnabled: window.mailCustomFromEnabled
|
||||
}
|
||||
}).then(function() {
|
||||
vm.preferences.defaults.AuxiliaryMailAccounts[index] = account;
|
||||
});
|
||||
}
|
||||
|
||||
function removeMailAccount(index) {
|
||||
vm.preferences.defaults.AuxiliaryMailAccounts.splice(index, 1);
|
||||
}
|
||||
|
||||
function addMailLabel() {
|
||||
vm.preferences.defaults.SOGoMailLabelsColors["new_label"] = ["New label", "#aaa"];
|
||||
}
|
||||
|
||||
function removeMailLabel(key) {
|
||||
delete vm.preferences.defaults.SOGoMailLabelsColors[key];
|
||||
}
|
||||
|
||||
function addMailFilter(ev) {
|
||||
if (!vm.preferences.defaults.SOGoSieveFilters)
|
||||
vm.preferences.defaults.SOGoSieveFilters = [];
|
||||
|
||||
vm.preferences.defaults.SOGoSieveFilters.push({});
|
||||
var filter = _.last(vm.preferences.defaults.SOGoSieveFilters);
|
||||
$mdDialog.show({
|
||||
controller: 'FiltersDialogController',
|
||||
templateUrl: 'editFilter?filter=new',
|
||||
targetEvent: ev,
|
||||
locals: {
|
||||
filter: filter,
|
||||
mailboxes: vm.preferences.mailboxes,
|
||||
labels: vm.preferences.defaults.SOGoMailLabelsColors
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editMailFilter(index) {
|
||||
var filter = angular.copy(vm.preferences.defaults.SOGoSieveFilters[index]);
|
||||
|
||||
$mdDialog.show({
|
||||
controller: 'FiltersDialogController',
|
||||
templateUrl: 'editFilter?filter=' + index,
|
||||
targetEvent: null,
|
||||
locals: {
|
||||
filter: filter,
|
||||
mailboxes: vm.preferences.mailboxes,
|
||||
labels: vm.preferences.defaults.SOGoMailLabelsColors
|
||||
}
|
||||
}).then(function() {
|
||||
vm.preferences.defaults.SOGoSieveFilters[index] = filter;
|
||||
});
|
||||
}
|
||||
|
||||
function removeMailFilter(index) {
|
||||
vm.preferences.defaults.SOGoSieveFilters.splice(index, 1);
|
||||
}
|
||||
|
||||
function userFilter($query) {
|
||||
var deferred = $q.defer();
|
||||
User.$filter($query).then(function(results) {
|
||||
deferred.resolve(results)
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function save() {
|
||||
vm.preferences.$save();
|
||||
}
|
||||
|
||||
function canChangePassword() {
|
||||
if (vm.passwords.newPassword && vm.passwords.newPassword.length > 0 &&
|
||||
vm.passwords.newPasswordConfirmation && vm.passwords.newPasswordConfirmation.length &&
|
||||
vm.passwords.newPassword == vm.passwords.newPasswordConfirmation)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function changePassword() {
|
||||
Authentication.changePassword(vm.passwords.newPassword).then(function() {
|
||||
var alert = $mdDialog.alert({
|
||||
title: l('Password'),
|
||||
content: l('The password was changed successfully.'),
|
||||
ok: 'OK'
|
||||
});
|
||||
$mdDialog.show( alert )
|
||||
.finally(function() {
|
||||
alert = undefined;
|
||||
});
|
||||
}, function(msg) {
|
||||
var alert = $mdDialog.alert({
|
||||
title: l('Password'),
|
||||
content: msg,
|
||||
ok: 'OK'
|
||||
});
|
||||
$mdDialog.show( alert )
|
||||
.finally(function() {
|
||||
alert = undefined;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
angular
|
||||
.module('SOGo.PreferencesUI')
|
||||
.controller('PreferencesController', PreferencesController);
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user