mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Bug #2680: Rename Reset to Refresh button
Bug #2681: Query correct zone for clusters in Create Group and Add RP dialogs
This commit is contained in:
parent
f7edf6e46b
commit
2e5585f7f2
@ -75,6 +75,42 @@ class SunstoneServer < CloudServer
|
||||
end
|
||||
end
|
||||
|
||||
############################################################################
|
||||
#
|
||||
############################################################################
|
||||
def get_pool_in_zone(kind,gid,client)
|
||||
if gid == "0"
|
||||
user_flag = Pool::INFO_ALL
|
||||
else
|
||||
user_flag = POOL_FILTER
|
||||
end
|
||||
|
||||
pool = case kind
|
||||
when "group" then GroupPoolJSON.new(client)
|
||||
when "cluster" then ClusterPoolJSON.new(client)
|
||||
when "host" then HostPoolJSON.new(client)
|
||||
when "image" then ImagePoolJSON.new(client, user_flag)
|
||||
when "vmtemplate" then TemplatePoolJSON.new(client, user_flag)
|
||||
when "vm" then VirtualMachinePoolJSON.new(client, user_flag)
|
||||
when "vnet" then VirtualNetworkPoolJSON.new(client, user_flag)
|
||||
when "user" then UserPoolJSON.new(client)
|
||||
when "acl" then AclPoolJSON.new(client)
|
||||
when "datastore" then DatastorePoolJSON.new(client)
|
||||
when "zone" then ZonePoolJSON.new(client)
|
||||
else
|
||||
error = Error.new("Error: #{kind} resource not supported")
|
||||
return [404, error.to_json]
|
||||
end
|
||||
|
||||
rc = pool.get_hash
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
return [500, rc.to_json]
|
||||
else
|
||||
return [200, rc.to_json]
|
||||
end
|
||||
end
|
||||
|
||||
############################################################################
|
||||
#
|
||||
############################################################################
|
||||
|
@ -367,6 +367,31 @@ var OpenNebula = {
|
||||
});
|
||||
},
|
||||
|
||||
"list_in_zone": function(params, resource, path){
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var timeout = params.timeout || false;
|
||||
var request = OpenNebula.Helper.request(resource,"list");
|
||||
var req_path = path ? path : resource.toLowerCase();
|
||||
|
||||
$.ajax({
|
||||
url: req_path,
|
||||
type: "GET",
|
||||
data: {timeout: timeout, zone_id: params.data.zone_id},
|
||||
dataType: "json",
|
||||
success: function(response){
|
||||
var list = OpenNebula.Helper.pool(resource,response)
|
||||
return callback ?
|
||||
callback(request, list) : null;
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
return callback_error ?
|
||||
callback_error(request, OpenNebula.Error(response)) : null;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//Subresource examples: "fetch_template", "log"...
|
||||
"show": function(params, resource, subresource, path){
|
||||
var callback = params.success;
|
||||
@ -1175,6 +1200,9 @@ var OpenNebula = {
|
||||
"list" : function(params){
|
||||
OpenNebula.Action.list(params,OpenNebula.Cluster.resource);
|
||||
},
|
||||
"list_in_zone" : function(params){
|
||||
OpenNebula.Action.list_in_zone(params,OpenNebula.Cluster.resource);
|
||||
},
|
||||
"show" : function(params){
|
||||
OpenNebula.Action.show(params,OpenNebula.Cluster.resource);
|
||||
},
|
||||
|
@ -206,7 +206,7 @@ var create_group_tmpl =
|
||||
<hr>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button radius right success" id="create_group_submit" value="Group.create">'+tr("Create")+'</button>\
|
||||
<button class="button secondary radius" id="create_group_reset_button" type="reset" value="reset">'+tr("Reset")+'</button>\
|
||||
<button class="button secondary radius" id="create_group_reset_button" type="reset" value="reset">'+tr("Refresh")+'</button>\
|
||||
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
|
||||
</div>\
|
||||
</div>\
|
||||
@ -919,10 +919,6 @@ function setup_add_rp_dialog(group_id){
|
||||
$.each(obj_list,function(){
|
||||
add_resource_tab(this.ZONE.ID, this.ZONE.NAME, dialog, "add_rp");
|
||||
});
|
||||
|
||||
if (obj_list.length == 0){
|
||||
add_resource_tab(0, "Local Zone", dialog, "add_rp");
|
||||
}
|
||||
},
|
||||
error: onError
|
||||
});
|
||||
@ -959,7 +955,7 @@ function setup_group_resource_tab_content(zone_id, zone_section, str_zone_tab_id
|
||||
});
|
||||
|
||||
// Retrieve the clusters to fill the datatable
|
||||
update_datatable_group_clusters(dataTable_group_clusters);
|
||||
update_datatable_group_clusters(dataTable_group_clusters, zone_id);
|
||||
|
||||
$('#'+str_zone_tab_id+'_search', zone_section).keyup(function(){
|
||||
dataTable_group_clusters.fnFilter( $(this).val() );
|
||||
@ -1027,7 +1023,7 @@ function setup_group_resource_tab_content(zone_id, zone_section, str_zone_tab_id
|
||||
setupTips(zone_section);
|
||||
}
|
||||
|
||||
function generate_group_resource_tab_content(str_zone_tab_id, str_datatable_id){
|
||||
function generate_group_resource_tab_content(str_zone_tab_id, str_datatable_id, zone_id){
|
||||
var html =
|
||||
'<div class="row">\
|
||||
<div class="four columns">\
|
||||
@ -1079,20 +1075,17 @@ function generate_group_resource_tab_content(str_zone_tab_id, str_datatable_id){
|
||||
|
||||
$("#refresh_group_clusters_table_button_class"+str_zone_tab_id).die();
|
||||
$("#refresh_group_clusters_table_button_class"+str_zone_tab_id).live('click', function(){
|
||||
update_datatable_group_clusters($('table[id='+str_datatable_id+']').dataTable());
|
||||
update_datatable_group_clusters($('table[id='+str_datatable_id+']').dataTable(), zone_id);
|
||||
});
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
// TODO: Refactor? same function in templates-tab.js
|
||||
function update_datatable_group_clusters(datatable, fnDrawCallback) {
|
||||
if (fnDrawCallback) {
|
||||
datatable.unbind('draw');
|
||||
datatable.on('draw', fnDrawCallback);
|
||||
}
|
||||
function update_datatable_group_clusters(datatable, zone_id) {
|
||||
|
||||
OpenNebula.Cluster.list({
|
||||
OpenNebula.Cluster.list_in_zone({
|
||||
data:{zone_id:zone_id},
|
||||
timeout: true,
|
||||
success: function (request, obj_list){
|
||||
var obj_list_array = [];
|
||||
@ -1103,8 +1096,7 @@ function update_datatable_group_clusters(datatable, fnDrawCallback) {
|
||||
});
|
||||
|
||||
updateView(obj_list_array, datatable);
|
||||
},
|
||||
error: onError
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1127,7 +1119,7 @@ var add_resource_tab = function(zone_id, zone_name, dialog, id_suffix) {
|
||||
|
||||
// Append the new div containing the tab and add the tab to the list
|
||||
var html_tab_content = '<li id="'+str_zone_tab_id+'Tab" style="display: block;">'+
|
||||
generate_group_resource_tab_content(str_zone_tab_id, str_datatable_id) +
|
||||
generate_group_resource_tab_content(str_zone_tab_id, str_datatable_id, zone_id) +
|
||||
'</li>'
|
||||
$(html_tab_content).appendTo($("ul#group_zones_tabs_content", dialog));
|
||||
|
||||
|
@ -405,9 +405,23 @@ end
|
||||
# GET Pool information
|
||||
##############################################################################
|
||||
get '/:pool' do
|
||||
|
||||
if params[:zone_id]
|
||||
zone = OpenNebula::Zone.new_with_id(params[:zone_id].to_i,
|
||||
$cloud_auth.client(session[:user]))
|
||||
rc = zone.info
|
||||
return [500, rc.message] if OpenNebula.is_error?(rc)
|
||||
zone_client = $cloud_auth.client(session[:user],
|
||||
zone['TEMPLATE/ENDPOINT'])
|
||||
@SunstoneServer.get_pool_in_zone(params[:pool],
|
||||
session[:user_gid],
|
||||
zone_client)
|
||||
else
|
||||
@SunstoneServer.get_pool(params[:pool], session[:user_gid])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# GET Resource information
|
||||
##############################################################################
|
||||
|
@ -58,7 +58,7 @@
|
||||
'view' : view,
|
||||
'available_views' : available_views,
|
||||
'display_name' : '<%= session[:display_name] %>',
|
||||
'zone_name' : '<%= session[:zone_name] ? session[:zone_name] : "Local Zone" %>'
|
||||
'zone_name' : '<%= session[:zone_name] %>'
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user