sogo/UI/WebServerResources/js/Mailer.services.js

3 lines
47 KiB
JavaScript
Raw Normal View History

2016-08-11 07:28:23 +02:00
!function(){"use strict";function a(b){"function"!=typeof b.then&&(angular.extend(this,b),_.forEach(this.identities,function(a){a.fullName?a.full=a.fullName+" <"+a.email+">":a.full="<"+a.email+">"}),a.$log.debug("Account: "+JSON.stringify(b,void 0,2)))}a.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(b,c,d,e,f,g,h,i){return angular.extend(a,{$q:b,$timeout:c,$log:d,$$resource:new f(e.activeUser("folderURL")+"Mail",e.activeUser()),$Preferences:g,$Mailbox:h,$Message:i}),a}];try{angular.module("SOGo.MailerUI")}catch(a){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",a.$factory),a.$findAll=function(b){return b?a.$unwrapCollection(b):a.$$resource.fetch("","mailAccounts").then(function(b){return a.$unwrapCollection(b)})},a.$unwrapCollection=function(b){var c=[];return angular.forEach(b,function(b,d){b.id=d,c[d]=new a(b)}),a.$accounts=c,c},a.prototype.getLength=function(){return this.$flattenMailboxes().length},a.prototype.getItemAtIndex=function(a){var b;return b=this.$flattenMailboxes(),a>=0&&a<b.length?b[a]:null},a.prototype.$getMailboxes=function(b){var c=this;return!this.$mailboxes||b&&b.reload?a.$Mailbox.$find(this).then(function(b){return c.$mailboxes=b,c.$expanded=!1,a.$Preferences.ready().then(function(){var b,d=function(a){_.forEach(a,function(a){a.$expanded=b.indexOf("/"+a.id)>=0,a.children&&a.children.length>0&&d(a.children)})};a.$Preferences.settings.Mail.ExpandedFolders&&(b=angular.isString(a.$Preferences.settings.Mail.ExpandedFolders)?angular.fromJson(a.$Preferences.settings.Mail.ExpandedFolders):a.$Preferences.settings.Mail.ExpandedFolders,c.$expanded=b.indexOf("/"+c.id)>=0,b.length>0&&d(c.$mailboxes)),a.$accounts&&(c.$expanded|=1==a.$accounts.length),c.$flattenMailboxes({reload:!0})}),c.$mailboxes}):a.$q.when(this.$mailboxes)},a.prototype.$flattenMailboxes=function(b){var c=this,d=[],e=[],f=function(a){_.forEach(a,function(a){d.push(a),(b&&b.all||a.$expanded)&&a.children&&a.children.length>0&&f(a.children)})};return!this.$$flattenMailboxes||b&&(b.reload||b.all)?(f(this.$mailboxes),b&&b.all||(c.$$flattenMailboxes=d,b&&b.saveState&&(_.forEach(a.$accounts,function(a){a.$expanded&&e.push("/"+a.id),_.reduce(a.$$flattenMailboxes,function(a,b){return b.$expanded&&a.push("/"+b.id),a},e)}),a.$$resource.post(null,"saveFoldersState",e)))):d=this.$$flattenMailboxes,d},a.prototype.$getMailboxByType=function(a){var b,c=function(b){var d=_.find(b,function(b){return b.type==a});return d||angular.forEach(b,function(a){!d&&a.children&&a.children.length>0&&(d=c(a.children))}),d};return b=c(this.$mailboxes)},a.prototype.$getMailboxByPath=function(a){var b=null,c=function(b){var d=_.find(b,function(b){return b.path==a});return d||angular.forEach(b,function(a){!d&&a.children&&a.children.length>0&&(d=c(a.children))}),d};return b=c(this.$mailboxes)},a.prototype.$newMailbox=function(b,c){var d=this;return a.$$resource.post(b.toString(),"createFolder",{name:c}).then(function(){d.$getMailboxes({reload:!0})})},a.prototype.updateQuota=function(a){var b,c,d;b=Math.round(1e4*a.usedSpace/a.maxQuota)/100,c=l("quotasFormat"),d=c.formatted(b,Math.round(a.maxQuota/10.24)/100),this.$quota={percent:b,description:d}},a.prototype.$newMessage=function(){var b=this;return a.$$resource.fetch(this.id.toString(),"compose").then(function(c){a.$log.debug("New message (compose): "+JSON.stringify(c,void 0,2));var d=new a.$Message(c.accountId,b.$getMailboxByPath(c.mailboxPath),c);return d}).then(function(b){return a.$$resource.fetch(b.$absolutePath({asDraft:!0}),"edit").then(function(c){return a.$log.debug("New message (edit): "+JSON.stringify(c,void 0,2)),angular.extend(b.editable,c),b.isNew=!0,b})})},a.prototype.$addDelegate=function(b){var c=this,d=a.$q.defer(),e={uid:b.uid};return!b.uid||_.indexOf(_.map(this.delegates,"uid"),b.uid)>-1?d.resolve():a.$$resource.fetch(this.id.toString(),"addDelegate",e).then(function(){c.delegates.push(b),d.resolve(c.users)},function(a,b){d.reject(l("An error occured please try again."))}),d.promise},a.prototype.$removeDeleg
R.virtualMailbox.setMailboxes(c),R.virtualMailbox.startSearch(R.search.match,R.search.params),a.go("mail.account.virtualMailbox",{accountId:R.accounts[0].id})}}function w(a){return R.currentSearchParam=a,i("advancedSearch"),!1}function x(a){if(a.length&&R.currentSearchParam.length){var b=0,c=R.currentSearchParam;return a.startsWith("!")&&(b=1,a=a.substring(1).trim()),R.currentSearchParam="",{searchBy:c,searchInput:a,negative:b}}}function y(a){a.$expanded=!a.$expanded,a.$flattenMailboxes({reload:!0,saveState:!0}),b(function(){angular.element(c).triggerHandler("resize")},150)}function z(a){k.prompt(l("New folder"),l("Enter the new name of your folder :")).then(function(b){a.$newMailbox(a.id,b).then(function(){},function(a,c){k.alert(l('An error occured while creating the mailbox "%{0}".',b),l(a.error))})})}function A(a){function b(a,b,c,d){function e(a){return c.$filter(a,d.delegates)}function f(){b.hide()}function g(a){d.$removeDelegate(a.uid).catch(function(a,b){k.alert(l("Warning"),l("An error occured please try again."))})}function h(a){a&&d.$addDelegate(a).then(function(){i.userToAdd="",i.searchText=""},function(a){k.alert(l("Warning"),a)})}var i=this;i.users=d.delegates,i.account=d,i.userToAdd="",i.searchText="",i.userFilter=e,i.closeModal=f,i.removeUser=g,i.addUser=h}d.show({templateUrl:a.id+"/delegation",controller:b,controllerAs:"delegate",clickOutsideToClose:!0,escapeToClose:!0,locals:{User:q,account:a}}),b.$inject=["$scope","$mdDialog","User","account"]}function B(a){R.editMode=a.path,i("mailboxName_"+a.path)}function C(a){a.$reset(),R.editMode=!1}function D(b,c,d){R.editMode!=d.path&&(R.editMode=!1,R.showingAdvancedSearch=!1,R.service.$virtualMode=!1,f(h["gt-md"])||g("left").close(),a.go("mail.account.mailbox",{accountId:c.id,mailboxId:j(d.path)}),b.stopPropagation(),b.preventDefault())}function E(a){a.$rename().then(function(a){R.editMode=!1})}function F(a){a.$compact().then(function(){e.show(e.simple().content(l("Folder compacted")).position("top right").hideDelay(3e3))})}function G(a){a.$emptyTrash().then(function(){e.show(e.simple().content(l("Trash emptied")).position("top right").hideDelay(3e3))})}function H(b){k.confirm(l("Confirmation"),l("Do you really want to move this folder into the trash ?")).then(function(){b.$delete().then(function(){a.go("mail.account.inbox")},function(a,c){k.alert(l('An error occured while deleting the mailbox "%{0}".',b.name),l(a.error))})})}function I(a){a.$markAsRead()}function J(a){a.$acl.$users().then(function(){d.show({templateUrl:a.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:a.$acl.users,User:q,folder:a}})})}function K(a){return"inbox"==a.type?{name:a.name,icon:"inbox"}:"draft"==a.type?{name:l("DraftsFolderName"),icon:"drafts"}:"sent"==a.type?{name:l("SentFolderName"),icon:"send"}:"trash"==a.type?{name:l("TrashFolderName"),icon:"delete"}:"junk"==a.type?{name:l("JunkFolderName"),icon:"thumb_down"}:"additional"==a.type?{name:a.name,icon:"folder_shared"}:{name:a.name,icon:"folder_open"}}function L(a,b){a.$setFolderAs(b).then(function(){a.$account.$getMailboxes({reload:!0})})}function M(){var a=window.unseenCountFolders;_.forEach(R.accounts,function(b){_.includes(a,b.id+"/folderINBOX")||a.push(b.id+"/folderINBOX"),_.forEach(b.$$flattenMailboxes,function(b){angular.isDefined(b.unseenCount)&&!_.includes(a,b.id)&&a.push(b.id)})}),n.$$resource.post("","unseenCount",{mailboxes:a}).then(function(a){_.forEach(R.accounts,function(b){_.forEach(b.$$flattenMailboxes,function(b){a[b.id]&&(b.unseenCount=a[b.id])})})}),r.ready().then(function(){var a=r.defaults.SOGoRefreshViewCheck;a&&"manually"!=a&&b(R.refreshUnseenCount,1e3*a.timeInterval())})}function N(a,b){return b.id!=a.id&&!b.isNoSelect()}function O(b,c,d){var f,g,h,i,j,k;f="/"+c.id,g=b.$selectedMessages(),0===g.length&&(g=[b.$selectedMessage()]),h=_.map(g,"uid"),i=b.selectedMessage&&h.indexOf(b.selectedMessage)>=0,"copy"==d?(j=b.$copyMessages(g,f),k=l("%{0} message(s) copied",g.length)):(j=b.$moveMessages(g,f),k=l("%{0} message(s) moved",g.length)),
//# sourceMappingURL=Mailer.services.js.map