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

Feature #4217: Add MarketPlaceApp Templates panel

This commit is contained in:
Daniel Molina 2016-02-10 17:12:16 +01:00
parent 4333bb6da2
commit fbf7e2cbe1
10 changed files with 242 additions and 11 deletions

View File

@ -610,6 +610,7 @@ tabs:
marketplaceapps-tab:
panel_tabs:
marketplaceapp_info_tab: true
marketplaceapp_templates_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -605,6 +605,7 @@ tabs:
marketplaceapps-tab:
panel_tabs:
marketplaceapp_info_tab: true
marketplaceapp_templates_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -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 = [

View File

@ -54,7 +54,7 @@
</div>
</div>
<fieldset>
<legend>{{tr "Select the Image origin"}}</legend>
<legend>{{tr "Select the Image to be exported"}}</legend>
{{{imagesTableHTML}}}
</fieldset>
<fieldset>

View File

@ -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;
}

View File

@ -55,10 +55,12 @@
</tbody>
</table>
</div>
<div class="large-6 columns">
{{{permissionsTableHTML}}}
<div class="large-6 columns">
{{{permissionsTableHTML}}}
</div>
</div>
<div class="row">
<div class="large-9 columns">{{{templateTableHTML}}}</div>
<div class="large-9 columns">
{{{templateTableHTML}}}
</div>
</div>

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

View File

@ -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. }}
{{! -------------------------------------------------------------------------- }}
<div class="row">
<div class="large-6 columns">
<table class="dataTable" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>{{tr "App Template"}}</th>
<th>
<a class="appTemplate_edit right" href="#"><i class="fa fa-pencil-square-o"></i></a>
</th>
</tr>
</thead>
</table>
<textarea rows="6" type="text" id="appTemplate_textarea" class="hidden">{{appTemplate}}</textarea>
<pre id="appTemplate_text" class="info_text">
{{#if appTemplate}}
{{~htmlDecode appTemplate~}}
{{else}}
{{tr "You can provide a template for the resource that will be created in OpenNebula"}}
{{/if}}
</pre>
</div>
<div class="large-6 columns">
<table class="dataTable" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>{{tr "VM Template"}}</th>
<th>
<a class="vmTemplate_edit right" href="#"><i class="fa fa-pencil-square-o"></i></a>
</th>
</tr>
</thead>
</table>
<textarea rows="6" type="text" id="vmTemplate_textarea" class="hidden">{{vmTemplate}}</textarea>
<pre id="vmTemplate_text" class="info_text">
{{#if vmTemplate}}
{{~htmlDecode vmTemplate~}}
{{else}}
{{tr "You can provide a VM template associated to the resource that will be created in OpenNebula"}}
{{/if}}
</pre>
</div>
</div>

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

View File

@ -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 {