mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-19 06:50:07 +03:00
Improve getSelectedNodes and refresh info button
This commit is contained in:
parent
84ff4d3daa
commit
ce010c75e0
@ -937,8 +937,13 @@ var cluster_actions = {
|
||||
"Cluster.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
var tab = dataTable_clusters.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Cluster.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_clusters);
|
||||
Sunstone.runAction("Cluster.list");
|
||||
}
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
@ -1069,8 +1074,7 @@ var cluster_buttons = {
|
||||
"Cluster.update_dialog" : {
|
||||
type : "action",
|
||||
layout: "main",
|
||||
text : tr("Update"),
|
||||
alwaysActive: true
|
||||
text : tr("Update")
|
||||
},
|
||||
"Cluster.delete" : {
|
||||
type: "confirm",
|
||||
|
@ -365,8 +365,13 @@ var datastore_actions = {
|
||||
"Datastore.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
var tab = dataTable_datastores.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Datastore.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_datastores);
|
||||
Sunstone.runAction("Datastore.list");
|
||||
}
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
@ -170,8 +170,13 @@ var file_actions = {
|
||||
"File.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
var tab = dataTable_files.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("File.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_files);
|
||||
Sunstone.runAction("File.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -228,8 +228,13 @@ var group_actions = {
|
||||
"Group.refresh" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
var tab = dataTable_groups.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Group.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_groups);
|
||||
Sunstone.runAction("Group.list");
|
||||
}
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
@ -177,8 +177,13 @@ var host_actions = {
|
||||
"Host.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
var tab = dataTable_hosts.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Host.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_hosts);
|
||||
Sunstone.runAction("Host.list");
|
||||
}
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
@ -251,41 +256,6 @@ var host_actions = {
|
||||
},
|
||||
error: hostMonitorError
|
||||
},
|
||||
/*
|
||||
"Host.pool_monitor" : {
|
||||
type: "monitor_global",
|
||||
call : OpenNebula.Host.pool_monitor,
|
||||
callback: function(req,response) {
|
||||
var host_dashboard_graphs = [
|
||||
{
|
||||
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU",
|
||||
labels : tr("Allocated")+","+tr("Real")+","+tr("Total"),
|
||||
humanize_figures : false,
|
||||
div_graph : $("#dash_host_cpu_graph", $dashboard)
|
||||
//div_legend : $("#dash_host_cpu_legend", $dashboard)
|
||||
},
|
||||
{
|
||||
monitor_resources : "HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM",
|
||||
labels : tr("Allocated")+","+tr("Real")+","+tr("Total"),
|
||||
humanize_figures : true,
|
||||
div_graph : $("#dash_host_mem_graph", $dashboard)
|
||||
}
|
||||
];
|
||||
|
||||
for(var i=0; i<host_dashboard_graphs.length; i++) {
|
||||
plot_totals(
|
||||
response,
|
||||
host_dashboard_graphs[i]
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: refresh individual info panel graphs with this new data?
|
||||
},
|
||||
|
||||
// TODO: ignore error, or set message similar to hostMonitorError?
|
||||
error: onError
|
||||
},
|
||||
*/
|
||||
"Host.update_template" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Host.update,
|
||||
|
@ -276,8 +276,13 @@ var image_actions = {
|
||||
"Image.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
var tab = dataTable_images.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Image.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_images);
|
||||
Sunstone.runAction("Image.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -32,8 +32,13 @@ var market_actions = {
|
||||
"Marketplace.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
var tab = dataTable_marketplace.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Marketplace.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_marketplace);
|
||||
Sunstone.runAction('Marketplace.list');
|
||||
Sunstone.runAction("Marketplace.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
"Marketplace.import" : {
|
||||
|
@ -911,8 +911,13 @@ var service_actions = {
|
||||
"Service.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
var tab = dataTable_services.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Service.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_services);
|
||||
Sunstone.runAction("Service.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -449,8 +449,13 @@ var service_template_actions = {
|
||||
"ServiceTemplate.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
var tab = dataTable_service_templates.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("ServiceTemplate.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_service_templates);
|
||||
Sunstone.runAction("ServiceTemplate.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -270,8 +270,13 @@ var template_actions = {
|
||||
"Template.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
var tab = dataTable_templates.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Template.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_templates);
|
||||
Sunstone.runAction("Template.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -537,9 +542,6 @@ Sunstone.addInfoPanel('template_info_panel',template_info_panel);
|
||||
|
||||
//Returns selected elements in the template table
|
||||
function templateElements(){
|
||||
if (Sunstone.rightInfoVisible($('#templates-tab'))) {
|
||||
return [Sunstone.rightInfoResourceId($('#templates-tab'))];
|
||||
}
|
||||
return getSelectedNodes(dataTable_templates);
|
||||
}
|
||||
|
||||
|
@ -285,8 +285,13 @@ var user_actions = {
|
||||
"User.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
var tab = dataTable_users.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("User.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_users);
|
||||
Sunstone.runAction("User.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -553,9 +558,6 @@ Sunstone.addMainTab('users-tab',users_tab);
|
||||
Sunstone.addInfoPanel("user_info_panel",user_info_panel);
|
||||
|
||||
function userElements(){
|
||||
if (Sunstone.rightInfoVisible($('#users-tab'))) {
|
||||
return [Sunstone.rightInfoResourceId($('#users-tab'))];
|
||||
}
|
||||
return getSelectedNodes(dataTable_users);
|
||||
}
|
||||
|
||||
|
@ -442,8 +442,13 @@ var vm_actions = {
|
||||
"VM.refresh" : {
|
||||
type: "custom",
|
||||
call : function (){
|
||||
var tab = dataTable_vMachines.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("VM.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_vMachines);
|
||||
Sunstone.runAction("VM.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -1145,9 +1150,6 @@ Sunstone.addInfoPanel('vm_info_panel',vm_info_panel);
|
||||
|
||||
|
||||
function vmElements() {
|
||||
if (Sunstone.rightInfoVisible($('#vms-tab'))) {
|
||||
return [Sunstone.rightInfoResourceId($('#vms-tab'))];
|
||||
}
|
||||
return getSelectedNodes(dataTable_vMachines);
|
||||
};
|
||||
|
||||
@ -3477,12 +3479,9 @@ function setupMigrateVMDialog(live){
|
||||
//notifySubmit("Template.instantiate",template_id, extra_msg);
|
||||
|
||||
$.each(getSelectedNodes(dataTable_vMachines), function(index, elem) {
|
||||
console.log(elem)
|
||||
if (live) {
|
||||
console.log("live")
|
||||
Sunstone.runAction("VM.migrate_live_action", elem, extra_info);
|
||||
} else {
|
||||
console.log("migrate")
|
||||
Sunstone.runAction("VM.migrate_action", elem, extra_info);
|
||||
}
|
||||
});
|
||||
|
@ -467,8 +467,13 @@ var vnet_actions = {
|
||||
"Network.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
var tab = dataTable_vNetworks.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Network.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_vNetworks);
|
||||
Sunstone.runAction("Network.list");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -140,8 +140,13 @@ var zone_actions = {
|
||||
"Zone.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
var tab = dataTable_zones.parents(".tab");
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
Sunstone.runAction("Zone.showinfo", Sunstone.rightInfoResourceId(tab))
|
||||
} else {
|
||||
waitingNodes(dataTable_zones);
|
||||
Sunstone.runAction("Zone.list");
|
||||
}
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
@ -1088,7 +1088,17 @@ function deleteElement(dataTable,tag){
|
||||
//when elements in a datatable are modified.
|
||||
function recountCheckboxes(dataTable, custom_context){
|
||||
var table = $('tbody',dataTable);
|
||||
var context = custom_context||table.parents('.tab');
|
||||
|
||||
var context;
|
||||
if (custom_context){
|
||||
context = custom_context;
|
||||
} else {
|
||||
context = table.parents('.tab');
|
||||
if ($(".right-info", context).is(':visible')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var nodes = $('tr',table); //visible nodes
|
||||
var total_length = nodes.length;
|
||||
var checked_length = $('input.check_item:checked',nodes).length;
|
||||
@ -1595,11 +1605,16 @@ function setupTips(context, position){
|
||||
function getSelectedNodes(dataTable){
|
||||
var selected_nodes = [];
|
||||
if (dataTable){
|
||||
var tab = dataTable.parents(".tab")
|
||||
if (Sunstone.rightInfoVisible(tab)) {
|
||||
selected_nodes.push(Sunstone.rightInfoResourceId(tab));
|
||||
} else {
|
||||
//Which rows of the datatable are checked?
|
||||
var nodes = $('tbody input.check_item:checked',dataTable);
|
||||
$.each(nodes,function(){
|
||||
selected_nodes.push($(this).val());
|
||||
});
|
||||
$.each(nodes,function(){
|
||||
selected_nodes.push($(this).val());
|
||||
});
|
||||
}
|
||||
};
|
||||
return selected_nodes;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user