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

2 lines
76 KiB
JavaScript
Raw Normal View History

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