From 79f28474e57de7848719d3cad846a4a9536b4fd9 Mon Sep 17 00:00:00 2001 From: Jorge Lobo <47326048+jloboescalona2@users.noreply.github.com> Date: Tue, 18 Jun 2019 12:25:08 +0200 Subject: [PATCH] B #3335: Add select default zone endpoint (#3437) * B #3335: add select change default zone endpoint Signed-off-by: Jorge Lobo * Update info-common.js (cherry picked from commit 22ae31375bdd98e68c017abbd27ffdb05382d579) --- .../app/tabs/users-tab/panels/info-common.js | 33 +++++++++++++++++++ .../app/tabs/users-tab/panels/info/html.hbs | 9 +++++ .../public/app/tabs/vms-tab/hooks/state.js | 2 +- .../tabs/vms-tab/utils/datatable-common.js | 2 +- .../public/app/utils/common-actions.js | 8 +++-- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/sunstone/public/app/tabs/users-tab/panels/info-common.js b/src/sunstone/public/app/tabs/users-tab/panels/info-common.js index d7a0f18460..90042ad343 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info-common.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/info-common.js @@ -26,6 +26,8 @@ define(function(require) { var OpenNebulaUser = require("opennebula/user"); var Sunstone = require("sunstone"); var UserCreation = require("tabs/users-tab/utils/user-creation"); + var OpenNebula = require('opennebula'); + var Notifier = require('utils/notifier'); /* TEMPLATES @@ -173,6 +175,37 @@ define(function(require) { } }); + // Change default zone + var default_zone_input = "default_zone_input"; + context.off("click", "#div_edit_zone"); + context.on("click", "#div_edit_zone", function() { + var options = ""; + OpenNebula.Zone.list({ + timeout: true, + success: function (request, obj_list) { + $.each(obj_list, function() { + if(this && this.ZONE && this.ZONE.TEMPLATE && this.ZONE.TEMPLATE.ENDPOINT && this.ZONE.NAME){ + options += ""; + } + }); + $(".value_td_zone", context).html(""); + + if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.DEFAULT_ZONE_ENDPOINT) { + $("#"+default_zone_input, context).val(that.element.TEMPLATE.SUNSTONE.DEFAULT_ZONE_ENDPOINT) + } + }, + error: Notifier.onError + }); + }); + + context.off("change", "#"+default_zone_input); + context.on("change", "#"+default_zone_input, function() { + var sunstone_setting = {DEFAULT_ZONE_ENDPOINT : $(this).val()}; + Sunstone.runAction("User.append_sunstone_setting", that.element.ID, sunstone_setting); + }); + return false; } }); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs index e38c393546..90f7e90092 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs @@ -60,6 +60,15 @@ + + {{tr "Default Zone Endpoint"}} + {{valOrDefault sunstone_template.DEFAULT_ZONE_ENDPOINT "-"}} + +
+ +
+ + diff --git a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js index bc60b8ea0c..be991cc502 100644 --- a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js +++ b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js @@ -72,4 +72,4 @@ define(function(require) { 'pre': _pre, 'post': _post }; -}); +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js index 5f28b3ff6e..d530ada5a5 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js @@ -170,4 +170,4 @@ define(function(require) { "" ]; } -}); +}); \ No newline at end of file diff --git a/src/sunstone/public/app/utils/common-actions.js b/src/sunstone/public/app/utils/common-actions.js index 98d1a4f81f..bd6f0e7d18 100644 --- a/src/sunstone/public/app/utils/common-actions.js +++ b/src/sunstone/public/app/utils/common-actions.js @@ -70,9 +70,11 @@ define(function(require) { type: "single", call: that.openNebulaResource.show, callback: function(request, response) { - Sunstone.getDataTable(that.tabId).updateElement(request, response); - if (Sunstone.rightInfoVisible($('#' + that.tabId))) { - Sunstone.insertPanels(that.tabId, response); + if(that && that.tabId && Sunstone && Sunstone.getDataTable && Sunstone.getDataTable(that.tabId)){ + Sunstone.getDataTable(that.tabId).updateElement(request, response); + if (Sunstone.rightInfoVisible($('#' + that.tabId))) { + Sunstone.insertPanels(that.tabId, response); + } } }, error: Notifier.onError