mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
feature #3748: Add deploy vm dialog
This commit is contained in:
parent
7ab04372fa
commit
ff51aa7f4e
@ -7,10 +7,10 @@ define(function(require) {
|
||||
var TAB_ID = require('./vms-tab/tabId');
|
||||
var DATATABLE_ID = "dataTableVms";
|
||||
|
||||
//var _dialogs = [
|
||||
// require('./vms-tab/dialogs/clone'),
|
||||
var _dialogs = [
|
||||
require('./vms-tab/dialogs/deploy'),
|
||||
// require('./vms-tab/dialogs/instantiate')
|
||||
//];
|
||||
];
|
||||
|
||||
var _panels = [
|
||||
require('./vms-tab/panels/info'),
|
||||
@ -39,7 +39,7 @@ define(function(require) {
|
||||
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
|
||||
panels: _panels,
|
||||
formPanels: _formPanels,
|
||||
//dialogs: _dialogs
|
||||
dialogs: _dialogs
|
||||
};
|
||||
|
||||
return Tab;
|
||||
|
@ -7,7 +7,7 @@ define(function(require) {
|
||||
|
||||
var TAB_ID = require('./tabId');
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
//var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId');
|
||||
var DEPLOY_DIALOG_ID = require('./dialogs/deploy/dialogId');
|
||||
//var INSTANTIATE_DIALOG_ID = require('./dialogs/instantiate/dialogId');
|
||||
var XML_ROOT = "VM";
|
||||
var RESOURCE = "VM";
|
||||
@ -62,6 +62,12 @@ define(function(require) {
|
||||
Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
|
||||
}
|
||||
},
|
||||
"VM.deploy" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
Sunstone.getDialog(DEPLOY_DIALOG_ID).show();
|
||||
}
|
||||
},
|
||||
/*"VM.create" : {
|
||||
type: "custom",
|
||||
call: function(id, name) {
|
||||
|
99
src/sunstone/public/app/tabs/vms-tab/dialogs/deploy.js
Normal file
99
src/sunstone/public/app/tabs/vms-tab/dialogs/deploy.js
Normal file
@ -0,0 +1,99 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseDialog = require('utils/dialogs/dialog');
|
||||
var TemplateHTML = require('hbs!./deploy/html');
|
||||
var Sunstone = require('sunstone');
|
||||
var DatastoresTable = require('tabs/datastores-tab/datatable');
|
||||
var HostsTable = require('tabs/hosts-tab/datatable');
|
||||
var Notifier = require('utils/notifier');
|
||||
var Tips = require('utils/tips');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var DIALOG_ID = require('./deploy/dialogId');
|
||||
var TAB_ID = require('../tabId')
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Dialog() {
|
||||
this.dialogId = DIALOG_ID;
|
||||
|
||||
this.hostsTable = new HostsTable('deploy_vm', {'select': true});
|
||||
this.datastoresTable = new DatastoresTable('deploy_vm_ds', {
|
||||
'select': true,
|
||||
'selectOptions': {
|
||||
'filter_fn': function(ds) { return ds.TYPE == 1; } // Show system DS only
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
return Dialog;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({
|
||||
'dialogId': this.dialogId,
|
||||
'hostsTableHTML': this.hostsTable.dataTableHTML,
|
||||
'datastoresTableHTML': this.datastoresTable.dataTableHTML
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
that.hostsTable.initialize();
|
||||
that.datastoresTable.initialize();
|
||||
|
||||
Tips.setup(context);
|
||||
|
||||
$('#' + DIALOG_ID + 'Form', context).submit(function() {
|
||||
var extra_info = {};
|
||||
|
||||
if ($("#selected_resource_id_deploy_vm", context).val()) {
|
||||
extra_info['host_id'] = $("#selected_resource_id_deploy_vm", context).val();
|
||||
} else {
|
||||
Notifier.notifyError(tr("You have not selected a host"));
|
||||
return false;
|
||||
}
|
||||
|
||||
extra_info['ds_id'] = $("#selected_resource_id_deploy_vm_ds", context).val() || -1
|
||||
extra_info['enforce'] = $("#enforce", this).is(":checked") ? true : false
|
||||
|
||||
$.each(Sunstone.getDataTable(TAB_ID).elements(), function(index, elem) {
|
||||
Sunstone.runAction("VM.deploy_action", elem, extra_info);
|
||||
});
|
||||
|
||||
Sunstone.getDialog(DIALOG_ID).hide();
|
||||
Sunstone.getDialog(DIALOG_ID).reset();
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(dialog) {
|
||||
this.datastoresTable.resetResourceTableSelect();
|
||||
this.hostsTable.resetResourceTableSelect();
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
define(function(require){
|
||||
return 'deployVMDialog';
|
||||
})
|
41
src/sunstone/public/app/tabs/vms-tab/dialogs/deploy/html.hbs
Normal file
41
src/sunstone/public/app/tabs/vms-tab/dialogs/deploy/html.hbs
Normal file
@ -0,0 +1,41 @@
|
||||
<div id="{{dialogId}}" class="reveal-modal large" role="dialog" data-reveal >
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<h3 id="deploy_vm_header" class="subheader">{{tr "Deploy Virtual Machine"}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="reveal-body">
|
||||
<form id="{{dialogId}}Form" action="">
|
||||
<div class="row">
|
||||
<fieldset>
|
||||
<legend>{{tr "Select a Host"}}</legend>
|
||||
{{{hostsTableHTML}}}
|
||||
</fieldset>
|
||||
</div>
|
||||
{{#advancedSection (tr "Advanced Options") }}
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<input type="checkbox" name="enforce" id="enforce"/>
|
||||
<label for="enforce">
|
||||
{{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>
|
||||
<br>
|
||||
<fieldset>
|
||||
<legend>{{tr "Select a datastore"}}</legend>
|
||||
{{{datastoresTableHTML}}}
|
||||
</fieldset>
|
||||
{{/advancedSection}}
|
||||
<div class="form_buttons reveal-footer">
|
||||
<div class="form_buttons">
|
||||
<button class="button radius right success" id="deploy_vm_proceed" value="VM.deploy">{{tr "Deploy"}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<a class="close-reveal-modal">×</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user