sogo/UI/WebServerResources/js/Preferences.js
2017-05-13 01:24:30 -04:00

2 lines
12 KiB
JavaScript

!function(){"use strict";function e(e,a){e.state("preferences",{abstract:!0,views:{preferences:{templateUrl:"preferences.html",controller:"PreferencesController",controllerAs:"app"}},resolve:{statePreferences:t}}).state("preferences.general",{url:"/general",views:{module:{templateUrl:"generalPreferences.html"}}}).state("preferences.calendars",{url:"/calendars",views:{module:{templateUrl:"calendarsPreferences.html"}}}).state("preferences.addressbooks",{url:"/addressbooks",views:{module:{templateUrl:"addressbooksPreferences.html"}}}).state("preferences.mailer",{url:"/mailer",views:{module:{templateUrl:"mailerPreferences.html"}}}),a.otherwise("/general")}function t(e){return e}function a(e){e.$on("$routeChangeError",function(e,t,a,n){console.error(e,t,a,n)})}angular.module("SOGo.PreferencesUI",["ui.router","ck","SOGo.Common","SOGo.MailerUI","SOGo.ContactsUI","SOGo.Authentication","as.sortable"]).config(e).run(a),e.$inject=["$stateProvider","$urlRouterProvider"],t.$inject=["Preferences"],a.$inject=["$rootScope"]}(),function(){"use strict";function e(e,t,a,n,r){function o(){return!(n>0)&&!r}function l(){e.cancel()}function s(){e.hide()}var i=this;i.defaultPort=143,i.defaults=t,i.account=a,i.accountId=n,i.customFromIsReadonly=o,i.cancel=l,i.save=s,i.hostnameRE=n>0?/^(?!(127\.0\.0\.1|localhost(?:\.localdomain)?)$)/:/./,i.account.encryption?"ssl"==i.account.encryption&&(i.defaultPort=993):i.account.encryption="none"}e.$inject=["$mdDialog","defaults","account","accountId","mailCustomFromEnabled"],angular.module("SOGo.PreferencesUI").controller("AccountDialogController",e)}(),function(){"use strict";function e(e,t,a,n,r,o){function s(){a.cancel()}function i(){return g.filter.rules&&g.filter.rules.length>0&&g.filter.actions&&g.filter.actions.length>0}function c(e){a.hide()}function d(e){g.filter.rules||(g.filter.rules=[]),g.filter.rules.push({field:"subject",operator:"contains"})}function f(e){g.filter.rules.splice(e,1)}function u(e){g.filter.actions||(g.filter.actions=[]),g.filter.actions.push({method:"discard"})}function m(e){g.filter.actions.splice(e,1)}var g=this,p=t.sieveCapabilities,h=t.forwardEnabled;t.vacationEnabled;g.filter=n,g.mailboxes=r,g.labels=o,g.cancel=s,g.hasRulesAndActions=i,g.save=c,g.addMailFilterRule=d,g.removeMailFilterRule=f,g.addMailFilterAction=u,g.removeMailFilterAction=m,g.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")},p.indexOf("body")>-1&&(g.fieldLabels.body=l("Body")),g.methodLabels={discard:l("Discard the message"),keep:l("Keep the message"),stop:l("Stop processing filter rules")},h&&(g.methodLabels.redirect=l("Forward the message to")),p.indexOf("reject")>-1&&(g.methodLabels.reject=l("Send a reject message")),p.indexOf("fileinto")>-1&&(g.methodLabels.fileinto=l("File the message in")),(p.indexOf("imapflags")>-1||p.indexOf("imap4flags")>-1)&&(g.methodLabels.addflag=l("Flag the message with")),g.numberOperatorLabels={under:l("is under"),over:l("is over")},g.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")},p.indexOf("regex")>-1&&(g.textOperatorLabels.regex=l("matches regex"),g.textOperatorLabels.regex_not=l("does not match regex")),g.flagLabels={seen:l("Seen"),deleted:l("Deleted"),answered:l("Answered"),flagged:l("Flagged"),junk:l("Junk"),not_junk:l("Not Junk")}}e.$inject=["$scope","$window","$mdDialog","filter","mailboxes","labels"],angular.module("SOGo.PreferencesUI").controller("FiltersDialogController",e)}(),function(){"use strict";function e(e,t,a,n,r,o,s,i,c,d,f,u,m,g){function p(e,t){t.$valid&&(n("xs")&&r("left").close(),a.go("preferences."+e))}function h(e){d.confirm(l("Warning"),l("Save preferences and reload page now?"),{ok:l("Yes"),cancel:l("No")}).then(function(){L(e,{quick:!0}).then(function(){t.location.reload(!0)})})}function w(e){Z.preferences.defaults.SOGoCalendarCategoriesColors["New category"]="#aaa",Z.preferences.defaults.SOGoCalendarCategories.push("New category"),c("calendarCategory_"+(Z.preferences.defaults.SOGoCalendarCategories.length-1)),e.$setDirty()}function v(e,t){var a=Z.preferences.defaults.SOGoCalendarCategories[e];Z.preferences.defaults.SOGoCalendarCategories.splice(e,1),delete Z.preferences.defaults.SOGoCalendarCategoriesColors[a],t.$setDirty()}function D(e){Z.preferences.defaults.SOGoContactsCategories.push(""),c("contactCategory_"+(Z.preferences.defaults.SOGoContactsCategories.length-1)),e.$setDirty()}function C(e,t){Z.preferences.defaults.SOGoContactsCategories.splice(e,1),t.$setDirty()}function b(e,t){var a;Z.preferences.defaults.AuxiliaryMailAccounts.push({}),a=_.last(Z.preferences.defaults.AuxiliaryMailAccounts),angular.extend(a,{name:"",identities:[{fullName:"",email:""}],receipts:{receiptAction:"ignore",receiptNonRecipientAction:"ignore",receiptOutsideDomainAction:"ignore",receiptAnyAction:"ignore"}}),o.show({controller:"AccountDialogController",controllerAs:"$AccountDialogController",templateUrl:"editAccount?account=new",targetEvent:e,locals:{defaults:Z.preferences.defaults,account:a,accountId:Z.preferences.defaults.AuxiliaryMailAccounts.length-1,mailCustomFromEnabled:window.mailCustomFromEnabled}}).then(function(){t.$setDirty()}).catch(function(){Z.preferences.defaults.AuxiliaryMailAccounts.pop()})}function A(e,t,a){var n=Z.preferences.defaults.AuxiliaryMailAccounts[t];o.show({controller:"AccountDialogController",controllerAs:"$AccountDialogController",templateUrl:"editAccount?account="+t,targetEvent:e,locals:{defaults:Z.preferences.defaults,account:n,accountId:t,mailCustomFromEnabled:window.mailCustomFromEnabled}}).then(function(){Z.preferences.defaults.AuxiliaryMailAccounts[t]=n,a.$setDirty()})}function y(e,t){Z.preferences.defaults.AuxiliaryMailAccounts.splice(e,1),t.$setDirty()}function $(e){var t="_$$"+guid();Z.preferences.defaults.SOGoMailLabelsColors[t]=["New label","#aaa"],c("mailLabel_"+(_.size(Z.preferences.defaults.SOGoMailLabelsColors)-1)),e.$setDirty()}function S(e,t){delete Z.preferences.defaults.SOGoMailLabelsColors[e],t.$setDirty()}function O(e,t){var a={match:"all"};o.show({templateUrl:"editFilter?filter=new",controller:"FiltersDialogController",controllerAs:"filterEditor",targetEvent:e,locals:{filter:a,mailboxes:q,labels:Z.preferences.defaults.SOGoMailLabelsColors}}).then(function(){Z.preferences.defaults.SOGoSieveFilters||(Z.preferences.defaults.SOGoSieveFilters=[]),Z.preferences.defaults.SOGoSieveFilters.push(a),t.$setDirty()})}function F(e,t,a){var n=angular.copy(Z.preferences.defaults.SOGoSieveFilters[t]);o.show({templateUrl:"editFilter?filter="+t,controller:"FiltersDialogController",controllerAs:"filterEditor",targetEvent:null,locals:{filter:n,mailboxes:q,labels:Z.preferences.defaults.SOGoMailLabelsColors}}).then(function(){Z.preferences.defaults.SOGoSieveFilters[t]=n,a.$setDirty()})}function x(e,t){Z.preferences.defaults.SOGoSieveFilters.splice(e,1),t.$setDirty()}function E(e){var t=[];angular.isDefined(Z.preferences.defaults.Vacation.autoReplyEmailAddresses)&&(t=Z.preferences.defaults.Vacation.autoReplyEmailAddresses.split(",")),Z.preferences.defaults.Vacation.autoReplyEmailAddresses=_.union(window.defaultEmailAddresses.split(","),t).join(","),e.$setDirty()}function P(e,t){return e.length<i.minimumSearchLength()?[]:f.$filter(e,t).then(function(e){return _.forEach(e,function(e){e.$$image||(e.image?e.$$image=e.image:Z.preferences.avatar(e.c_email,32,{no_404:!0}).then(function(t){e.$$image=t}))}),e})}function G(e,a){var n;if(a.$dirty){for(e.preventDefault(),e.stopPropagation(),n=e.target;"A"!=n.tagName;)n=n.parentNode;d.confirm(l("Unsaved Changes"),l("Do you want to save your changes made to the configuration?"),{ok:l("Save"),cancel:l("Don't Save")}).then(function(){L(a,{quick:!0}).then(function(){t.location=n.href})},function(){t.location=n.href})}}function L(a,n){var r,o,i,c,f,u;if(o=!0,f=[],t.forwardConstraints>0&&angular.isDefined(Z.preferences.defaults.Forward)&&Z.preferences.defaults.Forward.enabled&&angular.isDefined(Z.preferences.defaults.Forward.forwardAddress))for(i=Z.preferences.defaults.Forward.forwardAddress.split(","),c=t.defaultEmailAddresses.split(/, */),_.forEach(c,function(e){var t=e.split("@")[1];t&&f.push(t.toLowerCase())}),r=0;r<i.length&&o;r++)u=i[r].split("@")[1].toLowerCase(),f.indexOf(u)<0&&1==t.forwardConstraints?(d.alert(l("Error"),l("You are not allowed to forward your messages to an external email address.")),o=!1):f.indexOf(u)>=0&&2==t.forwardConstraints&&(d.alert(l("Error"),l("You are not allowed to forward your messages to an internal email address.")),o=!1);return o?Z.preferences.$save().then(function(e){n&&n.quick||(s.show(s.simple().content(l("Preferences saved")).position("bottom right").hideDelay(2e3)),a.$setPristine())}):e.reject()}function M(){return!!(Z.passwords.newPassword&&Z.passwords.newPassword.length>0&&Z.passwords.newPasswordConfirmation&&Z.passwords.newPasswordConfirmation.length&&Z.passwords.newPassword==Z.passwords.newPasswordConfirmation)}function T(){g.changePassword(Z.passwords.newPassword).then(function(){var e=o.alert({title:l("Password"),content:l("The password was changed successfully."),ok:l("OK")});o.show(e).finally(function(){e=void 0})},function(e){var t=o.alert({title:l("Password"),content:e,ok:l("OK")});o.show(t).finally(function(){t=void 0})})}function V(e){return _.filter(Z.timeZonesList,function(t){return t.toUpperCase().indexOf(e.toUpperCase())>=0})}function U(){var e=Z.preferences.defaults;e&&e.Vacation&&e.Vacation.enabled&&(j(),k())}function j(){var e;(e=Z.preferences.defaults.Vacation).startDateEnabled&&(e.endDateEnabled&&e.startDate.getTime()>e.endDate.getTime()&&(e.startDate=new Date(e.endDate.getTime()),e.startDate.addDays(-1)),e.startDate.getTime()<K.getTime()&&(e.startDate=new Date(K.getTime())))}function k(){var e;(e=Z.preferences.defaults.Vacation).endDateEnabled&&(e.startDateEnabled&&e.endDate.getTime()<e.startDate.getTime()?(e.endDate=new Date(e.startDate.getTime()),e.endDate.addDays(1)):e.endDate.getTime()<K.getTime()&&(e.endDate=new Date(K.getTime())))}function I(e){var t=Z.preferences.defaults,a=!0;return t&&t.Vacation&&t.Vacation.enabled&&t.Vacation.startDateEnabled&&(a=(!t.Vacation.endDateEnabled||e.getTime()<t.Vacation.endDate.getTime())&&e.getTime()>=K.getTime()),a}function R(e){var t=Z.preferences.defaults,a=!0;return t&&t.Vacation&&t.Vacation.enabled&&t.Vacation.endDateEnabled&&(a=(!t.Vacation.startDateEnabled||e.getTime()>t.Vacation.startDate.getTime())&&e.getTime()>=K.getTime()),a}var N,Z=this,q=[],K=(new Date).beginOfDay().addDays(1);Z.preferences=m,Z.passwords={newPassword:null,newPasswordConfirmation:null},Z.go=p,Z.onLanguageChange=h,Z.addCalendarCategory=w,Z.removeCalendarCategory=v,Z.addContactCategory=D,Z.removeContactCategory=C,Z.addMailAccount=b,Z.editMailAccount=A,Z.removeMailAccount=y,Z.addMailLabel=$,Z.removeMailLabel=S,Z.addMailFilter=O,Z.editMailFilter=F,Z.removeMailFilter=x,Z.addDefaultEmailAddresses=E,Z.userFilter=P,Z.confirmChanges=G,Z.save=L,Z.canChangePassword=M,Z.changePassword=T,Z.timeZonesList=window.timeZonesList,Z.timeZonesListFilter=V,Z.timeZonesSearchText="",Z.sieveVariablesCapability=t.sieveCapabilities.indexOf("variables")>=0,Z.updateVacationDates=U,Z.toggleVacationStartDate=j,Z.toggleVacationEndDate=k,Z.validateVacationStartDate=I,Z.validateVacationEndDate=R,i.activeUser("path").mail&&(N=new u({id:0})).$getMailboxes().then(function(){for(var e=N.$flattenMailboxes({all:!0}),t=-1,a=e.length;++t<a;)q.push(e[t])}),m.ready().then(function(){m.defaults.SOGoAlternateAvatar&&(f.$alternateAvatar=m.defaults.SOGoAlternateAvatar),U()})}e.$inject=["$q","$window","$state","$mdMedia","$mdSidenav","$mdDialog","$mdToast","sgSettings","sgFocus","Dialog","User","Account","statePreferences","Authentication"],angular.module("SOGo.PreferencesUI").controller("PreferencesController",e)}();
//# sourceMappingURL=Preferences.js.map