mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 11:52:37 +09:00
feature #3748: Add template creation form
This commit is contained in:
1 parent
9ac5eadd31
commit
7f8a1fa910
6 files changed
+161
-9
No files matched your search
@@ -16,9 +16,9 @@ define(function(require) {
|
||||
require('./templates-tab/panels/template')
|
||||
];
|
||||
|
||||
/*var _formPanels = [
|
||||
var _formPanels = [
|
||||
require('./templates-tab/form-panels/create')
|
||||
]*/
|
||||
]
|
||||
|
||||
var Tab = {
|
||||
tabId: TAB_ID,
|
||||
@@ -33,7 +33,7 @@ define(function(require) {
|
||||
actions: Actions,
|
||||
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
|
||||
panels: _panels,
|
||||
//formPanels: _formPanels,
|
||||
formPanels: _formPanels,
|
||||
//dialogs: _dialogs
|
||||
};
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@ define(function(require) {
|
||||
var OpenNebulaTemplate = require('opennebula/template');
|
||||
|
||||
var TAB_ID = require('./tabId');
|
||||
// TODO var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
|
||||
var _actions = {
|
||||
"Template.create" : {
|
||||
type: "create",
|
||||
call: OpenNebulaTemplate.create,
|
||||
callback: function(request, response) {
|
||||
// TODO Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
|
||||
// TODO Sunstone.hideFormPanel(TAB_ID);
|
||||
// TODO Sunstone.getDataTable(TAB_ID).addElement(request, response);
|
||||
Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
|
||||
Sunstone.hideFormPanel(TAB_ID);
|
||||
Sunstone.getDataTable(TAB_ID).addElement(request, response);
|
||||
},
|
||||
error: function(request, response) {
|
||||
// TODO Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
Notifier.onError(request, response);
|
||||
},
|
||||
notify: true
|
||||
@@ -26,7 +26,7 @@ define(function(require) {
|
||||
"Template.create_dialog" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
// TODO Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
|
||||
Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
|
||||
}
|
||||
},
|
||||
"Template.import_dialog" : {
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
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');
|
||||
|
||||
/*
|
||||
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');
|
||||
var WIZARD_TABS = [
|
||||
require('./create/wizard-tabs/general')
|
||||
]
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function FormPanel() {
|
||||
this.formPanelId = FORM_PANEL_ID;
|
||||
this.tabId = TAB_ID;
|
||||
this.actions = {
|
||||
'create': {
|
||||
'title': Locale.tr("Create VM Template"),
|
||||
'buttonText': Locale.tr("Create"),
|
||||
'resetButton': true
|
||||
},
|
||||
'update': {
|
||||
'title': Locale.tr("Update VM Template"),
|
||||
'buttonText': Locale.tr("Update"),
|
||||
'resetButton': false
|
||||
}
|
||||
};
|
||||
|
||||
var that = this;
|
||||
that.wizardTabs = [];
|
||||
var wizardTabInstance;
|
||||
$.each(WIZARD_TABS, function(index, wizardTab) {
|
||||
try {
|
||||
wizardTabInstance = new wizardTab();
|
||||
wizardTabInstance.contentHTML = wizardTabInstance.html();
|
||||
that.wizardTabs.push(wizardTabInstance);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
|
||||
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.setup = _setup;
|
||||
FormPanel.prototype.onShow = _onShow;
|
||||
FormPanel.prototype.submitWizard = _submitWizard;
|
||||
FormPanel.prototype.submitAdvanced = _submitAdvanced;
|
||||
FormPanel.prototype.fill = _fill;
|
||||
|
||||
return FormPanel;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _htmlWizard() {
|
||||
|
||||
return TemplateWizardHTML({
|
||||
'formPanelId': this.formPanelId,
|
||||
'wizardTabs': this.wizardTabs
|
||||
});
|
||||
}
|
||||
|
||||
function _htmlAdvanced() {
|
||||
return TemplateAdvancedHTML({formPanelId: this.formPanelId});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
$.each(this.wizardTabs, function(index, wizardTab) {
|
||||
wizardTab.setup();
|
||||
});
|
||||
|
||||
context.foundation('reflow', 'tab');
|
||||
Tips.setup(context);
|
||||
}
|
||||
|
||||
function _onShow() {
|
||||
|
||||
}
|
||||
|
||||
function _submitWizard() {
|
||||
|
||||
}
|
||||
|
||||
function _submitAdvanced() {
|
||||
|
||||
}
|
||||
|
||||
function _fill() {
|
||||
|
||||
}
|
||||
});
|
||||
@@ -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 Virtual Machine 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 'createVMTemplateForm';
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
<form data-abide="ajax" id="{{formPanelId}}Wizard" class="custom creation">
|
||||
<div class="bordered-tabs">
|
||||
<dl id="template_create_tabs" class="tabs right-info-tabs text-center" data-tab>
|
||||
{{#each wizardTabs}}
|
||||
<dd class='{{classes}}'>
|
||||
<a href='#{{wizardTabId}}'> <i class='fa {{icon}}'></i>
|
||||
<br>{{title}}</a>
|
||||
</dd>
|
||||
{{/each}}
|
||||
</dl>
|
||||
<div id="template_create_tabs_content" class="tabs-content" style="min-height: 300px">
|
||||
{{#each wizardTabs}}
|
||||
<div id="{{wizardTabId}}" class="wizard_tab content">
|
||||
{{{contentHTML}}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Reference in new issue
Block a user