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

2 lines
71 KiB
JavaScript
Raw Normal View History

2018-05-17 07:24:35 +02:00
!function(){"use strict";function e(t){"function"!=typeof t.then&&(angular.extend(this,t),_.forEach(this.identities,function(e){e.fullName?e.full=e.fullName+" <"+e.email+">":e.full="<"+e.email+">"}),e.$log.debug("Account: "+JSON.stringify(t,void 0,2)))}e.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(t,n,s,i,o,a,r,l){return angular.extend(e,{$q:t,$timeout:n,$log:s,$$resource:new o(i.activeUser("folderURL")+"Mail",i.activeUser()),$Preferences:a,$Mailbox:r,$Message:l}),e}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",e.$factory),e.$findAll=function(t){return t?e.$unwrapCollection(t):e.$$resource.fetch("","mailAccounts").then(function(t){return e.$unwrapCollection(t)})},e.$unwrapCollection=function(t){var n=[];return angular.forEach(t,function(t,s){t.id=s,n[s]=new e(t)}),e.$accounts=n,n},e.prototype.getLength=function(){return this.$flattenMailboxes().length},e.prototype.getItemAtIndex=function(e){var t;return t=this.$flattenMailboxes(),e>=0&&e<t.length?t[e]:null},e.prototype.$getMailboxes=function(t){var n=this;return!this.$mailboxes||t&&t.reload?e.$Mailbox.$find(this,t).then(function(t){n.$mailboxes=t,n.$expanded=!1;var s,i=function(e){_.forEach(e,function(e){e.$expanded=s.indexOf("/"+e.id)>=0,e.children&&e.children.length>0&&i(e.children)})};if(e.$Preferences.settings.Mail.ExpandedFolders){if(angular.isString(e.$Preferences.settings.Mail.ExpandedFolders))try{s=angular.fromJson(e.$Preferences.settings.Mail.ExpandedFolders)}catch(t){e.$log.warn("Can't parse list of expanded folders. String was: "+e.$Preferences.settings.Mail.ExpandedFolders),s=[]}else s=e.$Preferences.settings.Mail.ExpandedFolders;n.$expanded=s.indexOf("/"+n.id)>=0,s.length>0&&i(n.$mailboxes)}return e.$accounts&&(n.$expanded|=1==e.$accounts.length),n.$flattenMailboxes({reload:!0}),n.$mailboxes}):e.$q.when(this.$mailboxes)},e.prototype.$flattenMailboxes=function(t){var n=[],s=[],i=function(e){_.forEach(e,function(e){n.push(e),(t&&t.all||e.$expanded)&&e.children&&e.children.length>0&&i(e.children)})};return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(i(this.$mailboxes),t&&t.all||(this.$$flattenMailboxes=n,t&&t.saveState&&(_.forEach(e.$accounts,function(e){e.$expanded&&s.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},s)}),e.$$resource.post(null,"saveFoldersState",s)))):n=this.$$flattenMailboxes,n},e.prototype.$getMailboxByType=function(e){var t=function(n){var s=_.find(n,function(t){return t.type==e});return s||angular.forEach(n,function(e){!s&&e.children&&e.children.length>0&&(s=t(e.children))}),s};return t(this.$mailboxes)},e.prototype.$getMailboxByPath=function(e){var t=function(n){var s=_.find(n,function(t){return t.path==e});return s||angular.forEach(n,function(e){!s&&e.children&&e.children.length>0&&(s=t(e.children))}),s};return t(this.$mailboxes)},e.prototype.$newMailbox=function(t,n){var s=this;return e.$$resource.post(t.toString(),"createFolder",{name:n}).then(function(){s.$getMailboxes({reload:!0})})},e.prototype.$certificate=function(){var t=this;return this.security&&this.security.hasCertificate?this.$$certificate?e.$q.when(this.$$certificate):e.$$resource.fetch(this.id.toString(),"certificate").then(function(e){return t.$$certificate=e,e}):e.$q.reject()},e.prototype.$removeCertificate=function(){var t=this;return e.$$resource.fetch(this.id.toString(),"removeCertificate").then(function(){t.security.hasCertificate=!1})},e.prototype.updateQuota=function(e){var t,n;t=Math.round(1e4*e.usedSpace/e.maxQuota)/100,n=l("quotasFormat").formatted(t,Math.round(e.maxQuota/10.24)/100),this.$quota={percent:t,description:n}},e.prototype.$newMessage=function(t){var n=this;return e.$$resource.fetch(this.id.toString(),"compose").then(function(t){e.$log.debug("New message (compose): "+JSON.stringify(t,void 0,2));return new e.$Message(t.accountId,n.$getMailboxByPath(t.mailboxPath),t)}).then(function(s){return e.$$resource.fetch(s.$absolutePath({asDraft:!0}),"edit")
//# sourceMappingURL=Mailer.services.js.map