mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 11:52:37 +09:00
Feature #3748: VDC create wizard
This commit is contained in:
1 parent
09be9b3fe6
commit
a31e723efe
6 files changed
+349
-123
No files matched your search
@@ -16,6 +16,10 @@ define(function(require) {
|
||||
require('./vdcs-tab/panels/resources')
|
||||
];
|
||||
|
||||
var _formPanels = [
|
||||
require('./vdcs-tab/form-panels/create')
|
||||
];
|
||||
|
||||
var Tab = {
|
||||
tabId: TAB_ID,
|
||||
title: Locale.tr("VDCs"),
|
||||
@@ -31,6 +35,7 @@ define(function(require) {
|
||||
actions: Actions,
|
||||
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
|
||||
panels: _panels,
|
||||
formPanels: _formPanels,
|
||||
dialogs: _dialogs
|
||||
};
|
||||
|
||||
|
||||
@@ -7,61 +7,69 @@ define(function(require) {
|
||||
|
||||
var RESOURCE = "Vdc";
|
||||
var TAB_ID = require('./tabId');
|
||||
// TODO
|
||||
//var CREATE_DIALOG_ID = require('./dialogs/create/dialogId');
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
|
||||
var _actions = {
|
||||
|
||||
/* TODO
|
||||
"Vdc.create" : {
|
||||
type: "create",
|
||||
call: OpenNebulaResource.create,
|
||||
callback: function(request, response) {
|
||||
$("a[href=back]", $("#vdcs-tab")).trigger("click");
|
||||
popFormDialog("create_vdc_form", $("#vdcs-tab"));
|
||||
Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
|
||||
Sunstone.hideFormPanel(TAB_ID);
|
||||
|
||||
var group_ids = request.request.data[0].group_ids;
|
||||
$.each(group_ids,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_group",
|
||||
response.VDC.ID,
|
||||
{ group_id : parseInt(this)});
|
||||
});
|
||||
if(group_ids !=undefined){
|
||||
$.each(group_ids,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_group",
|
||||
response.VDC.ID,
|
||||
{ group_id : parseInt(this)});
|
||||
});
|
||||
}
|
||||
|
||||
var clusters = request.request.data[0].clusters;
|
||||
$.each(clusters,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_cluster",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
if(clusters !=undefined){
|
||||
$.each(clusters,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_cluster",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
}
|
||||
|
||||
var hosts = request.request.data[0].hosts;
|
||||
$.each(hosts,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_host",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
if(hosts !=undefined){
|
||||
$.each(hosts,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_host",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
}
|
||||
|
||||
var vnets = request.request.data[0].vnets;
|
||||
$.each(vnets,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_vnet",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
if(vnets !=undefined){
|
||||
$.each(vnets,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_vnet",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
}
|
||||
|
||||
var datastores = request.request.data[0].datastores;
|
||||
$.each(datastores,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_datastore",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
if(datastores !=undefined){
|
||||
$.each(datastores,function(){
|
||||
Sunstone.runAction(RESOURCE+".add_datastore",
|
||||
response.VDC.ID,
|
||||
this);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: this vdc.show may get the information before the add/del
|
||||
// actions end, showing "outdated" information
|
||||
|
||||
Sunstone.runAction(RESOURCE+'.show',request.request.data[0][0]);
|
||||
|
||||
addVdcElement(request, response);
|
||||
notifyCustom(tr("VDC created"), " ID: " + response.VDC.ID, false);
|
||||
Sunstone.getDataTable(TAB_ID).addElement(request, response);
|
||||
Notifier.notifyCustom(Locale.tr("VDC created"), " ID: " + response.VDC.ID, false);
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
@@ -69,37 +77,10 @@ define(function(require) {
|
||||
"Vdc.create_dialog" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
Sunstone.popUpFormPanel("create_vdc_form", "vdcs-tab", "create", true, function(context){
|
||||
refreshGroupTableSelect(context, "vdc_wizard_groups");
|
||||
|
||||
var zone_ids = [];
|
||||
|
||||
OpenNebula.Zone.list({
|
||||
timeout: true,
|
||||
success: function (request, obj_list){
|
||||
$.each(obj_list,function(){
|
||||
zone_ids.push(this.ZONE.ID);
|
||||
|
||||
addVdcResourceTab(
|
||||
"vdc_create_wizard",
|
||||
this.ZONE.ID,
|
||||
this.ZONE.NAME,
|
||||
$("#vdcCreateResourcesTab",context));
|
||||
});
|
||||
|
||||
setupVdcResourceTab("vdc_create_wizard",
|
||||
$("#vdcCreateResourcesTab",context));
|
||||
|
||||
context.data("zone_ids", zone_ids);
|
||||
},
|
||||
error: Notifier.onError
|
||||
});
|
||||
|
||||
$("input#name",context).focus();
|
||||
});
|
||||
Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
|
||||
}
|
||||
},
|
||||
*/
|
||||
|
||||
"Vdc.list" : {
|
||||
type: "list",
|
||||
call: OpenNebulaResource.list,
|
||||
@@ -209,97 +190,96 @@ define(function(require) {
|
||||
},
|
||||
error: Notifier.onError
|
||||
},
|
||||
/* TODO
|
||||
|
||||
"Vdc.add_group" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_group,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_group,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.del_group" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_group,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_group,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.add_cluster" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_cluster,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_cluster,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.del_cluster" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_cluster,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_cluster,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.add_host" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_host,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_host,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.del_host" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_host,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_host,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.add_vnet" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_vnet,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_vnet,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.del_vnet" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_vnet,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_vnet,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.add_datastore" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_datastore,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.add_datastore,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
},
|
||||
|
||||
"Vdc.del_datastore" : {
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_datastore,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
type: "single",
|
||||
call : OpenNebulaResource.del_datastore,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction(RESOURCE+'.show',req.request.data[0][0]);
|
||||
},
|
||||
error : Notifier.onError
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
return _actions;
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
require('foundation.tab');
|
||||
var BaseFormPanel = require('utils/form-panels/form-panel');
|
||||
var Sunstone = require('sunstone');
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var CustomTagsTable = require('utils/custom-tags-table');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
var GroupsTable = require('tabs/clusters-tab/datatable');
|
||||
var OpenNebulaZone = require('opennebula/zone');
|
||||
var Utils = require('../utils/common');
|
||||
var Notifier = require('utils/notifier');
|
||||
var ResourcesTab = require('../utils/resources-tab');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
*/
|
||||
|
||||
var TemplateWizardHTML = require('hbs!./create/wizard');
|
||||
var TemplateAdvancedHTML = require('hbs!./create/advanced');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var FORM_PANEL_ID = require('./create/formPanelId');
|
||||
var TAB_ID = require('../tabId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function FormPanel() {
|
||||
this.formPanelId = FORM_PANEL_ID;
|
||||
this.tabId = TAB_ID;
|
||||
this.actions = {
|
||||
'create': {
|
||||
'title': Locale.tr("Create Virtual Data Center"),
|
||||
'buttonText': Locale.tr("Create"),
|
||||
'resetButton': true
|
||||
},
|
||||
'update': {
|
||||
'title': Locale.tr("Update Virtual Data Center"),
|
||||
'buttonText': Locale.tr("Update"),
|
||||
'resetButton': false
|
||||
}
|
||||
};
|
||||
|
||||
BaseFormPanel.call(this);
|
||||
}
|
||||
|
||||
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
|
||||
FormPanel.prototype = Object.create(BaseFormPanel.prototype);
|
||||
FormPanel.prototype.constructor = FormPanel;
|
||||
FormPanel.prototype.htmlWizard = _htmlWizard;
|
||||
FormPanel.prototype.htmlAdvanced = _htmlAdvanced;
|
||||
FormPanel.prototype.submitWizard = _submitWizard;
|
||||
FormPanel.prototype.submitAdvanced = _submitAdvanced;
|
||||
FormPanel.prototype.onShow = _onShow;
|
||||
FormPanel.prototype.fill = _fill;
|
||||
FormPanel.prototype.setup = _setup;
|
||||
|
||||
return FormPanel;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _htmlWizard() {
|
||||
var opts = {
|
||||
info: false,
|
||||
select: true,
|
||||
selectOptions: {"multiple_choice": true}
|
||||
};
|
||||
|
||||
this.groupsTable = new GroupsTable("vdc_wizard_groups", opts);
|
||||
|
||||
this.resourcesTab = new ResourcesTab("vdc_create_wizard");
|
||||
|
||||
return TemplateWizardHTML({
|
||||
'formPanelId': this.formPanelId,
|
||||
'customTagsHTML': CustomTagsTable.html(),
|
||||
'groupsTableHTML': this.groupsTable.dataTableHTML,
|
||||
'resourcesTabHTML': this.resourcesTab.html()
|
||||
});
|
||||
}
|
||||
|
||||
function _htmlAdvanced() {
|
||||
return TemplateAdvancedHTML({formPanelId: this.formPanelId});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
CustomTagsTable.setup($("#vdcCreateGeneralTab", context));
|
||||
this.groupsTable.initialize();
|
||||
|
||||
var zone_ids = [];
|
||||
|
||||
OpenNebulaZone.list({
|
||||
timeout: true,
|
||||
success: function (request, obj_list){
|
||||
var zoneSection = $("#vdcCreateResourcesTab",context);
|
||||
|
||||
$.each(obj_list,function(){
|
||||
zone_ids.push(this.ZONE.ID);
|
||||
|
||||
that.resourcesTab.addResourcesZone(
|
||||
this.ZONE.ID,
|
||||
this.ZONE.NAME,
|
||||
zoneSection);
|
||||
});
|
||||
|
||||
that.resourcesTab.setup(zoneSection);
|
||||
|
||||
that.zone_ids = zone_ids;
|
||||
},
|
||||
error: Notifier.onError
|
||||
});
|
||||
|
||||
context.foundation();
|
||||
Tips.setup();
|
||||
}
|
||||
|
||||
function _submitWizard(context) {
|
||||
|
||||
//Fetch values
|
||||
var vdc_json = {};
|
||||
|
||||
$.extend(vdc_json, WizardFields.retrieve($("#vdcCreateGeneralTab", context)));
|
||||
|
||||
$.extend(vdc_json, CustomTagsTable.retrieve($("#vdcCreateGeneralTab", context)));
|
||||
|
||||
var group_ids = this.groupsTable.retrieveResourceTableSelect();
|
||||
|
||||
if (this.action == "create") {
|
||||
var resources = this.resourcesTab.retrieve(context);
|
||||
|
||||
vdc_json = {
|
||||
"vdc" : vdc_json,
|
||||
"group_ids" : group_ids,
|
||||
"clusters" : resources.clusters,
|
||||
"hosts" : resources.hosts,
|
||||
"vnets" : resources.vnets,
|
||||
"datastores" : resources.datastores
|
||||
};
|
||||
|
||||
Sunstone.runAction("Vdc.create",vdc_json);
|
||||
return false;
|
||||
} else if (this.action == "update") {
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function _submitAdvanced(context) {
|
||||
if (this.action == "create") {
|
||||
var template = $('textarea#template',context).val();
|
||||
var vdc_json = {vdc: {vdc_raw: template}};
|
||||
Sunstone.runAction("Vdc.create",vdc_json);
|
||||
return false;
|
||||
} else if (this.action == "update") {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
// TODO bug, does not work until the input is visible
|
||||
//$("input#name", context).focus();
|
||||
|
||||
this.groupsTable.refreshResourceTableSelect();
|
||||
this.resourcesTab.onShow(context);
|
||||
}
|
||||
|
||||
function _fill(context, element) {
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
<form data-abide="ajax" id="{{formPanelId}}Advanced" class="custom creation">
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<p>{{tr "Write the VDC template here"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<textarea id="template" rows="15" required></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,3 @@
|
||||
define(function(require){
|
||||
return 'createVDCForm';
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
<form data-abide="ajax" id="{{formPanelId}}Wizard" class="custom creation">
|
||||
<div>
|
||||
<dl id="vdc_create_tabs" class="tabs right-info-tabs text-center" data-tab>
|
||||
<dd class="active"><a href="#vdcCreateGeneralTab"><i class="fa fa-th"></i><br>{{tr "General"}}</a></dd>
|
||||
<dd><a href="#vdcCreateGroupsTab"><i class="fa fa-users"></i><br>{{tr "Groups"}}</a></dd>
|
||||
<dd><a href="#vdcCreateResourcesTab"><i class="fa fa-hdd-o"></i><br>{{tr "Resources"}}</a></dd>
|
||||
</dl>
|
||||
<div id="vdc_create_tabs_content" class="tabs-content">
|
||||
<div class="content active" id="vdcCreateGeneralTab">
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label for="name" >{{tr "Name"}}:
|
||||
<span class="tip">{{tr "Name that the VDC will get for description purposes."}}</span>
|
||||
</label>
|
||||
<input type="text" wizard_field="NAME" required name="name" id="name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label for="DESCRIPTION" >{{tr "Description"}}:
|
||||
<span class="tip">{{tr "Description of the VDC"}}</span>
|
||||
</label>
|
||||
<textarea type="text" wizard_field="DESCRIPTION" id="DESCRIPTION" name="DESCRIPTION"/>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<span>{{tr "Custom attributes"}}</span>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
{{{customTagsHTML}}}
|
||||
</div>
|
||||
<div id="vdcCreateGroupsTab" class="content">
|
||||
{{{groupsTableHTML}}}
|
||||
</div>
|
||||
<div id="vdcCreateResourcesTab" class="content">
|
||||
{{{resourcesTabHTML}}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Reference in new issue
Block a user