1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

F #826: Fixed Sunstone bugs (#2725)

This commit is contained in:
juanmont 2018-12-13 17:08:03 +01:00 committed by Ruben S. Montero
parent 84acc63ccd
commit 8150618b99
27 changed files with 232 additions and 80 deletions

View File

@ -796,6 +796,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -797,6 +797,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -790,6 +790,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -799,6 +799,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -797,6 +797,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -790,6 +790,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -796,6 +796,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -797,6 +797,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -790,6 +790,7 @@ tabs:
vnet_template_ar_list_tab: true
vnet_template_sg_list_tab: true
vnet_template_clusters_tab: true
vnet_template_template_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -64,7 +64,8 @@ define(function(require) {
callback: function(request, response) {
Sunstone.getDialog(CLUSTERS_DIALOG_ID).setParams({
element: response[XML_ROOT],
resource:"datastore"
resource:"datastore",
resource_name: RESOURCE
});
Sunstone.getDialog(CLUSTERS_DIALOG_ID).reset();

View File

@ -151,7 +151,8 @@ define(function(require) {
callback: function(request, response) {
Sunstone.getDialog(CLUSTERS_DIALOG_ID).setParams({
element: response[XML_ROOT],
resource:"vnet"
resource:"vnet",
resource_name: RESOURCE
});
Sunstone.getDialog(CLUSTERS_DIALOG_ID).reset();

View File

@ -73,6 +73,8 @@ define(function(require) {
that.arTab.setup(context, "add_ar");
$('#submit_ar_reset_button', context).click(function(){
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
Sunstone.getDialog(DIALOG_ID).show();
});

View File

@ -34,7 +34,8 @@ define(function(require) {
require('./vnets-templates-tab/panels/info'),
require('./vnets-templates-tab/panels/ar'),
require('./vnets-templates-tab/panels/secgroups'),
require('./vnets-templates-tab/panels/clusters')
require('./vnets-templates-tab/panels/clusters'),
require('./vnets-templates-tab/panels/templates')
];
var _panelsHooks = [

View File

@ -50,6 +50,7 @@ define(function(require) {
"VNTemplate.chgrp": _commonActions.multipleAction('chgrp'),
"VNTemplate.chmod": _commonActions.singleAction('chmod'),
"VNTemplate.rename": _commonActions.singleAction('rename'),
"VNTemplate.update" : _commonActions.update(),
"VNTemplate.update_template" : _commonActions.updateTemplate(),
"VNTemplate.append_template" : _commonActions.appendTemplate(),
"VNTemplate.update_dialog" : _commonActions.checkAndShowUpdate(),
@ -84,7 +85,7 @@ define(function(require) {
error: Notifier.onError
},
"VNTemplate.rm_ar" : {
"VNTemplate.remove_ar" : {
type: "single",
call: OpenNebulaResource.update,
callback: function(req) {
@ -102,7 +103,9 @@ define(function(require) {
callback: function(request, response) {
Sunstone.getDialog(CLUSTERS_DIALOG_ID).setParams({
element: response[XML_ROOT],
resource:"vntemplate"
resource:"vntemplate",
resource_name: RESOURCE,
only_update_template: true
});
Sunstone.getDialog(CLUSTERS_DIALOG_ID).reset();

View File

@ -41,7 +41,8 @@ define(function(require) {
"VNTemplate.addtocluster" : {
type : "action",
layout: "main",
text : Locale.tr("Select cluster")
text : Locale.tr("Select cluster"),
custom_classes: "only-sunstone-info"
},
"VNTemplate.chown" : {
type: "confirm_with_select",

View File

@ -74,6 +74,8 @@ define(function(require) {
that.arTab.setup(context, "add_ar");
$('#submit_ar_reset_button', context).click(function(){
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
Sunstone.getDialog(DIALOG_ID).show();
});

View File

@ -15,5 +15,5 @@
/* -------------------------------------------------------------------------- */
define(function(require){
return 'add_ar_dialog';
return 'vntemplate_add_ar_dialog';
});

View File

@ -74,6 +74,8 @@ define(function(require) {
that.arTab.setup(context, "add_ar");
$('#submit_ar_reset_button', context).click(function(){
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
Sunstone.getDialog(DIALOG_ID).show();
});

View File

@ -15,5 +15,5 @@
/* -------------------------------------------------------------------------- */
define(function(require){
return 'update_ar_dialog';
return 'vntemplate_update_ar_dialog';
});

View File

@ -385,9 +385,8 @@ define(function(require) {
if (this.action == "create") {
network_json = {
"vntemplate" : network_json,
"clusters": clusters
//"clusters": clusters
};
Sunstone.runAction("VNTemplate.create", network_json);
return false;
} else if (this.action == "update") {
@ -405,7 +404,8 @@ define(function(require) {
} else if (this.action == "update") {
var template_raw = $("textarea#template", context).val();
Sunstone.runAction("VNTemplate.update", this.resourceId, template_raw);
var vntemplate_json = {vntemplate: {vntemplate_raw: template}};
Sunstone.runAction("VNTemplate.update", this.resourceId, vntemplate_json);
return false;
}
}
@ -452,7 +452,7 @@ define(function(require) {
// Show all network mode inputs, and make them not required. This will change
// if a different network model is selected
$("input#bridge", context).attr("required", "");
$("input#bridge", context).removeAttr("required");
$("div.mode_param", context).show();
$("div.mode_param [wizard_field]", context).prop("wizard_field_disabled", true).removeAttr("required");

View File

@ -201,7 +201,7 @@ define(function(require) {
var sgs = template_json.VNTEMPLATE.TEMPLATE.SECURITY_GROUPS;
if (sgs) {
var selectedResources = {
ids : sgs.spli(",")
ids : sgs.split(",")
};
that.securityGroupsTable.selectResourceTableSelect(selectedResources);
}
@ -343,38 +343,25 @@ define(function(require) {
var id = that.element.ID;
var ar_id = $(this).attr('ar_id');
var element = that.element;
var ar = getAR(that.element, ar_id);
OpenNebulaNetworkTemplate.show({
data : {
id: id
},
timeout: true,
success: function (request, vn){
var vntmpl_info = vn.VNTEMPLATE;
if(ar != undefined){
Sunstone.getDialog(INSTANTIATE_UPDATE_AR_DIALOG_ID).reset();
var ar = getAR(vntmpl_info, ar_id);
Sunstone.getDialog(INSTANTIATE_UPDATE_AR_DIALOG_ID).setParams({
'vntmplId': id,
'arId': ar_id,
'element': that.element,
'arData': $.extend({}, ar),
'table': "ar_list_datatable",
'context': context
});
if(ar != undefined){
Sunstone.getDialog(INSTANTIATE_UPDATE_AR_DIALOG_ID).reset();
Sunstone.getDialog(INSTANTIATE_UPDATE_AR_DIALOG_ID).show();
Sunstone.getDialog(INSTANTIATE_UPDATE_AR_DIALOG_ID).setParams({
'vntmplId': id,
'arId': ar_id,
'element': element,
'arData': $.extend({}, ar),
'table': "ar_list_datatable",
'context': context
});
Sunstone.getDialog(INSTANTIATE_UPDATE_AR_DIALOG_ID).show();
} else {
Notifier.notifyError(Locale.tr("The Address Range was not found"));
}
},
error: Notifier.onError
});
} else {
Notifier.notifyError(Locale.tr("The Address Range was not found"));
}
return false;
});

View File

@ -17,11 +17,14 @@
<br>
<div class="template-row" element-id="{{element.ID}}">
<fieldset>
<legend>{{tr "Network Template Name"}}</legend>
<legend>{{tr "Network Template"}}</legend>
<div class="row">
<div class="medium-5 small-12 columns">
<h6>
<h5>
{{element.NAME}}<br>
</h5>
<h6>
{{element.TEMPLATE.DESCRIPTION}}<br>
</h6>
</div>
</div>

View File

@ -40,8 +40,8 @@ define(function(require) {
var RESOURCE = "VNTemplate";
var XML_ROOT = "VNTEMPLATE";
var ADD_AR_DIALOG_ID = require('tabs/vnets-tab/dialogs/add-ar/dialogId');
var UPDATE_AR_DIALOG_ID = require('tabs/vnets-tab/dialogs/update-ar/dialogId');
var ADD_AR_DIALOG_ID = require('../dialogs/add-ar/dialogId');
var UPDATE_AR_DIALOG_ID = require('../dialogs/update-ar/dialogId');
var CONFIRM_DIALOG_ID = require('utils/dialogs/generic-confirm/dialogId');
/*
@ -126,7 +126,7 @@ define(function(require) {
'tab': "vnets-templates-tab",
'action_add': "VNTemplate.add_ar",
'action_update': "VNTemplate.update_ar",
'action_rm': "VNTemplate.rm_ar"
'action_rm': "VNTemplate.remove_ar"
});
}
@ -198,7 +198,7 @@ define(function(require) {
delete that.element.TEMPLATE.AR_POOL;
Sunstone.runAction('VNTemplate.rm_ar', that.element.ID, TemplateUtils.templateToString(that.element.TEMPLATE));
Sunstone.runAction('VNTemplate.remove_ar', that.element.ID, TemplateUtils.templateToString(that.element.TEMPLATE));
return false;
}

View File

@ -0,0 +1,25 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2018, 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="row">
<div class="small-12 columns">
<pre class="template-pre monospace">
{{~templateString~}}
</pre>
</div>
</div>
</div>

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2018, 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 'vnet_template_template_tab';
});

View File

@ -0,0 +1,66 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2018, 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) {
var TemplateInfo = require('hbs!./template/html');
var Locale = require('utils/locale');
var TemplateUtils = require('utils/template-utils');
/*
CONSTANTS
*/
var TAB_ID = require('../tabId');
var PANEL_ID = require('./template/panelId');
var RESOURCE = "VNTemplate"
var XML_ROOT = "VNTEMPLATE"
/*
CONSTRUCTOR
*/
function Panel(info) {
this.tabId = TAB_ID;
this.resource = RESOURCE;
this.title = Locale.tr("Template");
this.icon = "fa-file";
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() {
return TemplateInfo({
'element': this.element,
'templateString': TemplateUtils.templateToString(this.element.TEMPLATE)
});
}
function _setup(context) {
}
});

View File

@ -22,6 +22,7 @@ define(function(require) {
var BaseDialog = require('utils/dialogs/dialog');
var ClustersTable = require('tabs/clusters-tab/datatable');
var Sunstone = require('sunstone');
var TemplateUtils = require("utils/template-utils");
/*
TEMPLATES
@ -36,6 +37,7 @@ define(function(require) {
var DIALOG_ID = require('./clusters/dialogId');
var DATASTORES_TAB_ID = require('tabs/datastores-tab/tabId');
var VNETS_TAB_ID = require('tabs/vnets-tab/tabId');
var VNTEMPLATE_TAB_ID = require('tabs/vnets-templates-tab/tabId');
/*
CONSTRUCTOR
@ -81,35 +83,37 @@ define(function(require) {
$('#' + DIALOG_ID + 'Form', dialog).submit(function() {
var selectedClustersList = that.clustersTable.retrieveResourceTableSelect();
$.each(selectedClustersList, function(index, clusterId) {
if ($.inArray(clusterId, that.originalClusterIds) === -1) {
if(that.resource == "datastore"){
Sunstone.runAction('Cluster.adddatastore', clusterId, that.element.ID);
} else {
Sunstone.runAction('Cluster.addvnet', clusterId, that.element.ID);
}
}
});
if ( that.only_update_template != undefined && that.only_update_template != true) {
$.each(that.originalClusterIds, function(index, clusterId) {
if ($.inArray(clusterId, selectedClustersList) === -1) {
if(that.resource == "datastore"){
Sunstone.runAction('Cluster.deldatastore', clusterId, that.element.ID);
} else {
Sunstone.runAction('Cluster.delvnet', clusterId, that.element.ID);
$.each(selectedClustersList, function(index, clusterId) {
if ($.inArray(clusterId, that.originalClusterIds) === -1) {
if(that.resource == "datastore"){
Sunstone.runAction('Cluster.adddatastore', clusterId, that.element.ID);
} else {
Sunstone.runAction('Cluster.addvnet', clusterId, that.element.ID);
}
}
}
});
});
$.each(that.originalClusterIds, function(index, clusterId) {
if ($.inArray(clusterId, selectedClustersList) === -1) {
if(that.resource == "datastore"){
Sunstone.runAction('Cluster.deldatastore', clusterId, that.element.ID);
} else {
Sunstone.runAction('Cluster.delvnet', clusterId, that.element.ID);
}
}
});
} else {
that.element.TEMPLATE.CLUSTER = selectedClustersList.join(",");
Sunstone.runAction(that.resource_name+".update", that.element.ID, TemplateUtils.templateToString(that.element.TEMPLATE))
}
Sunstone.getDialog(DIALOG_ID).hide();
Sunstone.getDialog(DIALOG_ID).reset();
setTimeout(function() {
if(that.resource == "datastore"){
Sunstone.runAction('Datastore.refresh');
} else {
Sunstone.runAction('Network.refresh');
}
Sunstone.runAction(that.resource_name+".refresh");
}, 1500);
return false;
@ -125,24 +129,50 @@ define(function(require) {
function _setParams(params) {
this.element = params.element;
if (this.element.CLUSTERS !== undefined && this.element.CLUSTERS.ID !== undefined) {
if ($.isArray(this.element.CLUSTERS.ID)) {
this.originalClusterIds = this.element.CLUSTERS.ID;
} else {
this.originalClusterIds = [this.element.CLUSTERS.ID];
}
} else {
this.originalClusterIds = [];
}
this.resource = params.resource;
this.resource_name = params.resource_name;
this.only_update_template = params.only_update_template;
var clusters;
if ( this.only_update_template != undefined && this.only_update_template != true ) {
clusters = this.element.CLUSTERS;
if (clusters !== undefined && clusters.ID !== undefined) {
if ($.isArray(clusters.ID)) {
this.originalClusterIds = clusters.ID;
} else {
this.originalClusterIds = [clusters.ID];
}
} else {
this.originalClusterIds = [];
}
} else {
clusters = this.element.TEMPLATE.CLUSTERS;
clusters = clusters.split(",");
if (clusters !== undefined ) {
if ($.isArray(clusters)) {
this.originalClusterIds = clusters;
} else {
this.originalClusterIds = [clusters];
}
} else {
this.originalClusterIds = [];
}
}
}
function _onShow(dialog) {
if(this.resource == "datastore"){
this.setNames( {tabId: DATASTORES_TAB_ID} );
}else{
}else if ( this.resource == "vnet" ){
this.setNames( {tabId: VNETS_TAB_ID} );
} else {
this.setNames( {tabId: VNTEMPLATE_TAB_ID} );
}
this.clustersTable.refreshResourceTableSelect();