From fd64d27fa0b3e0821b3f0f3eb8bc8dc74b88818c Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 17 Feb 2016 17:14:23 +0100 Subject: [PATCH 1/7] Bug #4332: Show datatable when clicking in a label from a detailed view --- .../app/tabs/provision-tab/templates/list.js | 7 +++- src/sunstone/public/app/utils/labels/utils.js | 41 ++++++++++++++----- .../public/app/utils/tab-datatable.js | 4 +- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/sunstone/public/app/tabs/provision-tab/templates/list.js b/src/sunstone/public/app/tabs/provision-tab/templates/list.js index 9d6b65e535..19d501dee0 100644 --- a/src/sunstone/public/app/tabs/provision-tab/templates/list.js +++ b/src/sunstone/public/app/tabs/provision-tab/templates/list.js @@ -94,7 +94,12 @@ define(function(require) { datatable.fnAddData(item_list); LabelsUtils.clearLabelsFilter(datatable, TEMPLATE_LABELS_COLUMN); var context = $('.labels-dropdown', datatable.closest('.content')); - LabelsUtils.insertLabelsMenu(context, datatable, TEMPLATE_LABELS_COLUMN, "VMTEMPLATE.TEMPLATE.LABELS"); + LabelsUtils.insertLabelsMenu({ + 'context': context, + 'dataTable': datatable, + 'labelsColumn': TEMPLATE_LABELS_COLUMN, + 'labelsPath': 'VMTEMPLATE.TEMPLATE.LABELS' + }); } }, error: Notifier.onError diff --git a/src/sunstone/public/app/utils/labels/utils.js b/src/sunstone/public/app/utils/labels/utils.js index 35e863610b..4f56dc9b04 100644 --- a/src/sunstone/public/app/utils/labels/utils.js +++ b/src/sunstone/public/app/utils/labels/utils.js @@ -39,10 +39,26 @@ define(function(require) { /* FUNCTION DEFINITIONS */ - /* - Add labels tree to the left menu + /** + * Add labels tree to the left menu + * @param {Object} opts - Options + * @param {string} opts.tabName - Tab Name to retrieve the rest of the opts + * @param {jQuery Object} [opts.context] - jQuery object to insert the menu, if not + * provided the link of the tab in the left menu will be used + * @param {DataTable} [opts.dataTable] - Datatable to apply the filter, if not + * provided the one defined in the Sunstone tab will be used + * @param {Number} [opts.labelsColumn] - Column of the labels in the datatable, + * if not provided the one defined in the Sunstone tab datatable + * will be used + * @param {string} [opts.labelsPath] - Path of the labels attr, this value will be + * used if the datatable uses aData object instead of an array with the values */ - function _insertLabelsMenu(context, dataTable, labelsColumn, labelsPath) { + function _insertLabelsMenu(opts) { + var context = opts.context || $('#li_' + opts.tabName); + var dataTable = opts.dataTable || Sunstone.getDataTable(opts.tabName).dataTable; + var labelsColumn = opts.labelsColumn || Sunstone.getDataTable(opts.tabName).labelsColumn; + var labelsPath = opts.labelsPath; + var labels = _getLabels(dataTable, labelsColumn, labelsPath); $('.labels-tree', context).remove(); context.append(Tree.html(_makeTree(labels), true)); @@ -53,6 +69,10 @@ define(function(require) { */ context.off('click', '.one-label'); context.on('click', '.one-label', function() { + if (opts.tabName) { + Sunstone.showTab(opts.tabName); + } + var regExp = []; var label = $(this).attr('one-label-full-name'); regExp.push('^' + label + '$'); @@ -94,7 +114,7 @@ define(function(require) { var selectedItems = tabTable.elements(); $.each(selectedItems, function(index, resourceId) { - labelsStr = _getLabel(dataTable, labelsColumn, resourceId); + labelsStr = _getLabel(tabName, dataTable, labelsColumn, resourceId); if (labelsStr != '') { $.each(labelsStr.split(','), function(){ if (labelsIndexed[this]) { @@ -159,7 +179,7 @@ define(function(require) { var labelsArray, labelIndex; var selectedItems = tabTable.elements(); $.each(selectedItems, function(index, resourceId) { - labelsStr = _getLabel(dataTable, labelsColumn, resourceId); + labelsStr = _getLabel(tabName, dataTable, labelsColumn, resourceId); if (labelsStr != '') { labelsArray = labelsStr.split(',') } else { @@ -190,7 +210,7 @@ define(function(require) { var labelsArray, labelIndex; var selectedItems = tabTable.elements(); $.each(selectedItems, function(index, resourceId) { - labelsStr = _getLabel(dataTable, labelsColumn, resourceId); + labelsStr = _getLabel(tabName, dataTable, labelsColumn, resourceId); if (labelsStr != '') { labelsArray = labelsStr.split(',') } else { @@ -233,7 +253,7 @@ define(function(require) { } - _insertLabelsMenu($('#li_' + tabName), tabTable.dataTable, tabTable.labelsColumn); + _insertLabelsMenu({'tabName': tabName}); _insertLabelsDropdown(tabName); }, error: Notifier.onError @@ -333,10 +353,9 @@ define(function(require) { return _deserializeLabels(labels.join(',')); } - function _getLabel(dataTable, labelsColumn, resourceId) { - var tab = dataTable.parents(".tab") - if (Sunstone.rightInfoVisible(tab)) { - var element = Sunstone.getElementRightInfo(tab.attr('id')); + function _getLabel(tabName, dataTable, labelsColumn, resourceId) { + if (Sunstone.rightInfoVisible($('#' + tabName))) { + var element = Sunstone.getElementRightInfo(tabName); if (element && element.TEMPLATE) { return element.TEMPLATE[LABELS_ATTR]||''; } else { diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index af39be65d9..8da8d2a864 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -485,9 +485,7 @@ define(function(require) { } if (that.labelsColumn) { - var dataTable = that.dataTable; - var labelsColumn = that.labelsColumn; - LabelsUtils.insertLabelsMenu($('#li_' + that.tabId), dataTable, labelsColumn); + LabelsUtils.insertLabelsMenu({'tabName': that.tabId}); LabelsUtils.insertLabelsDropdown(that.tabId); } From 449313f893415d6b2dff7afd458ef26d448ecf92 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 17 Feb 2016 17:32:58 +0100 Subject: [PATCH 2/7] Feature #4336: Show a placeholder when no labels are defined --- .../app/tabs/provision-tab/templates/list.js | 3 ++- src/sunstone/public/app/utils/labels/utils.js | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/sunstone/public/app/tabs/provision-tab/templates/list.js b/src/sunstone/public/app/tabs/provision-tab/templates/list.js index 19d501dee0..d000d4945f 100644 --- a/src/sunstone/public/app/tabs/provision-tab/templates/list.js +++ b/src/sunstone/public/app/tabs/provision-tab/templates/list.js @@ -98,7 +98,8 @@ define(function(require) { 'context': context, 'dataTable': datatable, 'labelsColumn': TEMPLATE_LABELS_COLUMN, - 'labelsPath': 'VMTEMPLATE.TEMPLATE.LABELS' + 'labelsPath': 'VMTEMPLATE.TEMPLATE.LABELS', + 'placeholder': Locale.tr("No labels defined") }); } }, diff --git a/src/sunstone/public/app/utils/labels/utils.js b/src/sunstone/public/app/utils/labels/utils.js index 4f56dc9b04..c5f57bd2d7 100644 --- a/src/sunstone/public/app/utils/labels/utils.js +++ b/src/sunstone/public/app/utils/labels/utils.js @@ -51,7 +51,9 @@ define(function(require) { * if not provided the one defined in the Sunstone tab datatable * will be used * @param {string} [opts.labelsPath] - Path of the labels attr, this value will be - * used if the datatable uses aData object instead of an array with the values + * used if the datatable uses aData object instead of an array w + * ith the values + * @param {string} [opts.placeholder] - Message to be shown in no labels are defined */ function _insertLabelsMenu(opts) { var context = opts.context || $('#li_' + opts.tabName); @@ -61,15 +63,21 @@ define(function(require) { var labels = _getLabels(dataTable, labelsColumn, labelsPath); $('.labels-tree', context).remove(); - context.append(Tree.html(_makeTree(labels), true)); - Tree.setup($('.labels-tree', context)); + if ($.isEmptyObject(labels)) { + if (opts.placeholder) { + context.append('
' + opts.placeholder + '
'); + } + } else { + context.append(Tree.html(_makeTree(labels), true)); + Tree.setup($('.labels-tree', context)); + } /* Filter datatable when a label in the left menu is clicked */ context.off('click', '.one-label'); context.on('click', '.one-label', function() { - if (opts.tabName) { + if (opts.tabName && !Sunstone.rightListVisible($('#' + opts.tabName))) { Sunstone.showTab(opts.tabName); } From a3dbf0ab56e8e15d80df447de22fa1f22fde6ae3 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 17 Feb 2016 17:44:58 +0100 Subject: [PATCH 3/7] Bug #4301: After updating an element in the datatable update the checkbox input --- src/sunstone/public/app/utils/tab-datatable.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index 8da8d2a864..dfaadc5164 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -502,8 +502,13 @@ define(function(require) { $.each(that.dataTable.fnGetData(), function(index, aData) { if (aData[that.selectOptions.id_index] === elementId) { - element[0] = aData[0]; + var nodes = that.dataTable.fnGetNodes(); + var checkId = '#' + that.resource.toLowerCase() + '_' + elementId; + var checkVal = $(checkId, nodes).prop('checked'); that.dataTable.fnUpdate(element, index, undefined, false); + if (checkVal) { + $(checkId, nodes).prop('checked', checkVal); + } that.recountCheckboxes(); return false; } From 69fa02b796364ebecb614ef608d28517009ff4ac Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 18 Feb 2016 12:33:43 +0100 Subject: [PATCH 4/7] Bug #4339: Set appliance ID for export form on show --- .../public/app/tabs/marketplaceapps-tab/actions.js | 14 +++++++++++++- .../tabs/marketplaceapps-tab/form-panels/export.js | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js index 4793e9a167..530c033d1f 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js @@ -36,7 +36,19 @@ define(function(require) { "MarketPlaceApp.export_dialog" : { type: "custom", call: function() { - Sunstone.showFormPanel(TAB_ID, EXPORT_DIALOG_ID, "export"); + var selected_nodes = Sunstone.getDataTable(TAB_ID).elements(); + if (selected_nodes.length != 1) { + Notifier.notifyMessage("Please select one (and just one) app to export."); + return false; + } + + var resourceId = "" + selected_nodes[0]; + + Sunstone.resetFormPanel(TAB_ID, EXPORT_DIALOG_ID); + Sunstone.showFormPanel(TAB_ID, EXPORT_DIALOG_ID, "export", + function(formPanelInstance, context) { + formPanelInstance.setResourceId(context, resourceId); + }); } }, "MarketPlaceApp.export" : { diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js index 875b01da34..05e72367af 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js @@ -73,6 +73,7 @@ define(function(require) { FormPanel.prototype.constructor = FormPanel; FormPanel.prototype.htmlWizard = _htmlWizard; FormPanel.prototype.submitWizard = _submitWizard; + FormPanel.prototype.setResourceId = _setResourceId; FormPanel.prototype.onShow = _onShow; FormPanel.prototype.setup = _setup; @@ -105,6 +106,9 @@ define(function(require) { this.datastoresTable.idInput().attr('required', ''); } + function _setResourceId(context, resourceId) { + this.resourceId = resourceId; + } function _submitWizard(context) { var marketPlaceAppObj = { @@ -112,7 +116,7 @@ define(function(require) { "dsid" : this.datastoresTable.idInput().val() }; - Sunstone.runAction("MarketPlaceApp.export", Sunstone.getDataTable(TAB_ID).elements(), marketPlaceAppObj); + Sunstone.runAction("MarketPlaceApp.export", [this.resourceId], marketPlaceAppObj); return false; } }); From dc761a90496246b0921205e08b3da69d330a1a67 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 18 Feb 2016 16:07:15 +0100 Subject: [PATCH 5/7] Bug #4340: Get rid of the SCHED_ keys in the info panel --- .../public/app/tabs/vms-tab/panels/info.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/info.js b/src/sunstone/public/app/tabs/vms-tab/panels/info.js index f8d893b2bb..785db6f686 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/vms-tab/panels/info.js @@ -77,7 +77,20 @@ define(function(require) { var deployId = (typeof(this.element.DEPLOY_ID) == "object" ? "--" : this.element.DEPLOY_ID); var resched = (parseInt(this.element.RESCHED) ? Locale.tr("yes") : Locale.tr("no")) - var templateTableHTML = TemplateTable.html(this.element.USER_TEMPLATE, RESOURCE, Locale.tr("Attributes")); + + // Get rid of the unwanted (for show) SCHED_* keys + var that = this; + var strippedTemplate = {}; + var unshownValues = {}; + $.each(that.element.USER_TEMPLATE, function(key, value) { + if (!key.match(/^SCHED_*/)) { + strippedTemplate[key] = value; + } else { + unshownValues[key] = value; + } + }) + + var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE, Locale.tr("Attributes"), unshownValues); var monitoring = $.extend({}, this.element.MONITORING); delete monitoring.CPU; From 1f0b9dbdbe19c22f04d7dcf513ad8bb44b794ec3 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 18 Feb 2016 16:41:17 +0100 Subject: [PATCH 6/7] Bug #4319: Missing translation for VM --hard actions --- src/sunstone/public/app/tabs/vms-tab/buttons.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sunstone/public/app/tabs/vms-tab/buttons.js b/src/sunstone/public/app/tabs/vms-tab/buttons.js index 0eec3bae20..06d61e7179 100644 --- a/src/sunstone/public/app/tabs/vms-tab/buttons.js +++ b/src/sunstone/public/app/tabs/vms-tab/buttons.js @@ -58,7 +58,7 @@ define(function(require) { }, "VM.migrate_live" : { type: "action", - text: Locale.tr("Migrate") + ' live', + text: Locale.tr("Migrate") + ' ' + Locale.tr("live") + '', tip: Locale.tr("This will live-migrate the selected VMs to the chosen host"), layout: "vmsplanification_buttons", custom_classes : "state-dependent" @@ -107,7 +107,7 @@ define(function(require) { }, "VM.reboot_hard" : { type: "action", - text: Locale.tr("Reboot") + ' hard', + text: Locale.tr("Reboot") + ' ' + Locale.tr("hard") + '', layout: "vmsrepeat_buttons", tip: Locale.tr("This will perform a hard reboot on selected VMs"), custom_classes : "state-dependent" @@ -121,7 +121,7 @@ define(function(require) { }, "VM.poweroff_hard" : { type: "action", - text: Locale.tr("Power Off") + ' hard', + text: Locale.tr("Power Off") + ' ' + Locale.tr("hard") + '', layout: "vmspause_buttons", tip: Locale.tr("This will send a forced power off signal to running VMs. They can be resumed later."), custom_classes : "state-dependent" @@ -135,7 +135,7 @@ define(function(require) { }, "VM.undeploy_hard" : { type: "action", - text: Locale.tr("Undeploy") + ' hard', + text: Locale.tr("Undeploy") + ' ' + Locale.tr("hard") + '', layout: "vmsstop_buttons", tip: Locale.tr("Shuts down the given VM. The VM is saved in the system Datastore."), custom_classes : "state-dependent" @@ -149,7 +149,7 @@ define(function(require) { }, "VM.shutdown_hard" : { type: "confirm", - text: Locale.tr("Shutdown") + ' hard', + text: Locale.tr("Shutdown") + ' ' + Locale.tr("hard") + '', layout: "vmsdelete_buttons", tip: Locale.tr("This will initiate the shutdown-hard (forced) process in the selected VMs"), custom_classes : "state-dependent" @@ -164,7 +164,7 @@ define(function(require) { }, "VM.delete_recreate" : { type: "confirm", - text: Locale.tr("Delete") + ' recreate', + text: Locale.tr("Delete") + ' ' + Locale.tr("recreate") + '', layout: "vmsrepeat_buttons", tip: Locale.tr("This will delete and recreate VMs to PENDING state"), custom_classes : "state-dependent" From cbd2b9875680ba81cb16ef0887d43786c62cbd6a Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 18 Feb 2016 17:00:11 +0100 Subject: [PATCH 7/7] Bug #4323: Add topology placeholder for empty vnets pool --- .../public/app/tabs/vnets-topology-tab.js | 43 +++++++++++-------- .../app/tabs/vnets-topology-tab/html.hbs | 3 +- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/sunstone/public/app/tabs/vnets-topology-tab.js b/src/sunstone/public/app/tabs/vnets-topology-tab.js index b26a5e6dba..ffed3068a1 100644 --- a/src/sunstone/public/app/tabs/vnets-topology-tab.js +++ b/src/sunstone/public/app/tabs/vnets-topology-tab.js @@ -25,6 +25,7 @@ define(function(require) { var Vis = require('vis'); var TemplateDashboard = require('hbs!./vnets-topology-tab/html'); + var TemplateEmptyTable = require('hbs!utils/tab-datatable/empty-table'); var _network; var _vnetList; @@ -120,26 +121,32 @@ define(function(require) { var i = 0; function _getVNet(index){ - var vnetId = item_list[index].VNET.ID; + var element = item_list[index]; + if (element !== undefined) { + var vnetId = element.VNET.ID; - OpenNebula.Network.show({ - data : { - id: vnetId - }, - timeout:true, - success: function(request,info){ - vnetList.push(info); + OpenNebula.Network.show({ + data : { + id: vnetId + }, + timeout:true, + success: function(request,info){ + vnetList.push(info); - i += 1; - if (i == item_list.length){ - _vnetList = vnetList; - _doTopology(); - } else { - _getVNet(i); - } - }, - error: Notifier.onError - }); + i += 1; + if (i == item_list.length){ + _vnetList = vnetList; + _doTopology(); + } else { + _getVNet(i); + } + }, + error: Notifier.onError + }); + } else { + _vnetList = vnetList; + $('#visgraph').html(TemplateEmptyTable()); + } } _getVNet(i); diff --git a/src/sunstone/public/app/tabs/vnets-topology-tab/html.hbs b/src/sunstone/public/app/tabs/vnets-topology-tab/html.hbs index 459145a70f..63e8396c17 100644 --- a/src/sunstone/public/app/tabs/vnets-topology-tab/html.hbs +++ b/src/sunstone/public/app/tabs/vnets-topology-tab/html.hbs @@ -14,4 +14,5 @@ {{! limitations under the License. }} {{! -------------------------------------------------------------------------- }} -
+
+