mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
Feature #2778: Use new dynamic selects for clusters
This commit is contained in:
parent
ad3bdc0f71
commit
3d174e2ecc
@ -108,7 +108,8 @@ var create_acl_tmpl =
|
||||
</div>\
|
||||
<div class="in_cluster">\
|
||||
<label for="in_cluster">'+tr("Cluster")+':</label>\
|
||||
<select name="in_cluster" id="in_cluster"></select>\
|
||||
<div name="in_cluster" id="in_cluster">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
@ -488,7 +489,8 @@ function setupCreateAclDialog(){
|
||||
});
|
||||
|
||||
//update the rule preview every time some field changes
|
||||
$('input,select',dialog).change(function(){
|
||||
$(dialog).off('change', 'input,select');
|
||||
$(dialog).on('change', 'input,select', function(){
|
||||
var context = $('#create_acl_form',$create_acl_dialog);
|
||||
var user = $('#applies',context).val();
|
||||
|
||||
@ -517,7 +519,7 @@ function setupCreateAclDialog(){
|
||||
belonging="@"+$('#belonging_to',context).val();
|
||||
break;
|
||||
case "in_cluster":
|
||||
belonging="%"+$('#in_cluster',context).val();
|
||||
belonging="%"+$('#in_cluster .resource_list_select',context).val();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -570,7 +572,7 @@ function setupCreateAclDialog(){
|
||||
}
|
||||
break;
|
||||
case "in_cluster":
|
||||
var l=$('#in_cluster',this).val().length;
|
||||
var l=$('#in_cluster .resource_list_select',this).val().length;
|
||||
if (!l){
|
||||
notifyError("Please select a cluster to which the selected resources belong to");
|
||||
return false;
|
||||
@ -611,7 +613,7 @@ function popUpCreateAclDialog(){
|
||||
$('#applies',dialog).html('<option value="*">'+tr("All")+'</option>'+
|
||||
users.html()+groups.html());
|
||||
$('#belonging_to',dialog).html(groups_select);
|
||||
$('#in_cluster',dialog).html(clusters_select);
|
||||
insertSelectClusters('#in_cluster',dialog, null, true);
|
||||
|
||||
$('#applies',dialog).trigger("change");
|
||||
|
||||
|
@ -871,8 +871,6 @@ function updateClusterDatastoresInfoView (request,datastore_list){
|
||||
|
||||
|
||||
/* -------- End of datatables section -------- */
|
||||
|
||||
var clusters_select="";
|
||||
var dataTable_clusters;
|
||||
var $create_cluster_dialog;
|
||||
|
||||
@ -1174,32 +1172,17 @@ function clusterElementArray(element_json){
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
//updates the cluster select by refreshing the options in it
|
||||
function updateClusterSelect(){
|
||||
clusters_select = '<option value="-1">Default (none)</option>';
|
||||
clusters_select += makeSelectOptions(dataTable_clusters,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[],//status_cols
|
||||
[],//bad_st
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
//callback for an action affecting a cluster element
|
||||
function updateClusterElement(request, element_json){
|
||||
var id = element_json.CLUSTER.ID;
|
||||
var element = clusterElementArray(element_json);
|
||||
updateSingleElement(element,dataTable_clusters,'#cluster_'+id);
|
||||
updateClusterSelect();
|
||||
}
|
||||
|
||||
//callback for actions deleting a cluster element
|
||||
function deleteClusterElement(req){
|
||||
deleteElement(dataTable_clusters,'#cluster_'+req.request.data);
|
||||
$('div#cluster_tab_'+req.request.data,main_tabs_context).remove();
|
||||
updateClusterSelect();
|
||||
}
|
||||
|
||||
//call back for actions creating a cluster element
|
||||
@ -1207,7 +1190,6 @@ function addClusterElement(request,element_json){
|
||||
var id = element_json.CLUSTER.ID;
|
||||
var element = clusterElementArray(element_json);
|
||||
addElement(element,dataTable_clusters);
|
||||
updateClusterSelect();
|
||||
}
|
||||
|
||||
//callback to update the list of clusters.
|
||||
@ -1220,7 +1202,6 @@ function updateClustersView (request,list){
|
||||
});
|
||||
|
||||
updateView(list_array,dataTable_clusters);
|
||||
updateClusterSelect();
|
||||
};
|
||||
|
||||
|
||||
@ -1393,10 +1374,6 @@ function clusterResourceViewListeners(){
|
||||
});
|
||||
};
|
||||
|
||||
function clusters_sel() {
|
||||
return clusters_select;
|
||||
}
|
||||
|
||||
//This is executed after the sunstone.js ready() is run.
|
||||
//Here we can basicly init the host datatable, preload it
|
||||
//and add specific listeners
|
||||
|
@ -51,8 +51,8 @@ var create_datastore_tmpl =
|
||||
</div>\
|
||||
<div class="large-6 columns">\
|
||||
<label for="cluster">' + tr("Cluster") + '</label>\
|
||||
<select id="cluster_id" name="cluster_id">\
|
||||
</select>\
|
||||
<div id="cluster_id" name="cluster_id">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
@ -210,7 +210,8 @@ var create_datastore_tmpl =
|
||||
<div class="row">\
|
||||
<div class="columns large-6">\
|
||||
<label for="datastore_cluster_raw">'+tr("Cluster")+'</label>\
|
||||
<select id="datastore_cluster_raw" name="datastore_cluster_raw"></select>\
|
||||
<div id="datastore_cluster_raw" name="datastore_cluster_raw">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
@ -469,7 +470,7 @@ var datastore_buttons = {
|
||||
"Datastore.addtocluster" : {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Select cluster"),
|
||||
select: clusters_sel,
|
||||
select: insertSelectClusters,
|
||||
layout: "more_select",
|
||||
tip: tr("Select the destination cluster:"),
|
||||
condition: mustBeAdmin
|
||||
@ -869,7 +870,7 @@ function setupCreateDatastoreDialog(){
|
||||
$('#create_datastore_submit',dialog).click(function(){
|
||||
var context = $( "#create_datastore_form", dialog);
|
||||
var name = $('#name',context).val();
|
||||
var cluster_id = $('#cluster_id',context).val();
|
||||
var cluster_id = $(".resource_list_select", $('#cluster_id',dialog)).val();
|
||||
var ds_type = $('input[name=ds_type]:checked',context).val();
|
||||
var ds_mad = $('#ds_mad',context).val();
|
||||
ds_mad = ds_mad == "custom" ? $('input[name="ds_tab_custom_ds_mad"]').val() : ds_mad;
|
||||
@ -964,7 +965,7 @@ function setupCreateDatastoreDialog(){
|
||||
|
||||
$('#create_datastore_submit_manual',dialog).click(function(){
|
||||
var template = $('#template',dialog).val();
|
||||
var cluster_id = $('#datastore_cluster_raw',dialog).val();
|
||||
var cluster_id = $(".resource_list_select", $('#datastore_cluster_raw',dialog)).val();
|
||||
|
||||
if (!cluster_id){
|
||||
notifyError(tr("Please select a cluster for this datastore"));
|
||||
@ -1100,8 +1101,15 @@ function select_custom(){
|
||||
}
|
||||
|
||||
function popUpCreateDatastoreDialog(){
|
||||
$('select#cluster_id',$create_datastore_dialog).html(clusters_sel());
|
||||
$('select#datastore_cluster_raw',$create_datastore_dialog).html(clusters_sel());
|
||||
var cluster_id = $("div#cluster_id .resource_list_select", $create_datastore_dialog).val();
|
||||
if (!cluster_id) cluster_id = "-1";
|
||||
|
||||
var cluster_id_raw = $("div#datastore_cluster_raw .resource_list_select", $create_datastore_dialog).val();
|
||||
if (!cluster_id_raw) cluster_id_raw = "-1";
|
||||
|
||||
|
||||
insertSelectClusters('div#cluster_id', $create_datastore_dialog, cluster_id, false);
|
||||
insertSelectClusters('div#datastore_cluster_raw', $create_datastore_dialog, cluster_id_raw, false);
|
||||
$create_datastore_dialog.foundation().foundation('reveal', 'open');
|
||||
$("input#name",$create_datastore_dialog).focus();
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ var create_host_tmpl =
|
||||
</div>\
|
||||
<div class="large-6 columns" id="cluster_select">\
|
||||
<label for="host_cluster_id">' + tr("Cluster") + '</label>\
|
||||
<select id="host_cluster_id" name="host_cluster_id">\
|
||||
</select>\
|
||||
<div id="host_cluster_id" name="host_cluster_id">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<fieldset>\
|
||||
@ -298,7 +298,7 @@ var host_buttons = {
|
||||
"Host.addtocluster" : {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Select cluster"),
|
||||
select: clusters_sel,
|
||||
select: insertSelectClusters,
|
||||
tip: tr("Select the destination cluster:"),
|
||||
layout: "more_select",
|
||||
condition: mustBeAdmin
|
||||
@ -924,7 +924,7 @@ function setupCreateHostDialog(){
|
||||
return false;
|
||||
}
|
||||
|
||||
var cluster_id = $('#host_cluster_id',this).val();
|
||||
var cluster_id = $('#host_cluster_id .resource_list_select',this).val();
|
||||
if (!cluster_id) cluster_id = "-1";
|
||||
|
||||
var vmm_mad = $('select#vmm_mad',this).val();
|
||||
@ -953,11 +953,10 @@ function setupCreateHostDialog(){
|
||||
|
||||
//Open creation dialogs
|
||||
function popUpCreateHostDialog(){
|
||||
var cluster_id = $('#host_cluster_id',$('div#create_host_dialog')).val();
|
||||
var cluster_id = $('#host_cluster_id .resource_list_select',$('div#create_host_dialog')).val();
|
||||
if (!cluster_id) cluster_id = "-1";
|
||||
|
||||
$('#host_cluster_id',$('div#create_host_dialog')).html(clusters_sel());
|
||||
$('#host_cluster_id',$('div#create_host_dialog')).val(cluster_id);
|
||||
insertSelectClusters('#host_cluster_id',$('div#create_host_dialog'), cluster_id, false);
|
||||
|
||||
$('div#create_host_dialog').foundation('reveal', 'open');
|
||||
$("input#name",$('div#create_host_dialog')).focus();
|
||||
|
@ -532,7 +532,7 @@ var vnet_buttons = {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Select cluster"),
|
||||
layout: "more_select",
|
||||
select: clusters_sel,
|
||||
select: insertSelectClusters,
|
||||
tip: tr("Select the destination cluster:"),
|
||||
condition: mustBeAdmin
|
||||
},
|
||||
|
@ -869,9 +869,7 @@ function setupConfirmDialogs(){
|
||||
</div>\
|
||||
<br />\
|
||||
<div class="row">\
|
||||
<div class="large-12 columns">\
|
||||
<select id="confirm_select">\
|
||||
</select>\
|
||||
<div class="large-12 columns" id="confirm_select">\
|
||||
</div>\
|
||||
</div>\
|
||||
<br />\ <br />\
|
||||
@ -891,7 +889,7 @@ function setupConfirmDialogs(){
|
||||
var error = 0;
|
||||
var value = $(this).val();
|
||||
var action = SunstoneCfg["actions"][value];
|
||||
var param = $('select#confirm_select',context).val();
|
||||
var param = $('select.resource_list_select',context).val();
|
||||
|
||||
if (!param.length){
|
||||
notifyError("You must select a value");
|
||||
@ -961,8 +959,8 @@ function popUpConfirmWithSelectDialog(target_elem){
|
||||
else
|
||||
var tip = button.tip
|
||||
|
||||
var select_var = button.select();
|
||||
$('select#confirm_select',dialog).html(select_var);
|
||||
button.select('div#confirm_select', dialog, null, true);
|
||||
|
||||
$('div#confirm_with_select_tip',dialog).text(tip);
|
||||
|
||||
var action = SunstoneCfg["actions"][value];
|
||||
@ -1678,7 +1676,7 @@ function insertSelectOptions(id, context, resource, init_val, empty_value, extra
|
||||
|
||||
$(id, context).html(select_str);
|
||||
|
||||
$(".resource_list_select", context).val(init_val);
|
||||
$(id+" .resource_list_select", context).val(init_val);
|
||||
},
|
||||
error: onError
|
||||
});
|
||||
@ -1995,10 +1993,6 @@ function hosts_sel(){
|
||||
return hosts_select;
|
||||
}
|
||||
|
||||
function clusters_sel() {
|
||||
return clusters_select;
|
||||
}
|
||||
|
||||
function datastores_sel() {
|
||||
return datastores_select;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user