mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Feature #3748: Oneflow template info panel
This commit is contained in:
parent
19ed2a1c4b
commit
4fc4c34be0
@ -13,7 +13,7 @@ define(function(require) {
|
||||
];
|
||||
|
||||
var _panels = [
|
||||
//require('./oneflow-templates-tab/panels/info'),
|
||||
require('./oneflow-templates-tab/panels/info'),
|
||||
//require('./oneflow-templates-tab/panels/roles')
|
||||
];
|
||||
|
||||
|
@ -0,0 +1,95 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var Locale = require('utils/locale');
|
||||
var PermissionsTable = require('utils/panel/permissions-table');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
*/
|
||||
|
||||
var TemplateHTML = require('hbs!./info/html');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var TAB_ID = require('../tabId');
|
||||
var PANEL_ID = require('./info/panelId');
|
||||
var XML_ROOT = "DOCUMENT";
|
||||
var RESOURCE = "ServiceTemplate";
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Panel(info) {
|
||||
this.title = Locale.tr("Info");
|
||||
this.icon = "fa-info-circle";
|
||||
|
||||
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 that = this;
|
||||
|
||||
var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element);
|
||||
|
||||
var customAttrs = [];
|
||||
|
||||
$.each(this.element.TEMPLATE.BODY['custom_attrs'], function(key, attr){
|
||||
var parts = attr.split("|");
|
||||
// 0 mandatory; 1 type; 2 desc;
|
||||
|
||||
var roles_using_net = [];
|
||||
|
||||
switch (parts[1]) {
|
||||
case "vnet_id":
|
||||
$.each(that.element.TEMPLATE.BODY.roles, function(index, value){
|
||||
if (value.vm_template_contents){
|
||||
var reg = new RegExp("\\$"+TemplateUtils.htmlDecode(key)+"\\b");
|
||||
|
||||
if(reg.exec(value.vm_template_contents) != null){
|
||||
roles_using_net.push(value.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
customAttrs.push({
|
||||
"name": key,
|
||||
"mandatory": parts[0],
|
||||
"type": parts[1],
|
||||
"description": parts[2],
|
||||
"roles": roles_using_net.join(", ")
|
||||
});
|
||||
});
|
||||
|
||||
return TemplateHTML({
|
||||
'element': this.element,
|
||||
'permissionsTableHTML': permissionsTableHTML,
|
||||
'customAttrs': customAttrs
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
|
||||
}
|
||||
});
|
@ -0,0 +1,65 @@
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<table class="dataTable extended_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">{{tr "Information"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "ID"}}</td>
|
||||
<td class="value_td" colspan="2">{{element.ID}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Name"}}</td>
|
||||
<td class="value_td" colspan="2">{{element.NAME}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Description"}}</td>
|
||||
<td class="value_td" colspan="2">{{element.TEMPLATE.BODY.description}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Strategy"}}</td>
|
||||
<td class="value_td">{{element.TEMPLATE.BODY.deployment}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Shutdown action"}}</td>
|
||||
<td class="value_td">
|
||||
{{valOrDefault element.TEMPLATE.BODY.shutdown_action "-"}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Ready Status Gate"}}</td>
|
||||
<td class="value_td">
|
||||
{{#if element.TEMPLATE.BODY.ready_status_gate}}
|
||||
{{tr "yes"}}
|
||||
{{else}}
|
||||
{{tr "no"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{#if customAttrs}}
|
||||
<table id="info_template_table" class="dataTable extended_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">{{tr "Network Configuration"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{#each customAttrs}}
|
||||
<tr>
|
||||
<td class="key_td">{{name}}</td>
|
||||
<td class="value_td">{{description}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td"></td>
|
||||
<td class="value_td">{{tr "Roles"}}: {{roles}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="large-6 columns">{{{permissionsTableHTML}}}</div>
|
||||
</div>
|
@ -0,0 +1,3 @@
|
||||
define(function(require){
|
||||
return 'service_template_info_tab';
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user