1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

Feature #4217: Add MarketPlace create and update forms

This commit is contained in:
Daniel Molina 2016-02-08 16:37:52 +01:00
parent d299db45a8
commit 4630a422ed
9 changed files with 393 additions and 14 deletions

View File

@ -599,7 +599,8 @@ tabs:
#- 8 # Labels
actions:
MarketPlace.refresh: true
#MarketPlace.create_dialog: true
MarketPlace.create_dialog: true
MarketPlace.update_dialog: true
MarketPlace.rename: true
MarketPlace.chown: true
MarketPlace.chgrp: true
@ -624,7 +625,7 @@ tabs:
#- 11 # Labels
actions:
MarketPlaceApp.refresh: true
#MarketPlaceApp.create_dialog: true
MarketPlaceApp.create_dialog: true
MarketPlaceApp.rename: true
MarketPlaceApp.chown: true
MarketPlaceApp.chgrp: true

View File

@ -594,7 +594,8 @@ tabs:
#- 8 # Labels
actions:
MarketPlace.refresh: true
#MarketPlace.create_dialog: true
MarketPlace.create_dialog: true
MarketPlace.update_dialog: true
MarketPlace.rename: true
MarketPlace.chown: true
MarketPlace.chgrp: true

View File

@ -0,0 +1,323 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
DEPENDENCIES
*/
var BaseFormPanel = require('utils/form-panels/form-panel');
var Sunstone = require('sunstone');
var Locale = require('utils/locale');
var Notifier = require('utils/notifier');
var Tips = require('utils/tips');
var ResourceSelect = require('utils/resource-select');
var Config = require('sunstone-config');
/*
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 MarketPlace"),
'buttonText': Locale.tr("Create"),
'resetButton': true
}
};
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.setup = _setup;
return FormPanel;
/*
FUNCTION DEFINITIONS
*/
function _htmlWizard() {
return TemplateWizardHTML({
'formPanelId': this.formPanelId,
});
}
function _htmlAdvanced() {
return TemplateAdvancedHTML({formPanelId: this.formPanelId});
}
function _onShow(dialog) {
$("#name", dialog).focus();
// var cluster_id = $("div#cluster_id .resource_list_select", dialog).val();
// if (!cluster_id) cluster_id = "-1";
//
// var cluster_id_raw = $("div#datastore_cluster_raw .resource_list_select", dialog).val();
// if (!cluster_id_raw) cluster_id_raw = "-1";
//
// ResourceSelect.insert({
// context: $('#cluster_id', dialog),
// resourceName: 'Cluster',
// initValue: cluster_id,
// includeDefaultCluster: true
// });
//
// ResourceSelect.insert({
// context: $('#datastore_cluster_raw', dialog),
// resourceName: 'Cluster',
// initValue: cluster_id_raw,
// includeDefaultCluster: true
// });
return false;
}
// Set up the create datastore dialog
function _setup(dialog) {
Tips.setup(dialog);
// Show custom driver input only when custom is selected in selects
// $('input[name="ds_tab_custom_ds_mad"],' +
// 'input[name="ds_tab_custom_tm_mad"]', dialog).parent().hide();
//
// $('select#ds_mad', dialog).change(function() {
// if ($(this).val() == "custom") {
// $('input[name="ds_tab_custom_ds_mad"]', dialog).parent().show();
// } else {
// _setRequiredFields(dialog, $(this).val());
// $('input[name="ds_tab_custom_ds_mad"]', dialog).parent().hide();
// }
// });
//
// $('select#tm_mad', dialog).change(function() {
// if ($(this).val() == "custom")
// $('input[name="ds_tab_custom_tm_mad"]', dialog).parent().show();
// else
// $('input[name="ds_tab_custom_tm_mad"]', dialog).parent().hide();
// });
//
// $('#presets', dialog).change(function() {
// _hideAll(dialog);
// var choice_str = $(this).val();
//
// switch (choice_str)
// {
// case 'fs':
// _selectFilesystem(dialog);
// break;
// case 'vmware_vmfs':
// _selectVmwareVmfs(dialog);
// break;
// case 'block_lvm':
// _selectBlockLvm(dialog);
// break;
// case 'fs_lvm':
// _selectFsLvm(dialog);
// break;
// case 'ceph':
// _selectCeph(dialog);
// break;
// case 'gluster':
// _selectGluster(dialog);
// break;
// case 'dev':
// _selectDevices(dialog);
// break;
// case 'iscsi':
// _selectISCSI(dialog);
// break;
// case 'custom':
// _selectCustom(dialog);
// break;
// }
// });
//
// $('#presets', dialog).change();
//
// // Hide disk_type
// $('select#disk_type', dialog).parent().hide();
//
// _hideAll(dialog);
// _selectFilesystem(dialog);
}
function _submitWizard(dialog) {
// var name = $('#name', dialog).val();
// var cluster_id = $(".resource_list_select", $('#cluster_id', dialog)).val();
// var ds_type = $('input[name=ds_type]:checked', dialog).val();
// var ds_mad = $('#ds_mad', dialog).val();
// ds_mad = ds_mad == "custom" ? $('input[name="ds_tab_custom_ds_mad"]', dialog).val() : ds_mad;
// var tm_mad = $('#tm_mad', dialog).val();
// tm_mad = tm_mad == "custom" ? $('input[name="ds_tab_custom_tm_mad"]', dialog).val() : tm_mad;
// var type = $('#disk_type', dialog).val();
//
// var safe_dirs = $('#safe_dirs', dialog).val();
// var base_path = $('#base_path', dialog).val();
// var restricted_dirs = $('#restricted_dirs', dialog).val();
// var limit_transfer_bw = $('#limit_transfer_bw', dialog).val();
// var datastore_capacity_check = $('#datastore_capacity_check', dialog).is(':checked');
// var no_decompress = $('#no_decompress', dialog).is(':checked');
//
// var bridge_list = $('#bridge_list', dialog).val();
// var ds_tmp_dir = $('#ds_tmp_dir', dialog).val();
// var vg_name = $('#vg_name', dialog).val();
// var limit_mb = $('#limit_mb', dialog).val();
// var gluster_host = $('#gluster_host', dialog).val();
// var gluster_volume = $('#gluster_volume', dialog).val();
// var pool_name = $('#pool_name', dialog).val();
// var ceph_host = $('#ceph_host', dialog).val();
// var ceph_secret = $('#ceph_secret', dialog).val();
// var ceph_user = $('#ceph_user', dialog).val();
// var rbd_format = $('#rbd_format', dialog).val();
// var staging_dir = $('#staging_dir', dialog).val();
// var ceph_conf = $('#ceph_conf', dialog).val();
// var iscsi_host = $('#iscsi_host', dialog).val();
// var iscsi_user = $('#iscsi_user', dialog).val();
// var iscsi_usage = $('#iscsi_usage', dialog).val();
//
// var ds_obj = {
// "datastore" : {
// "name" : name,
// "tm_mad" : tm_mad,
// "disk_type" : type,
// "type" : ds_type
// },
// "cluster_id" : cluster_id
// };
//
// // If we are adding a system datastore then
// // we do not use ds_mad
// if (ds_type != "SYSTEM_DS")
// ds_obj.datastore.ds_mad = ds_mad;
//
// if (base_path)
// ds_obj.datastore.base_path = base_path;
//
// if (safe_dirs)
// ds_obj.datastore.safe_dirs = safe_dirs;
//
// if (restricted_dirs)
// ds_obj.datastore.restricted_dirs = restricted_dirs;
//
// if (limit_transfer_bw)
// ds_obj.datastore.limit_transfer_bw = limit_transfer_bw;
//
// if (no_decompress)
// ds_obj.datastore.no_decompress = "YES";
//
// if (datastore_capacity_check)
// ds_obj.datastore.datastore_capacity_check = "YES";
//
// if (bridge_list)
// ds_obj.datastore.bridge_list = bridge_list;
//
// if (ds_tmp_dir)
// ds_obj.datastore.ds_tmp_dir = ds_tmp_dir;
//
// if (vg_name)
// ds_obj.datastore.vg_name = vg_name;
//
// if (limit_mb)
// ds_obj.datastore.limit_mb = limit_mb;
//
// if (gluster_host)
// ds_obj.datastore.gluster_host = gluster_host;
//
// if (gluster_volume)
// ds_obj.datastore.gluster_volume = gluster_volume;
//
// if (pool_name)
// ds_obj.datastore.pool_name = pool_name;
//
// if (ceph_host)
// ds_obj.datastore.ceph_host = ceph_host;
//
// if (ceph_secret)
// ds_obj.datastore.ceph_secret = ceph_secret;
//
// if (ceph_user)
// ds_obj.datastore.ceph_user = ceph_user;
//
// if (rbd_format)
// ds_obj.datastore.rbd_format = rbd_format;
//
// if (staging_dir)
// ds_obj.datastore.staging_dir = staging_dir;
//
// if (ceph_conf)
// ds_obj.datastore.ceph_conf = ceph_conf;
//
// if (iscsi_host)
// ds_obj.datastore.iscsi_host = iscsi_host;
//
// if (iscsi_user)
// ds_obj.datastore.iscsi_user = iscsi_user;
//
// if (iscsi_usage)
// ds_obj.datastore.iscsi_usage = iscsi_usage;
// Sunstone.runAction("Datastore.create", ds_obj);
return false;
}
function _submitAdvanced(dialog) {
// var template = $('#template', dialog).val();
// var cluster_id = $(".resource_list_select", $('#datastore_cluster_raw', dialog)).val();
//
// if (!cluster_id) {
// Notifier.notifyError(Locale.tr("Please select a cluster for this datastore"));
// return false;
// }
//
// var ds_obj = {
// "datastore" : {
// "datastore_raw" : template
// },
// "cluster_id" : cluster_id
// };
//
// Sunstone.runAction("Datastore.create", ds_obj);
return false;
}
});

View File

@ -0,0 +1,28 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, OpenNebula Project, OpenNebula Systems }}
{{! }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
{{! not use this file except in compliance with the License. You may obtain }}
{{! a copy of the License at }}
{{! }}
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
{{! }}
{{! Unless required by applicable law or agreed to in writing, software }}
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
{{! See the License for the specific language governing permissions and }}
{{! limitations under the License. }}
{{! -------------------------------------------------------------------------- }}
<form data-abide="ajax" id="{{formPanelId}}Advanced" class="custom creation">
<div class="row">
<div class="large-12 columns">
<p>{{tr "Write the MarketPlace Appliance template here"}}</p>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<textarea id="template" rows="15" required></textarea>
</div>
</div>
</form>

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require){
return 'createMarketPlaceAppForm';
})

View File

@ -35,7 +35,7 @@ define(function(require) {
];
var _formPanels = [
//require('./datastores-tab/form-panels/create')
require('./marketplaces-tab/form-panels/create')
];
var Tab = {

View File

@ -24,13 +24,13 @@ define(function(require) {
var RESOURCE = "MarketPlace";
var XML_ROOT = "MARKETPLACE";
var TAB_ID = require('./tabId');
//var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT);
var _actions = {
//"MarketPlace.create" : _commonActions.create(CREATE_DIALOG_ID),
//"MarketPlace.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
"MarketPlace.create" : _commonActions.create(CREATE_DIALOG_ID),
"MarketPlace.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
"MarketPlace.list" : _commonActions.list(),
"MarketPlace.show" : _commonActions.show(),
"MarketPlace.refresh" : _commonActions.refresh(),
@ -38,9 +38,11 @@ define(function(require) {
"MarketPlace.chown": _commonActions.multipleAction('chown'),
"MarketPlace.chgrp": _commonActions.multipleAction('chgrp'),
"MarketPlace.chmod": _commonActions.singleAction('chmod'),
//"MarketPlace.update" : _commonActions.updateTemplate(),
//"MarketPlace.update_template" : _commonActions.updateTemplate(),
//"MarketPlace.append_template" : _commonActions.appendTemplate(),
"MarketPlace.update" : _commonActions.update(),
"MarketPlace.update_template" : _commonActions.updateTemplate(),
"MarketPlace.append_template" : _commonActions.appendTemplate(),
"MarketPlace.update_dialog" : _commonActions.checkAndShowUpdate(),
"MarketPlace.show_to_update" : _commonActions.showUpdate(CREATE_DIALOG_ID),
"MarketPlace.rename": _commonActions.singleAction('rename')
}

View File

@ -23,10 +23,15 @@ define(function(require) {
layout: "refresh",
alwaysActive: true
},
//"MarketPlace.create_dialog" : {
// type: "create_dialog",
// layout: "create"
//},
"MarketPlace.create_dialog" : {
type: "create_dialog",
layout: "create"
},
"MarketPlace.update_dialog" : {
type: "action",
layout: "main",
text: Locale.tr("Update")
},
"MarketPlace.chown" : {
type: "confirm_with_select",
text: Locale.tr("Change owner"),