1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-16 09:57:23 +03:00

B #~: select network in vm update (#325)

Signed-off-by: Jorge Lobo <jlobo@opennebula.io>

Co-authored-by: Jorge Lobo <jlobo@opennebula.systems>
This commit is contained in:
Jorge Miguel Lobo Escalona 2020-10-16 14:22:52 +02:00 committed by GitHub
parent a730b9c22c
commit 7e96cea83f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,21 +19,21 @@ define(function(require) {
DEPENDENCIES
*/
var OpennebulaVM = require('opennebula/vm');
var BaseDialog = require('utils/dialogs/dialog');
var TemplateHTML = require('hbs!./attach-nic/html');
var Sunstone = require('sunstone');
var Notifier = require('utils/notifier');
var Tips = require('utils/tips');
var NicTab = require('tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab');
var WizardFields = require('utils/wizard-fields');
var OpennebulaVM = require("opennebula/vm");
var BaseDialog = require("utils/dialogs/dialog");
var TemplateHTML = require("hbs!./attach-nic/html");
var Sunstone = require("sunstone");
var Notifier = require("utils/notifier");
var Tips = require("utils/tips");
var NicTab = require("tabs/templates-tab/form-panels/create/wizard-tabs/network/nic-tab");
var WizardFields = require("utils/wizard-fields");
/*
CONSTANTS
*/
var DIALOG_ID = require('./attach-nic/dialogId');
var TAB_ID = require('../tabId')
var DIALOG_ID = require("./attach-nic/dialogId");
var TAB_ID = require("../tabId");
/*
CONSTRUCTOR
@ -42,7 +42,7 @@ define(function(require) {
function Dialog() {
this.dialogId = DIALOG_ID;
this.nicTab = new NicTab(DIALOG_ID + 'NickTab');
this.nicTab = new NicTab(DIALOG_ID + "NickTab");
BaseDialog.call(this);
};
@ -64,8 +64,8 @@ define(function(require) {
function _html() {
return TemplateHTML({
'dialogId': this.dialogId,
'nicTabHTML': this.nicTab.html()
"dialogId": this.dialogId,
"nicTabHTML": this.nicTab.html()
});
}
@ -84,8 +84,9 @@ define(function(require) {
$("#parent", context).toggle(this.checked);
});
$('#' + DIALOG_ID + 'Form', context).submit(function() {
$("#" + DIALOG_ID + "Form", context).submit(function() {
var templateJSON = that.nicTab.retrieve(context);
var selectedNetwork = Object.keys(templateJSON).length > 0 && templateJSON.constructor === Object;
if($("#cb_attach_rdp", context).prop("checked")) {
templateJSON.RDP = "YES";
@ -96,17 +97,21 @@ define(function(require) {
var obj = {
"NIC_ALIAS": templateJSON
}
};
} else {
var obj = {
"NIC": templateJSON
}
};
}
Sunstone.runAction('VM.attachnic', that.element.ID, obj);
if(selectedNetwork){
Sunstone.runAction("VM.attachnic", that.element.ID, obj);
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
}else{
Notifier.notifyError("Select a network");
}
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
return false;
});
@ -117,9 +122,9 @@ define(function(require) {
this.setNames( {tabId: TAB_ID} );
this.nicTab.onShow(context);
$('#cb_attach_alias').prop('checked', false).change();
var showRdp = false, template = this.element.TEMPLATE
$("#cb_attach_alias").prop("checked", false).change();
var showRdp = false, template = this.element.TEMPLATE;
if (template.NIC) {
showRdp = OpennebulaVM.hasConnection(template.NIC, "rdp");
@ -133,7 +138,7 @@ define(function(require) {
}
function _setElement(element) {
this.element = element
this.element = element;
}
function _setNicsNames(nicsNames) {