1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-18 02:50:09 +03:00

Feature #4217: Add export app form

This commit is contained in:
Daniel Molina 2016-02-09 18:38:33 +01:00
parent ebd1199f23
commit f75c009ef9
10 changed files with 214 additions and 1 deletions

View File

@ -625,6 +625,7 @@ tabs:
actions:
MarketPlaceApp.refresh: true
MarketPlaceApp.create_dialog: true
MarketPlaceApp.export_dialog: true
MarketPlaceApp.rename: true
MarketPlaceApp.chown: true
MarketPlaceApp.chgrp: true

View File

@ -620,6 +620,7 @@ tabs:
actions:
MarketPlaceApp.refresh: true
MarketPlaceApp.create_dialog: true
MarketPlaceApp.export_dialog: true
MarketPlaceApp.rename: true
MarketPlaceApp.chown: true
MarketPlaceApp.chgrp: true

View File

@ -48,6 +48,7 @@ module OpenNebulaJSON
rc = case action_hash['perform']
when "update" then self.update(action_hash['params'])
when "export" then self.export(action_hash['params'])
when "chown" then self.chown(action_hash['params'])
when "chmod" then self.chmod_octet(action_hash['params'])
when "rename" then self.rename(action_hash['params'])
@ -64,6 +65,12 @@ module OpenNebulaJSON
super(params['template_raw'])
end
def export(params=Hash.new)
dsid = params['dsid'] ? params['dsid'].to_i : params['dsid']
name = params['name']
super({:dsid => dsid, :name => name})
end
def chown(params=Hash.new)
super(params['owner_id'].to_i,params['group_id'].to_i)
end

View File

@ -97,6 +97,10 @@ define(function(require) {
var action_obj = params.data.extra_param;
OpenNebulaAction.simple_action(params, RESOURCE, "rename", action_obj);
},
"export" : function(params) {
var action_obj = params.data.extra_param;
OpenNebulaAction.simple_action(params, RESOURCE, "export", action_obj);
},
"enable": function(params) {
OpenNebulaAction.simple_action(params, RESOURCE, "enable");
},

View File

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

View File

@ -25,12 +25,37 @@ define(function(require) {
var XML_ROOT = "MARKETPLACEAPP";
var TAB_ID = require('./tabId');
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
var EXPORT_DIALOG_ID = require('./form-panels/export/formPanelId');
var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT);
var _actions = {
"MarketPlaceApp.create" : _commonActions.create(CREATE_DIALOG_ID),
"MarketPlaceApp.create_dialog" : _commonActions.showCreate(CREATE_DIALOG_ID),
"MarketPlaceApp.export_dialog" : {
type: "custom",
call: function() {
Sunstone.showFormPanel(TAB_ID, EXPORT_DIALOG_ID, "export");
}
},
"MarketPlaceApp.export" : {
type: "multiple",
call: OpenNebulaResource.export,
callback: function(req) {
Sunstone.hideFormPanel(TAB_ID);
OpenNebulaAction.clear_cache("IMAGE");
OpenNebulaAction.clear_cache("VMTEMPLATE");
},
elements: function() {
return Sunstone.getDataTable(TAB_ID).elements();
},
error: function(request, response){
// without tab id param to work for both templates and vms tab
Sunstone.hideFormPanelLoading();
Notifier.onError(request, response);
},
notify: true
},
"MarketPlaceApp.list" : _commonActions.list(),
"MarketPlaceApp.show" : _commonActions.show(),
"MarketPlaceApp.refresh" : _commonActions.refresh(),

View File

@ -27,6 +27,10 @@ define(function(require) {
type: "create_dialog",
layout: "create"
},
"MarketPlaceApp.export_dialog" : {
type: "action",
text: '<i class="fa fa-download"/>'
},
"MarketPlaceApp.chown" : {
type: "confirm_with_select",
text: Locale.tr("Change owner"),

View File

@ -0,0 +1,119 @@
/* -------------------------------------------------------------------------- */
/* 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 DataStoresTable = require('tabs/datastores-tab/datatable');
var DataStore = require('opennebula/datastore');
var Config = require('sunstone-config');
var WizardFields = require('utils/wizard-fields');
/*
TEMPLATES
*/
var TemplateWizardHTML = require('hbs!./export/wizard');
/*
CONSTANTS
*/
var FORM_PANEL_ID = require('./export/formPanelId');
var TAB_ID = require('../tabId');
/*
CONSTRUCTOR
*/
function FormPanel() {
this.formPanelId = FORM_PANEL_ID;
this.tabId = TAB_ID;
this.actions = {
'export': {
'title': Locale.tr("Export App To OpenNebula"),
'buttonText': Locale.tr("Export"),
'resetButton': true
}
};
this.datastoresTable = new DataStoresTable(
FORM_PANEL_ID + 'datastoresTable', {
'select': true,
'selectOptions': {
'filter_fn': function(ds) { return ds.TYPE == DataStore.TYPES.IMAGE_DS; } // Show system DS only
}
});
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.submitWizard = _submitWizard;
FormPanel.prototype.onShow = _onShow;
FormPanel.prototype.setup = _setup;
return FormPanel;
/*
FUNCTION DEFINITIONS
*/
function _htmlWizard() {
return TemplateWizardHTML({
'formPanelId': this.formPanelId,
'datastoresTableHTML': this.datastoresTable.dataTableHTML
});
}
function _onShow(context) {
this.datastoresTable.resetResourceTableSelect();
$("#NAME", context).focus();
return false;
}
// Set up the create datastore context
function _setup(context) {
Tips.setup(context);
this.datastoresTable.initialize();
this.datastoresTable.idInput().attr('required', '');
}
function _submitWizard(context) {
var marketPlaceAppObj = {
"name" : $("#NAME", context).val(),
"dsid" : this.datastoresTable.idInput().val()
};
Sunstone.runAction("MarketPlaceApp.export", Sunstone.getDataTable(TAB_ID).elements(), marketPlaceAppObj);
return false;
}
});

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 'exportMarketPlaceAppForm';
})

View File

@ -0,0 +1,32 @@
{{! -------------------------------------------------------------------------- }}
{{! 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}}Wizard" class="custom creation">
<div class="row">
<div class="medium-6 columns">
<label for="NAME">
{{tr "Name"}}:
<span class="tip">
{{tr "Name that the resource will get for description purposes."}}
</span>
</label>
<input id="NAME" type="text" wizard_field="NAME"/>
</div>
</div>
<fieldset>
<legend>{{tr "Select the Datastore to store the resource"}}</legend>
{{{datastoresTableHTML}}}
</fieldset>
</form>