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

2 lines
54 KiB
JavaScript
Raw Normal View History

2017-05-13 07:24:30 +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,o,a,s,i,r,l){return angular.extend(e,{$q:t,$timeout:n,$log:o,$$resource:new s(a.activeUser("folderURL")+"Mail",a.activeUser()),$Preferences:i,$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,o){t.id=o,n[o]=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){return n.$mailboxes=t,n.$expanded=!1,e.$Preferences.ready().then(function(){var t,o=function(e){_.forEach(e,function(e){e.$expanded=t.indexOf("/"+e.id)>=0,e.children&&e.children.length>0&&o(e.children)})};e.$Preferences.settings.Mail.ExpandedFolders&&(t=angular.isString(e.$Preferences.settings.Mail.ExpandedFolders)?angular.fromJson(e.$Preferences.settings.Mail.ExpandedFolders):e.$Preferences.settings.Mail.ExpandedFolders,n.$expanded=t.indexOf("/"+n.id)>=0,t.length>0&&o(n.$mailboxes)),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=this,o=[],a=[],s=function(e){_.forEach(e,function(e){o.push(e),(t&&t.all||e.$expanded)&&e.children&&e.children.length>0&&s(e.children)})};return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(s(this.$mailboxes),t&&t.all||(n.$$flattenMailboxes=o,t&&t.saveState&&(_.forEach(e.$accounts,function(e){e.$expanded&&a.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},a)}),e.$$resource.post(null,"saveFoldersState",a)))):o=this.$$flattenMailboxes,o},e.prototype.$getMailboxByType=function(e){var t=function(n){var o=_.find(n,function(t){return t.type==e});return o||angular.forEach(n,function(e){!o&&e.children&&e.children.length>0&&(o=t(e.children))}),o};return t(this.$mailboxes)},e.prototype.$getMailboxByPath=function(e){var t=function(n){var o=_.find(n,function(t){return t.path==e});return o||angular.forEach(n,function(e){!o&&e.children&&e.children.length>0&&(o=t(e.children))}),o};return t(this.$mailboxes)},e.prototype.$newMailbox=function(t,n){var o=this;return e.$$resource.post(t.toString(),"createFolder",{name:n}).then(function(){o.$getMailboxes({reload:!0})})},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(){var t=this;return e.$$resource.fetch(this.id.toString(),"compose").then(function(n){return e.$log.debug("New message (compose): "+JSON.stringify(n,void 0,2)),new e.$Message(n.accountId,t.$getMailboxByPath(n.mailboxPath),n)}).then(function(t){return e.$$resource.fetch(t.$absolutePath({asDraft:!0}),"edit").then(function(n){return e.$log.debug("New message (edit): "+JSON.stringify(n,void 0,2)),angular.extend(t.editable,n),t.isNew=!0,t})})},e.prototype.$addDelegate=function(t){var n=this,o=e.$q.defer(),a={uid:t.uid};return!t.uid||_.indexOf(_.map(this.delegates,"uid"),t.uid)>-1?o.resolve():e.$$resource.fetch(this.id.toString(),"addDelegate",a).then(function(){n.delegates.push(t),o.resolve(n.users)},function(e,t){o.reject(l("An error occured please try again."))}),o.promise},e.prototype.$removeDelegate=function(t){var n=thi
//# sourceMappingURL=Mailer.services.js.map