diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index 298a12b6a2..85fb5b4e8c 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -8,12 +8,43 @@ features: tabs: provision-tab: panel_tabs: + vm_info_tab: false + vm_capacity_tab: false + vm_hotplugging_tab: false + vm_network_tab: false + vm_snapshot_tab: false + vm_placement_tab: false + vm_actions_tab: false + vm_template_tab: false + vm_log_tab: false + provision_tabs: users: false flows: true templates: true - actions: + actions: &provisionactions Template.chmod: false Template.delete: true + VM.resume: true + VM.reboot: true + VM.reboot_hard: true + VM.poweroff: true + VM.poweroff_hard: true + VM.undeploy: false + VM.undeploy_hard: false + VM.shutdown_hard: true + VM.delete: true + VM.resize: false + VM.attachdisk: false + VM.detachdisk: false + VM.disk_saveas: false + VM.attachnic: false + VM.detachnic: false + VM.snapshot_create: false + VM.snapshot_revert: false + VM.snapshot_delete: false + VM.disk_snapshot_create: false + VM.disk_snapshot_revert: false + VM.disk_snapshot_delete: false dashboard: quotas: true vms: true @@ -33,3 +64,32 @@ tabs: user_showback_tab: true actions: User.quotas_dialog: false + vms-tab: + actions: *provisionactions + images-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Datastore + #- 6 # Size + - 7 # Type + #- 8 # Registration time + #- 9 # Persistent + - 10 # Status + - 11 # #VMs + #- 12 # Target + vnets-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Reservation + - 6 # Cluster + #- 7 # Bridge + - 8 # Leases + #- 9 # VLAN ID diff --git a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml index 55ab8eb8a7..9495e19cef 100644 --- a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml @@ -8,12 +8,43 @@ features: tabs: provision-tab: panel_tabs: + vm_info_tab: false + vm_capacity_tab: false + vm_hotplugging_tab: false + vm_network_tab: false + vm_snapshot_tab: false + vm_placement_tab: false + vm_actions_tab: false + vm_template_tab: false + vm_log_tab: false + provision_tabs: users: false flows: true templates: false - actions: + actions: &provisionactions Template.chmod: false Template.delete: true + VM.resume: true + VM.reboot: true + VM.reboot_hard: true + VM.poweroff: true + VM.poweroff_hard: true + VM.undeploy: false + VM.undeploy_hard: false + VM.shutdown_hard: true + VM.delete: true + VM.resize: false + VM.attachdisk: false + VM.detachdisk: false + VM.disk_saveas: false + VM.attachnic: false + VM.detachnic: false + VM.snapshot_create: false + VM.snapshot_revert: false + VM.snapshot_delete: false + VM.disk_snapshot_create: false + VM.disk_snapshot_revert: false + VM.disk_snapshot_delete: false dashboard: quotas: true vms: true @@ -31,4 +62,33 @@ tabs: user_accounting_tab: true user_showback_tab: true actions: - User.quotas_dialog: false \ No newline at end of file + User.quotas_dialog: false + vms-tab: + actions: *provisionactions + images-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Datastore + #- 6 # Size + - 7 # Type + #- 8 # Registration time + #- 9 # Persistent + - 10 # Status + - 11 # #VMs + #- 12 # Target + vnets-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Reservation + - 6 # Cluster + #- 7 # Bridge + - 8 # Leases + #- 9 # VLAN ID diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index 992fb3bf69..fc82168c55 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -8,12 +8,43 @@ features: tabs: provision-tab: panel_tabs: + vm_info_tab: false + vm_capacity_tab: false + vm_hotplugging_tab: false + vm_network_tab: false + vm_snapshot_tab: false + vm_placement_tab: false + vm_actions_tab: false + vm_template_tab: false + vm_log_tab: false + provision_tabs: users: true flows: true templates: true - actions: + actions: &provisionactions Template.chmod: true Template.delete: true + VM.resume: true + VM.reboot: true + VM.reboot_hard: true + VM.poweroff: true + VM.poweroff_hard: true + VM.undeploy: false + VM.undeploy_hard: false + VM.shutdown_hard: true + VM.delete: true + VM.resize: false + VM.attachdisk: false + VM.detachdisk: false + VM.disk_saveas: false + VM.attachnic: false + VM.detachnic: false + VM.snapshot_create: false + VM.snapshot_revert: false + VM.snapshot_delete: false + VM.disk_snapshot_create: false + VM.disk_snapshot_revert: false + VM.disk_snapshot_delete: false dashboard: quotas: false vms: false @@ -33,3 +64,33 @@ tabs: user_showback_tab: true actions: User.quotas_dialog: false + vms-tab: + actions: *provisionactions + images-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Datastore + #- 6 # Size + - 7 # Type + #- 8 # Registration time + #- 9 # Persistent + - 10 # Status + - 11 # #VMs + #- 12 # Target + vnets-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Reservation + - 6 # Cluster + #- 7 # Bridge + - 8 # Leases + #- 9 # VLAN ID + diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index f9aa865470..2f2b78d2d9 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -8,12 +8,43 @@ features: tabs: provision-tab: panel_tabs: + vm_info_tab: false + vm_capacity_tab: false + vm_hotplugging_tab: false + vm_network_tab: false + vm_snapshot_tab: false + vm_placement_tab: false + vm_actions_tab: false + vm_template_tab: false + vm_log_tab: false + provision_tabs: users: true flows: true templates: false - actions: - Template.chmod: true + actions: &provisionactions + Template.chmod: false Template.delete: true + VM.resume: true + VM.reboot: true + VM.reboot_hard: true + VM.poweroff: true + VM.poweroff_hard: true + VM.undeploy: false + VM.undeploy_hard: false + VM.shutdown_hard: true + VM.delete: true + VM.resize: false + VM.attachdisk: false + VM.detachdisk: false + VM.disk_saveas: false + VM.attachnic: false + VM.detachnic: false + VM.snapshot_create: false + VM.snapshot_revert: false + VM.snapshot_delete: false + VM.disk_snapshot_create: false + VM.disk_snapshot_revert: false + VM.disk_snapshot_delete: false dashboard: quotas: false vms: false @@ -32,3 +63,33 @@ tabs: user_showback_tab: true actions: User.quotas_dialog: false + vms-tab: + actions: *provisionactions + images-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Datastore + #- 6 # Size + - 7 # Type + #- 8 # Registration time + #- 9 # Persistent + - 10 # Status + - 11 # #VMs + #- 12 # Target + vnets-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + - 5 # Reservation + - 6 # Cluster + #- 7 # Bridge + - 8 # Leases + #- 9 # VLAN ID + diff --git a/src/sunstone/public/app/sunstone-config.js b/src/sunstone/public/app/sunstone-config.js index fb869f105e..32baec5510 100644 --- a/src/sunstone/public/app/sunstone-config.js +++ b/src/sunstone/public/app/sunstone-config.js @@ -50,6 +50,15 @@ define(function(require) { } }, + "isProvisionTabEnabled": function(tabName, panelTabName) { + if (_config['view']['tabs'][tabName]) { + var enabled = _config['view']['tabs'][tabName]['provision_tabs'][panelTabName]; + return enabled; + } else { + return false; + } + }, + "isFeatureEnabled": function(featureName) { if (_config['view']['features'] && _config['view']['features'][featureName]) { return true; diff --git a/src/sunstone/public/app/tabs/provision-tab.js b/src/sunstone/public/app/tabs/provision-tab.js index c4b375341a..c25ca51f9f 100644 --- a/src/sunstone/public/app/tabs/provision-tab.js +++ b/src/sunstone/public/app/tabs/provision-tab.js @@ -841,7 +841,7 @@ define(function(require) { provision_vdc_templates_datatable.fnFilter("^(?!\-$)", 2, true, false); provision_vdc_templates_datatable.fnFilter("^1$", 3, true, false); - if (Config.isTabPanelEnabled("provision-tab", "templates")) { + if (Config.isProvisionTabEnabled("provision-tab", "templates")) { ProvisionTemplatesList.updateDatatable(provision_saved_templates_datatable); provision_saved_templates_datatable.fnFilter("^(?!\-$)", 2, true, false); provision_saved_templates_datatable.fnFilter("^0$", 3, true, false); @@ -969,12 +969,43 @@ define(function(require) { $(".alert-box-error", context).html(""); } + var _panels = [ + require('./vms-tab/panels/info'), + require('./vms-tab/panels/capacity'), + require('./vms-tab/panels/storage'), + require('./vms-tab/panels/network'), + require('./vms-tab/panels/snapshots'), + require('./vms-tab/panels/placement'), + require('./vms-tab/panels/actions'), + require('./vms-tab/panels/template'), + require('./vms-tab/panels/log') + ]; + + + var _dialogs = [ + //require('./vms-tab/dialogs/deploy'), + //require('./vms-tab/dialogs/migrate'), + require('./vms-tab/dialogs/resize'), + require('./vms-tab/dialogs/attach-disk'), + require('./vms-tab/dialogs/disk-snapshot'), + require('./vms-tab/dialogs/disk-saveas'), + require('./vms-tab/dialogs/attach-nic'), + require('./vms-tab/dialogs/snapshot'), + //require('./vms-tab/dialogs/vnc'), + //require('./vms-tab/dialogs/spice'), + //require('./vms-tab/dialogs/saveas-template') + ]; + + var Actions = require('./vms-tab/actions'); + var Tab = { tabId: TAB_ID, list_header: "", - actions: povision_actions, + actions: $.extend(povision_actions, Actions), content: TemplateContent(), - setup: _setup + setup: _setup, + panels: _panels, + dialogs: _dialogs }; return Tab; @@ -993,7 +1024,7 @@ define(function(require) { ProvisionVmsList.generate($(".provision_vms_list_section"), {active: true}); - if (Config.isTabPanelEnabled("provision-tab", "templates")) { + if (Config.isProvisionTabEnabled("provision-tab", "templates")) { ProvisionTemplatesList.generate($(".provision_templates_list_section"), {active: true}); } diff --git a/src/sunstone/public/app/tabs/provision-tab/content.hbs b/src/sunstone/public/app/tabs/provision-tab/content.hbs index c20d7c2455..8b29b59cb9 100644 --- a/src/sunstone/public/app/tabs/provision-tab/content.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/content.hbs @@ -20,17 +20,17 @@ {{> tabs/provision-tab/vms/create}} -{{#isTabPanelEnabled "provision-tab" "templates"}} +{{#isProvisionTabEnabled "provision-tab" "templates"}} -{{/isTabPanelEnabled}} +{{/isProvisionTabEnabled}} -{{#isTabPanelEnabled "provision-tab" "users"}} +{{#isProvisionTabEnabled "provision-tab" "users"}} {{> tabs/provision-tab/group/info}} {{> tabs/provision-tab/users/create}} -{{/isTabPanelEnabled}} +{{/isProvisionTabEnabled}} -{{#isTabPanelEnabled "provision-tab" "flows"}} +{{#isProvisionTabEnabled "provision-tab" "flows"}} {{> tabs/provision-tab/flows/create}} -{{/isTabPanelEnabled}} +{{/isProvisionTabEnabled}} diff --git a/src/sunstone/public/app/tabs/provision-tab/header.hbs b/src/sunstone/public/app/tabs/provision-tab/header.hbs index c2b321e0a7..1ccdc4a385 100644 --- a/src/sunstone/public/app/tabs/provision-tab/header.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/header.hbs @@ -18,7 +18,7 @@
@@ -78,7 +93,7 @@
-
+
@@ -95,7 +110,7 @@
-
+
@@ -107,75 +122,80 @@

-
-
-
-

- {{tr "Net RX"}} -

+
+
+
+

+ {{tr "Net RX"}} +

+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+

+ {{tr "Net TX"}} +

+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-

- {{tr "Net TX"}} -

+
+
+
+

+ {{tr "Net Download Speed"}} +

+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+

+ {{tr "Net Upload Speed"}} +

+
-
-
-
-
-
-
-
-
-

- {{tr "Net Download Speed"}} -

+
+
+
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-

- {{tr "Net Upload Speed"}} -

-
-
-
-
-
-
-
-
-
-

-
+
+
+
+
+
diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/list.js b/src/sunstone/public/app/tabs/provision-tab/vms/list.js index 5a6fc19d63..14a626e29f 100644 --- a/src/sunstone/public/app/tabs/provision-tab/vms/list.js +++ b/src/sunstone/public/app/tabs/provision-tab/vms/list.js @@ -16,6 +16,7 @@ define(function(require) { require('foundation.alert'); + var Sunstone = require('sunstone'); var OpenNebula = require('opennebula'); var OpenNebulaVM = require('opennebula/vm'); var Locale = require('utils/locale'); @@ -27,6 +28,7 @@ define(function(require) { var TemplateVmsList = require('hbs!./list'); + var TAB_ID = require('../tabId'); var _accordionId = 0; return { @@ -247,6 +249,9 @@ define(function(require) { }, error: Notifier.onError, success: function(request, response){ + $(".provision-right-info").html(""); + Sunstone.insertPanels(TAB_ID, response, TAB_ID, $(".provision-right-info", context)); + var data = response.VM var state = get_provision_vm_state(data); @@ -254,6 +259,7 @@ define(function(require) { case "deploying": $(".provision_reboot_confirm_button", context).hide(); $(".provision_poweroff_confirm_button", context).hide(); + $(".provision_undeploy_confirm_button", context).hide(); $(".provision_poweron_button", context).hide(); $(".provision_delete_confirm_button", context).show(); $(".provision_shutdownhard_confirm_button", context).hide(); @@ -265,6 +271,7 @@ define(function(require) { case "running": $(".provision_reboot_confirm_button", context).show(); $(".provision_poweroff_confirm_button", context).show(); + $(".provision_undeploy_confirm_button", context).show(); $(".provision_poweron_button", context).hide(); $(".provision_delete_confirm_button", context).hide(); $(".provision_shutdownhard_confirm_button", context).show(); @@ -276,18 +283,32 @@ define(function(require) { case "off": $(".provision_reboot_confirm_button", context).hide(); $(".provision_poweroff_confirm_button", context).hide(); + $(".provision_undeploy_confirm_button", context).hide(); $(".provision_poweron_button", context).show(); - $(".provision_delete_confirm_button", context).show(); - $(".provision_shutdownhard_confirm_button", context).hide(); + $(".provision_delete_confirm_button", context).hide(); + $(".provision_shutdownhard_confirm_button", context).show(); $(".provision_snapshot_button", context).show(); $(".provision_vnc_button", context).hide(); $(".provision_snapshot_button_disabled", context).hide(); $(".provision_vnc_button_disabled", context).show(); break; + case "undeployed": + $(".provision_reboot_confirm_button", context).hide(); + $(".provision_poweroff_confirm_button", context).hide(); + $(".provision_undeploy_confirm_button", context).hide(); + $(".provision_poweron_button", context).show(); + $(".provision_delete_confirm_button", context).hide(); + $(".provision_shutdownhard_confirm_button", context).show(); + $(".provision_snapshot_button", context).hide(); + $(".provision_vnc_button", context).hide(); + $(".provision_snapshot_button_disabled", context).hide(); + $(".provision_vnc_button_disabled", context).show(); + break; case "powering_off": case "error": $(".provision_reboot_confirm_button", context).hide(); $(".provision_poweroff_confirm_button", context).hide(); + $(".provision_undeploy_confirm_button", context).hide(); $(".provision_poweron_button", context).hide(); $(".provision_delete_confirm_button", context).show(); $(".provision_shutdownhard_confirm_button", context).hide(); @@ -300,6 +321,7 @@ define(function(require) { color = 'secondary'; $(".provision_reboot_confirm_button", context).hide(); $(".provision_poweroff_confirm_button", context).hide(); + $(".provision_undeploy_confirm_button", context).hide(); $(".provision_poweron_button", context).hide(); $(".provision_delete_confirm_button", context).show(); $(".provision_shutdownhard_confirm_button", context).hide(); @@ -392,27 +414,27 @@ define(function(require) { monitor_resources : "MONITORING/CPU", labels : "Real CPU", humanize_figures : false, - div_graph : $(".vm_cpu_graph", context) + div_graph : $(".vm_cpu_provision_graph", context) }, { monitor_resources : "MONITORING/MEMORY", labels : "Real MEM", humanize_figures : true, - div_graph : $(".vm_memory_graph", context) + div_graph : $(".vm_memory_provision_graph", context) }, { labels : "Network reception", monitor_resources : "MONITORING/NETRX", humanize_figures : true, convert_from_bytes : true, - div_graph : $(".vm_net_rx_graph", context) + div_graph : $(".vm_net_rx_provision_graph", context) }, { labels : "Network transmission", monitor_resources : "MONITORING/NETTX", humanize_figures : true, convert_from_bytes : true, - div_graph : $(".vm_net_tx_graph", context) + div_graph : $(".vm_net_tx_provision_graph", context) }, { labels : "Network reception speed", @@ -421,7 +443,7 @@ define(function(require) { convert_from_bytes : true, y_sufix : "B/s", derivative : true, - div_graph : $(".vm_net_rx_speed_graph", context) + div_graph : $(".vm_net_rx_speed_provision_graph", context) }, { labels : "Network transmission speed", @@ -430,7 +452,7 @@ define(function(require) { convert_from_bytes : true, y_sufix : "B/s", derivative : true, - div_graph : $(".vm_net_tx_speed_graph", context) + div_graph : $(".vm_net_tx_speed_provision_graph", context) } ]; @@ -446,7 +468,7 @@ define(function(require) { }) } - if (Config.isTabPanelEnabled("provision-tab", "templates")) { + if (Config.isProvisionTabEnabled("provision-tab", "templates")) { context.on("click", ".provision_snapshot_button", function(){ $(".provision_confirm_action:first", context).html( '
'+ @@ -582,6 +604,37 @@ define(function(require) { '
'); }); + context.on("click", ".provision_undeploy_confirm_button", function(){ + $(".provision_confirm_action:first", context).html( + '
'+ + '
'+ + '
'+ + ''+ + Locale.tr("This action will power off this Virtual Machine and will be undeployed from the physical machine")+ + '
'+ + '
'+ + Locale.tr("You can send the power off signal to the Virtual Machine (this is equivalent to execute the command from the console). If that doesn't effect your Virtual Machine, try to Power off the machine (this is equivalent to pressing the power off button in a physical computer).")+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + ''+Locale.tr("Power off and undeploy")+''+ + ''+ + ''+ + '
'+ + '
'+ + '×'+ + '
'); + }); + context.on("click", ".provision_reboot_confirm_button", function(){ $(".provision_confirm_action:first", context).html( '
'+ @@ -682,6 +735,29 @@ define(function(require) { return false; }); + context.on("click", ".provision_undeploy_button", function(){ + var button = $(this); + button.attr("disabled", "disabled"); + var vm_id = $(".provision_info_vm", context).attr("vm_id"); + var undeploy_action = $('input[name=provision_undeploy_radio]:checked').val() + + OpenNebula.VM[undeploy_action]({ + data : { + id: vm_id + }, + success: function(request, response){ + update_provision_vm_info(vm_id, context); + button.removeAttr("disabled"); + }, + error: function(request, response){ + Notifier.onError(request, response); + button.removeAttr("disabled"); + } + }) + + return false; + }); + context.on("click", ".provision_reboot_button", function(){ var button = $(this); button.attr("disabled", "disabled"); @@ -933,11 +1009,15 @@ define(function(require) { case OpenNebulaVM.STATES.STOPPED: case OpenNebulaVM.STATES.SUSPENDED: case OpenNebulaVM.STATES.POWEROFF: - case OpenNebulaVM.STATES.UNDEPLOYED: case OpenNebulaVM.STATES.DONE: state_color = 'off'; state_str = Locale.tr("OFF"); + break; + case OpenNebulaVM.STATES.UNDEPLOYED: + state_color = 'undeployed'; + state_str = Locale.tr("UNDEPLOYED"); + break; default: state_color = 'powering_off'; diff --git a/src/sunstone/public/app/tabs/vms-tab/actions.js b/src/sunstone/public/app/tabs/vms-tab/actions.js index 6170433fb5..0649012060 100644 --- a/src/sunstone/public/app/tabs/vms-tab/actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/actions.js @@ -15,6 +15,7 @@ /* -------------------------------------------------------------------------- */ define(function(require) { + var Config = require('sunstone-config'); var Sunstone = require('sunstone'); var Notifier = require('utils/notifier'); var Locale = require('utils/locale'); @@ -38,7 +39,21 @@ define(function(require) { var _actions = { "VM.list": _commonActions.list(), - "VM.show": _commonActions.show(), + "VM.show": { + type: "single", + call: OpenNebulaVM.show, + callback: function(request, response) { + if (Config.isTabEnabled("provision-tab")) { + $(".provision_refresh_info", ".provision_list_vms").click(); + } else { + Sunstone.getDataTable(TAB_ID).updateElement(request, response); + if (Sunstone.rightInfoVisible($('#' + TAB_ID))) { + Sunstone.insertPanels(TAB_ID, response); + } + } + }, + error: Notifier.onError + }, "VM.refresh": _commonActions.refresh(), "VM.delete": _commonActions.del(), "VM.chown": _commonActions.multipleAction('chown'), diff --git a/src/sunstone/public/app/templates/helpers/isProvisionTabEnabled.js b/src/sunstone/public/app/templates/helpers/isProvisionTabEnabled.js new file mode 100644 index 0000000000..46bc29c8e4 --- /dev/null +++ b/src/sunstone/public/app/templates/helpers/isProvisionTabEnabled.js @@ -0,0 +1,32 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require) { + var Handlebars = require('hbs/handlebars'); + var Config = require('sunstone-config'); + + var isProvisionTabEnabled = function(tabName, panel, options) { + if (Config.isProvisionTabEnabled(tabName, panel)) { + return options.fn(this); + } else { + return options.inverse(this); + } + }; + + Handlebars.registerHelper('isProvisionTabEnabled', isProvisionTabEnabled); + + return isProvisionTabEnabled; +}) diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index ac78287e23..5c4ec15a59 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -393,7 +393,7 @@ define(function(require) { var row_id_index = this.dataTable.attr("row_id"); if (row_id_index != undefined) { - $.each($(this.dataTable.fnGetNodes()), function() { + $.each($(that.dataTable.fnGetNodes()), function() { if ($('td.markrow', this).length != 0) { var aData = that.dataTable.fnGetData(this); @@ -403,7 +403,7 @@ define(function(require) { }); } - $.each($(this.dataTable.fnGetNodes()), function() { + $.each($(that.dataTable.fnGetNodes()), function() { if ($('td.markrowchecked', this).length != 0) { if (!isNaN($($('td', $(this))[1]).html())) { checked_row_ids.push($($('td', $(this))[1]).html()); @@ -416,11 +416,11 @@ define(function(require) { // dataTable.fnSettings is undefined when the table has been detached from // the DOM - if (this.dataTable && this.dataTable.fnSettings()) { - var dTable_settings = this.dataTable.fnSettings(); + if (that.dataTable && that.dataTable.fnSettings()) { + var dTable_settings = that.dataTable.fnSettings(); var prev_start = dTable_settings._iDisplayStart; - this.dataTable.fnClearTable(false); + that.dataTable.fnClearTable(false); var item_list; if (fromArray) { @@ -435,7 +435,6 @@ define(function(require) { }); } - var that = this; if (item_list.length > 0) { that.dataTable.fnAddData(item_list, false); } @@ -451,11 +450,11 @@ define(function(require) { dTable_settings.iInitDisplayStart = new_start; - this.dataTable.fnDraw(true); + that.dataTable.fnDraw(true); }; if (selected_row_id != undefined) { - $.each($(this.dataTable.fnGetNodes()), function() { + $.each($(that.dataTable.fnGetNodes()), function() { var aData = that.dataTable.fnGetData(this); @@ -466,7 +465,7 @@ define(function(require) { } if (checked_row_ids.length != 0) { - $.each($(this.dataTable.fnGetNodes()), function() { + $.each($(that.dataTable.fnGetNodes()), function() { var current_id = $($('td', this)[1]).html(); if (isNaN(current_id)) {