diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js index e7bf9226ad..5e99b934ce 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js @@ -43,6 +43,12 @@ define(function(require) { this.selected_row_role_id = undefined; + // Controls visibility of buttons only available to OneFlow services. This + // panel is also used by the OneFlow templates + this.servicePanel = true; + + this.panelId = PANEL_ID; + return this; } @@ -77,6 +83,8 @@ define(function(require) { return TemplateHTML({ 'element': this.element, + 'panelId': this.panelId, + 'servicePanel': this.servicePanel, 'roleList': roleList }); } @@ -91,7 +99,7 @@ define(function(require) { var roles = this.element.TEMPLATE.BODY.roles; if (roles && roles.length) { this.servicerolesDataTable = new DomDataTable( - 'datatable_service_roles', + 'datatable_roles_'+this.panelId, { actions: true, info: false, @@ -120,9 +128,6 @@ define(function(require) { Sunstone.insertButtonsInTab("oneflow-services", "service_roles_tab", roles_buttons, $('#role_actions', context)); - // TODO - //setupScaleDialog(); - // TODO: global var, see Service.refresh /* if(selected_row_role_id) { @@ -190,60 +195,64 @@ define(function(require) { return TemplateRoleInfo({ 'role': role, + 'servicePanel': this.servicePanel, + 'panelId': this.panelId, 'vmsTableColumns': VMsTableUtils.columns, 'vms': vms }); } function _roleSetup(context, role_index) { - var role = this.element.TEMPLATE.BODY.roles[role_index]; + if(this.servicePanel) { + var role = this.element.TEMPLATE.BODY.roles[role_index]; - // This table has 2 more columns to the left compared to the normal VM table - // The visibility index array needs to be adjusted - var visibleColumns = [0,1].concat( - SunstoneConfig.tabTableColumns(VMS_TAB_ID).map(function(n){ - return n+2; - })); + // This table has 2 more columns to the left compared to the normal VM table + // The visibility index array needs to be adjusted + var visibleColumns = [0,1].concat( + SunstoneConfig.tabTableColumns(VMS_TAB_ID).map(function(n){ + return n+2; + })); - this.serviceroleVMsDataTable = new DomDataTable( - 'datatable_service_vms_'+role.name, - { - actions: true, - info: false, - customTabContext: $('#role_vms_actions', context), - dataTableOptions: { - "bAutoWidth": false, - "bSortClasses" : false, - "bDeferRender": true, - "aoColumnDefs": [ - {"bSortable": false, "aTargets": [0,1,"check"]}, - {"bVisible": true, "aTargets": visibleColumns}, - {"bVisible": false, "aTargets": ['_all']} - ] - } - }); - - // TODO: global vars, see Service.refresh - /* - if(last_selected_row_rolevm) { - last_selected_row_rolevm.children().each(function(){ - $(this).removeClass('markrowchecked'); + this.serviceroleVMsDataTable = new DomDataTable( + 'datatable_vms_'+this.panelId+'_'+role.name, + { + actions: true, + info: false, + customTabContext: $('#role_vms_actions', context), + dataTableOptions: { + "bAutoWidth": false, + "bSortClasses" : false, + "bDeferRender": true, + "aoColumnDefs": [ + {"bSortable": false, "aTargets": [0,1,"check"]}, + {"bVisible": true, "aTargets": visibleColumns}, + {"bVisible": false, "aTargets": ['_all']} + ] + } }); + + // TODO: global vars, see Service.refresh + /* + if(last_selected_row_rolevm) { + last_selected_row_rolevm.children().each(function(){ + $(this).removeClass('markrowchecked'); + }); + } + + last_selected_row_rolevm = $(this); + $(this).children().each(function(){ + $(this).addClass('markrowchecked'); + }); + */ + + this.serviceroleVMsDataTable.initialize(); + Sunstone.insertButtonsInTab( + "oneflow-services", + "service_roles_tab", + roles_vm_buttons, + $('div#role_vms_actions', context)); } - last_selected_row_rolevm = $(this); - $(this).children().each(function(){ - $(this).addClass('markrowchecked'); - }); - */ - - this.serviceroleVMsDataTable.initialize(); - Sunstone.insertButtonsInTab( - "oneflow-services", - "service_roles_tab", - roles_vm_buttons, - $('div#role_vms_actions', context)); - Tips.setup(context); } }); diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/html.hbs b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/html.hbs index 4229f3b6e9..ecad08e84b 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/html.hbs +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/html.hbs @@ -1,18 +1,16 @@
+ {{#if servicePanel}}
-
-

{{tr "Roles"}}

-
-
+
-
+
-
+
@@ -23,15 +21,18 @@
+ {{/if}}
- +
+ {{#if servicePanel}} + {{/if}} @@ -44,7 +45,9 @@ + {{#if ../servicePanel}} + {{/if}} diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs index a3892ca932..c499c40613 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles/roleInfo.hbs @@ -22,6 +22,7 @@
{{tr "Name"}}{{tr "State"}}{{tr "Cardinality"}} {{tr "VM Template"}} {{tr "Parents"}} {{name}}{{state}}{{cardinality}} {{vm_template}} {{parents}}

+ {{#if servicePanel}}
{{tr "Virtual Machines"}}
@@ -30,7 +31,7 @@

- +
@@ -55,6 +56,7 @@
+ {{/if}}

{{#if role.elasticity_policies}} @@ -101,8 +103,12 @@ {{valOrDefault expression_evaluated this.expression}} {{#if period_number}} + {{#if servicePanel}} {{valOrDefault true_evals "0"}}/{{period_number}} {{else}} + {{period_number}} + {{/if}} + {{else}} - {{/if}} @@ -150,7 +156,7 @@ {{type}} {{adjust}} - {{valOrDefault min_adjust_step ""}} + {{valOrDefault min_adjust_step "-"}} {{#if start_time}} {{tr "Start time"}} {{start_time}} diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab.js b/src/sunstone/public/app/tabs/oneflow-templates-tab.js index 229012b76c..59d389d9ce 100644 --- a/src/sunstone/public/app/tabs/oneflow-templates-tab.js +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab.js @@ -9,12 +9,11 @@ define(function(require) { var RESOURCE = "ServiceTemplate"; var _dialogs = [ - //require('./oneflow-templates-tab/dialogs/instantiate') ]; var _panels = [ require('./oneflow-templates-tab/panels/info'), - //require('./oneflow-templates-tab/panels/roles') + require('./oneflow-templates-tab/panels/roles') ]; var _formPanels = [ diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/roles.js b/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/roles.js new file mode 100644 index 0000000000..ef9ce3c6a1 --- /dev/null +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/roles.js @@ -0,0 +1,32 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var BasePanel = require('tabs/oneflow-services-tab/panels/roles'); + + /* + CONSTANTS + */ + + var PANEL_ID = require('./roles/panelId'); + + /* + CONSTRUCTOR + */ + + function Panel(info) { + BasePanel.call(this, info); + + this.servicePanel = false; + this.panelId = PANEL_ID; + + return this; + } + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype = Object.create(BasePanel.prototype); + Panel.prototype.constructor = Panel; + + return Panel; +}); diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/roles/panelId.js b/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/roles/panelId.js new file mode 100644 index 0000000000..12d21e43ab --- /dev/null +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab/panels/roles/panelId.js @@ -0,0 +1,3 @@ +define(function(require){ + return 'service_template_roles_tab'; +}); \ No newline at end of file