mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
feature #3748: Add resize vm dialog
This commit is contained in:
parent
b8441259a2
commit
d9aefcb54e
104
src/sunstone/public/app/tabs/vms-tab/dialogs/resize.js
Normal file
104
src/sunstone/public/app/tabs/vms-tab/dialogs/resize.js
Normal file
@ -0,0 +1,104 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseDialog = require('utils/dialogs/dialog');
|
||||
var TemplateHTML = require('hbs!./resize/html');
|
||||
var Sunstone = require('sunstone');
|
||||
var Notifier = require('utils/notifier');
|
||||
var Tips = require('utils/tips');
|
||||
var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var DIALOG_ID = require('./resize/dialogId');
|
||||
var TAB_ID = require('../tabId')
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Dialog() {
|
||||
this.dialogId = DIALOG_ID;
|
||||
|
||||
BaseDialog.call(this);
|
||||
};
|
||||
|
||||
Dialog.DIALOG_ID = DIALOG_ID;
|
||||
Dialog.prototype = Object.create(BaseDialog.prototype);
|
||||
Dialog.prototype.constructor = Dialog;
|
||||
Dialog.prototype.html = _html;
|
||||
Dialog.prototype.onShow = _onShow;
|
||||
Dialog.prototype.setup = _setup;
|
||||
Dialog.prototype.setElement = _setElement;
|
||||
|
||||
return Dialog;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({
|
||||
'dialogId': this.dialogId,
|
||||
'capacityInputsHTML': CapacityInputs.html()
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
CapacityInputs.setup();
|
||||
|
||||
Tips.setup(context);
|
||||
|
||||
$('#' + DIALOG_ID + 'Form', context).submit(function() {
|
||||
var templateJSON = WizardFields.retrieve(context);
|
||||
|
||||
if (templateJSON["CPU"] == that.element.TEMPLATE.CPU) {
|
||||
delete templateJSON["CPU"];
|
||||
};
|
||||
|
||||
if (templateJSON["MEMORY"] == that.element.TEMPLATE.MEMORY) {
|
||||
delete templateJSON["MEMORY"];
|
||||
};
|
||||
|
||||
if (templateJSON["VCPU"] == that.element.TEMPLATE.VCPU) {
|
||||
delete templateJSON["VCPU"];
|
||||
};
|
||||
|
||||
var enforce = $("#enforce", this).is(":checked");
|
||||
|
||||
var obj = {
|
||||
"vm_template": templateJSON,
|
||||
"enforce": enforce,
|
||||
}
|
||||
|
||||
Sunstone.runAction('VM.resize', that.element.ID, obj);
|
||||
|
||||
Sunstone.getDialog(DIALOG_ID).hide();
|
||||
Sunstone.getDialog(DIALOG_ID).reset();
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
var that = this;
|
||||
$('#vm_id', context).text(that.element.ID);
|
||||
$('#CPU', context).val(that.element.TEMPLATE.CPU);
|
||||
$('#MEMORY_TMP', context).val(that.element.TEMPLATE.MEMORY);
|
||||
if (that.element.VCPU) {
|
||||
$('#VCPU', context).val(that.element.TEMPLATE.VCPU);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function _setElement(element) {
|
||||
this.element = element
|
||||
}
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
define(function(require) {
|
||||
return 'resizeVMDialog';
|
||||
})
|
33
src/sunstone/public/app/tabs/vms-tab/dialogs/resize/html.hbs
Normal file
33
src/sunstone/public/app/tabs/vms-tab/dialogs/resize/html.hbs
Normal file
@ -0,0 +1,33 @@
|
||||
<div id="{{dialogId}}" class="reveal-modal large" role="dialog" data-reveal >
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<h3 class="subheader" id="">{{tr "Resize VM capacity"}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="reveal-body">
|
||||
<form id="{{dialogId}}Form" action="">
|
||||
<div class="row centered">
|
||||
<div class="large-6 columns">
|
||||
<label for="vm_id">{{tr "Virtual Machine ID"}}:</label>
|
||||
<label style="border-style: inset; background-color: lightgrey" type="text" name="vm_id" id="vm_id" disabled/>
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<input type="checkbox" name="enforce" id="enforce"/>
|
||||
<label class="inline" for="vm_id">
|
||||
{{tr "Enforce"}}
|
||||
<span class="tip">
|
||||
{{tr "If it is set to true, the host capacity will be checked. This will only affect oneadmin requests, regular users resize requests will always be enforced"}}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{{{capacityInputsHTML}}}
|
||||
<div class="reveal-footer">
|
||||
<div class="form_buttons">
|
||||
<button class="button radius right success" id="resize_capacity_button" type="submit" value="VM.resize">{{tr "Resize"}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<a class="close-reveal-modal">×</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user