diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 92129ec624..84b076149f 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -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 diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 4c17853ab5..581e0afdab 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -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 diff --git a/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb b/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb index 1bd0b47546..c5d2b75721 100644 --- a/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb @@ -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 diff --git a/src/sunstone/public/app/opennebula/marketplaceapp.js b/src/sunstone/public/app/opennebula/marketplaceapp.js index 4489aef21f..1ddff61005 100644 --- a/src/sunstone/public/app/opennebula/marketplaceapp.js +++ b/src/sunstone/public/app/opennebula/marketplaceapp.js @@ -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"); }, diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab.js b/src/sunstone/public/app/tabs/marketplaceapps-tab.js index 9a7ef6b7e0..704028931e 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab.js @@ -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 = { diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js index 33a6ab5132..8de2c31700 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/actions.js @@ -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(), diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/buttons.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/buttons.js index d014c7da08..2f26552f6f 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/buttons.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/buttons.js @@ -27,6 +27,10 @@ define(function(require) { type: "create_dialog", layout: "create" }, + "MarketPlaceApp.export_dialog" : { + type: "action", + text: '' + }, "MarketPlaceApp.chown" : { type: "confirm_with_select", text: Locale.tr("Change owner"), diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js new file mode 100644 index 0000000000..875b01da34 --- /dev/null +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js @@ -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; + } +}); + diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/formPanelId.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/formPanelId.js new file mode 100644 index 0000000000..5a8f5cb6b1 --- /dev/null +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/formPanelId.js @@ -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'; +}) diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/wizard.hbs b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/wizard.hbs new file mode 100644 index 0000000000..3e06f92298 --- /dev/null +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/wizard.hbs @@ -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. }} +{{! -------------------------------------------------------------------------- }} +
+
+
+ + +
+
+
+ {{tr "Select the Datastore to store the resource"}} + {{{datastoresTableHTML}}} +
+
\ No newline at end of file