From 9195efdcc4a8b8192ae286451a54b9c47fc421c1 Mon Sep 17 00:00:00 2001 From: Jean-Roch Maitre Date: Fri, 30 Jun 2017 15:10:10 -0700 Subject: [PATCH] UI-2789: add a way to select storage plan for faxes --- app.js | 128 ++++++++++++++++++++++++++++++++++++++------- i18n/en-US.json | 3 +- views/storage.html | 3 ++ 3 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 views/storage.html diff --git a/app.js b/app.js index 354a029..2a55762 100644 --- a/app.js +++ b/app.js @@ -45,32 +45,120 @@ define(function(require){ render: function(container) { var self = this; - self.listFaxboxes(function(faxboxes) { - self.appFlags.faxboxes = _.indexBy(faxboxes, 'id'); + self.getFaxData(function(results) { + self.appFlags.faxboxes = _.indexBy(results.faxboxes, 'id'); + + var menus = [ + { + tabs: [ + { + text: self.i18n.active().fax.menuTitles.inbound, + callback: self.renderInbound + }, + { + text: self.i18n.active().fax.menuTitles.outbound, + callback: self.renderOutbound + }, + { + text: self.i18n.active().fax.menuTitles.logs, + callback: self.renderLogs + } + ] + } + ]; + + if (results.storage) { + var tabStorage = { + text: self.i18n.active().fax.menuTitles.storage, + callback: self.renderStorage + }; + + menus[0].tabs.push(tabStorage); + } monster.ui.generateAppLayout(self, { - menus: [ - { - tabs: [ - { - text: self.i18n.active().fax.menuTitles.inbound, - callback: self.renderInbound - }, - { - text: self.i18n.active().fax.menuTitles.outbound, - callback: self.renderOutbound - }, - { - text: self.i18n.active().fax.menuTitles.logs, - callback: self.renderLogs - } - ] - } - ] + menus: menus }); }); }, + getFaxData: function(callback) { + var self = this; + + monster.parallel({ + faxboxes: function(callback) { + self.listFaxboxes(function(faxboxes) { + callback(null, faxboxes); + }); + }, + storage: function(callback) { + self.getStorage(function(storage) { + callback(null, storage); + }); + } + }, + function(err, results) { + callback && callback(results); + }); + }, + + getStorage: function(callback) { + var self = this; + + self.callApi({ + resource: 'storage.get', + data: { + accountId: self.accountId, + generateError: false + }, + success: function(data) { + callback(data.data); + }, + error: function(data, error, globalHandler) { + if (error.status === 404) { + callback(undefined); + } else { + globalHandler(data); + } + } + }); + }, + + renderStorage: function(pArgs) { + var self = this, + args = pArgs || {}, + parent = args.container || $('#fax_app_container .app-content-wrapper'); + + self.getStorage(function(storage) { + var formattedData = self.storageFormatData(storage), + template = $(monster.template(self, 'storage', formattedData)); + + self.storageBindEvents(template); + + monster.pub('common.storagePlanManager.render', { + container: template.find('.control-container'), + forceTypes: ['fax'], + hideOtherTypes: true + }); + + parent + .fadeOut(function() { + $(this) + .empty() + .append(template) + .fadeIn(); + }); + }); + }, + + storageBindEvents: function(template) { + var self = this; + }, + + storageFormatData: function(data) { + return data; + }, + renderFaxes: function(pArgs) { var self = this, args = pArgs || {}, diff --git a/i18n/en-US.json b/i18n/en-US.json index 5570652..c54bc65 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -4,7 +4,8 @@ "menuTitles": { "inbound": "Inbound faxes", "outbound": "Outbound faxes", - "logs": "Email-to-Fax Logs" + "logs": "Email-to-Fax Logs", + "storage": "Storage" }, "table": { "columns": { diff --git a/views/storage.html b/views/storage.html new file mode 100644 index 0000000..7c1369c --- /dev/null +++ b/views/storage.html @@ -0,0 +1,3 @@ +
+
+