diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 59b029490d..3fe0c45461 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -610,6 +610,7 @@ tabs: marketplaceapps-tab: panel_tabs: marketplaceapp_info_tab: true + marketplaceapp_templates_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 976095db2b..0a559edafa 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -605,6 +605,7 @@ tabs: marketplaceapps-tab: panel_tabs: marketplaceapp_info_tab: true + marketplaceapp_templates_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab.js b/src/sunstone/public/app/tabs/marketplaceapps-tab.js index 704028931e..1a3d89a8e3 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab.js @@ -27,7 +27,8 @@ define(function(require) { ]; var _panels = [ - require('./marketplaceapps-tab/panels/info') + require('./marketplaceapps-tab/panels/info'), + require('./marketplaceapps-tab/panels/templates') ]; var _panelsHooks = [ diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs index 11b2a121c2..191e3f123a 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create/wizard.hbs @@ -54,7 +54,7 @@
- {{tr "Select the Image origin"}} + {{tr "Select the Image to be exported"}} {{{imagesTableHTML}}}
diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info.js index 96dce6fa3e..1e27a3cd73 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info.js @@ -25,6 +25,7 @@ define(function(require) { var TemplateTable = require('utils/panel/template-table'); var PermissionsTable = require('utils/panel/permissions-table'); var OpenNebulaMarketPlaceApp = require('opennebula/marketplaceapp'); + var Sunstone = require('sunstone'); /* TEMPLATES @@ -66,11 +67,17 @@ define(function(require) { function _html() { - var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME); + var strippedTemplate = $.extend({}, this.element.TEMPLATE); + delete strippedTemplate["VMTEMPLATE64"]; + delete strippedTemplate["APPTEMPLATE64"]; + var templateTableHTML = TemplateTable.html( - this.element.TEMPLATE, RESOURCE, + strippedTemplate, RESOURCE, Locale.tr("Attributes")); + + var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME); var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element); + var prettyRegTime = Humanize.prettyTime(this.element.REGTIME); var stateStr = OpenNebulaMarketPlaceApp.stateStr(this.element.STATE); var typeStr = OpenNebulaMarketPlaceApp.typeStr(this.element.TYPE); var sizeStr = Humanize.sizeFromMB(this.element.SIZE); @@ -81,6 +88,7 @@ define(function(require) { 'renameTrHTML': renameTrHTML, 'templateTableHTML': templateTableHTML, 'permissionsTableHTML': permissionsTableHTML, + 'prettyRegTime': prettyRegTime, 'stateStr': stateStr, 'typeStr': typeStr, 'sizeStr': sizeStr @@ -88,8 +96,22 @@ define(function(require) { } function _setup(context) { + var strippedTemplate = $.extend({}, this.element.TEMPLATE); + delete strippedTemplate["VMTEMPLATE64"]; + delete strippedTemplate["APPTEMPLATE64"]; + + var hiddenValues = {}; + + if (this.element.TEMPLATE.VMTEMPLATE64 !== undefined) { + hiddenValues.VMTEMPLATE64 = this.element.TEMPLATE.VMTEMPLATE64; + } + if (this.element.TEMPLATE.APPTEMPLATE64 !== undefined) { + hiddenValues.APPTEMPLATE64 = this.element.TEMPLATE.APPTEMPLATE64; + } + + TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues); + RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context); - TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); return false; } diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info/html.hbs index 9bb4b7b48b..44378567f4 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/info/html.hbs @@ -55,10 +55,12 @@ -
- {{{permissionsTableHTML}}} +
+ {{{permissionsTableHTML}}}
-
{{{templateTableHTML}}}
+
+ {{{templateTableHTML}}} +
diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates.js new file mode 100644 index 0000000000..c8a3462895 --- /dev/null +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates.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 Locale = require('utils/locale'); + var Humanize = require('utils/humanize'); + var RenameTr = require('utils/panel/rename-tr'); + var TemplateTable = require('utils/panel/template-table'); + var PermissionsTable = require('utils/panel/permissions-table'); + var OpenNebulaMarketPlaceApp = require('opennebula/marketplaceapp'); + var Sunstone = require('sunstone'); + + /* + TEMPLATES + */ + + var TemplateInfo = require('hbs!./templates/html'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./templates/panelId'); + var RESOURCE = "MarketPlaceApp" + var XML_ROOT = "MARKETPLACEAPP" + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Templates"); + this.icon = "fa-file-o"; + + this.element = info[XML_ROOT]; + + return this; + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + + function _html() { + var vmTemplate = atob(this.element.TEMPLATE.VMTEMPLATE64 || ''); + var appTemplate = atob(this.element.TEMPLATE.APPTEMPLATE64 || ''); + + return TemplateInfo({ + 'element': this.element, + 'vmTemplate': vmTemplate, + 'appTemplate': appTemplate + }); + } + + function _setup(context) { + context.off("click", ".vmTemplate_edit"); + context.on("click", ".vmTemplate_edit", function() { + $("#vmTemplate_text", context).hide(); + $("#vmTemplate_textarea", context).show().focus(); + }); + + context.off("change", "#vmTemplate_textarea"); + context.on("change", "#vmTemplate_textarea", function() { + var templateStr = 'VMTEMPLATE64 = "' + btoa($(this).val()) + '"'; + Sunstone.runAction("MarketPlaceApp.append_template", that.element.ID, templateStr); + }); + + context.off("focusout", "#vmTemplate_textarea"); + context.on("focusout", "#vmTemplate_textarea", function() { + $("#vmTemplate_text", context).show(); + $("#vmTemplate_textarea", context).hide(); + }); + + context.off("click", ".appTemplate_edit"); + context.on("click", ".appTemplate_edit", function() { + $("#appTemplate_text", context).hide(); + $("#appTemplate_textarea", context).show().focus(); + }); + + context.off("change", "#appTemplate_textarea"); + context.on("change", "#appTemplate_textarea", function() { + var templateStr = 'APPTEMPLATE64 = "' + btoa($(this).val()) + '"'; + Sunstone.runAction("MarketPlaceApp.append_template", that.element.ID, templateStr); + }); + + context.off("focusout", "#appTemplate_textarea"); + context.on("focusout", "#appTemplate_textarea", function() { + $("#appTemplate_text", context).show(); + $("#appTemplate_textarea", context).hide(); + }); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates/html.hbs b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates/html.hbs new file mode 100644 index 0000000000..5cc8fa867a --- /dev/null +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates/html.hbs @@ -0,0 +1,58 @@ +{{! -------------------------------------------------------------------------- }} +{{! 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 "App Template"}} + +
+ +
+      {{#if appTemplate}}
+        {{~htmlDecode appTemplate~}}
+      {{else}}
+        {{tr "You can provide a template for the resource that will be created in OpenNebula"}}
+      {{/if}}
+    
+
+
+ + + + + + + +
{{tr "VM Template"}} + +
+ +
+      {{#if vmTemplate}}
+        {{~htmlDecode vmTemplate~}}
+      {{else}}
+        {{tr "You can provide a VM template associated to the resource that will be created in OpenNebula"}}
+      {{/if}}
+    
+
+
diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates/panelId.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates/panelId.js new file mode 100644 index 0000000000..751de77571 --- /dev/null +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/panels/templates/panelId.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 'marketplaceapp_templates_tab'; +}); diff --git a/src/sunstone/public/scss/app.scss b/src/sunstone/public/scss/app.scss index c4588e8339..309cd76022 100644 --- a/src/sunstone/public/scss/app.scss +++ b/src/sunstone/public/scss/app.scss @@ -1185,13 +1185,21 @@ hr { } } -#user_ssh_public_key_text, #config_ssh_public_key_text { +#user_ssh_public_key_text, +#config_ssh_public_key_text { font-size: 0.875rem; color: #777; padding: 0px 10px; overflow-x:hidden; - text-overflow: - ellipsis; height: 120px; + text-overflow: ellipsis; + height: 120px; +} + +.info_text { + color: #777; + padding: 0px 10px; + overflow-x:hidden; + text-overflow: ellipsis; } .vm-action-disabled {