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; } }); 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 f890cd796a..3a67cb32f8 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,13 @@ 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', + 'placeholder': Locale.tr("No labels defined") + }); } }, error: Notifier.onError 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" 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; 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. }} {{! -------------------------------------------------------------------------- }} -
+
+
diff --git a/src/sunstone/public/app/utils/labels/utils.js b/src/sunstone/public/app/utils/labels/utils.js index 35e863610b..c5f57bd2d7 100644 --- a/src/sunstone/public/app/utils/labels/utils.js +++ b/src/sunstone/public/app/utils/labels/utils.js @@ -39,20 +39,48 @@ 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 w + * ith the values + * @param {string} [opts.placeholder] - Message to be shown in no labels are defined */ - 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)); - 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 && !Sunstone.rightListVisible($('#' + opts.tabName))) { + Sunstone.showTab(opts.tabName); + } + var regExp = []; var label = $(this).attr('one-label-full-name'); regExp.push('^' + label + '$'); @@ -94,7 +122,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 +187,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 +218,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 +261,7 @@ define(function(require) { } - _insertLabelsMenu($('#li_' + tabName), tabTable.dataTable, tabTable.labelsColumn); + _insertLabelsMenu({'tabName': tabName}); _insertLabelsDropdown(tabName); }, error: Notifier.onError @@ -333,10 +361,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 4d2aea0ee3..0727b7fb25 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); } @@ -504,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; }