From e424cd29fd7a1efd7a9e9c8cd7af51b71ccfcb71 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 7 Dec 2012 14:32:55 +0100 Subject: [PATCH] feature #1664: Cluster tab now has info panel --- .../public/js/plugins/clusters-tab.js | 383 ++++++++++++++---- 1 file changed, 301 insertions(+), 82 deletions(-) diff --git a/src/sunstone/public/js/plugins/clusters-tab.js b/src/sunstone/public/js/plugins/clusters-tab.js index f7e0af9837..c5d628909e 100644 --- a/src/sunstone/public/js/plugins/clusters-tab.js +++ b/src/sunstone/public/js/plugins/clusters-tab.js @@ -18,6 +18,60 @@ /* ------------ Cluster creation dialog ------------ */ +var host_datatable_table_tmpl='\ + \ + ' + tr("All") + '\ + ' + tr("ID") + '\ + ' + tr("Name") + '\ + ' + tr("Cluster") + '\ + ' + tr("Running VMs") + '\ + ' + tr("Real CPU") + '\ + ' + tr("Allocated CPU") + '\ + ' + tr("Real MEM") + '\ + ' + tr("Allocated MEM") + '\ + ' + tr("Status") + '\ + ' + tr("IM MAD") + '\ + ' + tr("VM MAD") + '\ + ' + tr("Last monitored on") + '\ + \ + \ + \ + ' + +var vnet_datatable_table_tmpl='\ + \ + '+tr("All")+'\ + '+tr("ID")+'\ + '+tr("Owner")+'\ + '+tr("Group")+'\ + '+tr("Name")+'\ + '+tr("Cluster")+'\ + '+tr("Type")+'\ + '+tr("Bridge")+'\ + '+tr("Total Leases")+'\ + \ + \ + \ + ' + +var datastore_datatable_table_tmpl='\ + \ + ' + tr("All") + '\ + '+tr("ID")+'\ + '+tr("Owner")+'\ + '+tr("Group")+'\ + '+tr("Name")+'\ + '+tr("Cluster")+'\ + '+tr("Basepath")+'\ + '+tr("TM MAD")+'\ + '+tr("DS MAD")+'\ + '+tr("System")+'\ + \ + \ + \ + ' + + var create_cluster_tmpl ='
\
\ \ @@ -29,33 +83,12 @@ var create_cluster_tmpl ='
\ \
\
\ -
\ +
\

' + tr("Select Hosts for this Cluster") + '

\
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
' + tr("All") + '' + tr("ID") + '' + tr("Name") + '' + tr("Cluster") + '' + tr("Running VMs") + '' + tr("Real CPU") + '' + tr("Allocated CPU") + '' + tr("Real MEM") + '' + tr("Allocated MEM") + '' + tr("Status") + '' + tr("IM MAD") + '' + tr("VM MAD") + '' + tr("Last monitored on") + '
\ -
\ + ' + host_datatable_table_tmpl + '
\
\
\
\ @@ -64,29 +97,12 @@ var create_cluster_tmpl ='
\
\
\
\ -
\ +
\

' + tr("Select Virtual Networks for this Cluster") + '

\
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("All")+''+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Cluster")+''+tr("Type")+''+tr("Bridge")+''+tr("Total Leases")+'
\ -
\ + ' + vnet_datatable_table_tmpl + '
\
\
\
\ @@ -98,30 +114,12 @@ var create_cluster_tmpl ='
\
\
\
\ -
\ +
\

' + tr("Select Datastores for this Xluster") + '

\
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
' + tr("All") + ''+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Cluster")+''+tr("Basepath")+''+tr("TM MAD")+''+tr("DS MAD")+''+tr("System")+'
\ -
\ + ' + datastore_datatable_table_tmpl + '
\
\
\
\ @@ -459,10 +457,17 @@ var cluster_host_actions = { call: OpenNebula.Host.list, callback: updateClusterHostsView, error: onError + }, + + "ClusterHostInfo.list" : { + type: "list", + call: OpenNebula.Host.list, + callback: updateClusterHostsInfoView, + error: onError } } -//callback to update the list of hosts. +//callback to update the list of hosts for Create dialog function updateClusterHostsView (request,host_list){ var host_list_array = []; @@ -471,11 +476,22 @@ function updateClusterHostsView (request,host_list){ host_list_array.push(hostElementArray(this)); }); - updateView(host_list_array,dataTable_cluster_hosts); updateHostSelect(); } +//callback to update the list of hosts for info panel +function updateClusterHostsInfoView (request,host_list){ + var host_list_array = []; + + $.each(host_list,function(){ + if(this.HOST.CLUSTER_ID == cluster_info.ID) + host_list_array.push(hostElementArray(this)); + }); + + updateView(host_list_array,dataTable_cluster_hosts_panel); +} + //updates the host select by refreshing the options in it function updateHostSelect(){ hosts_select = makeSelectOptions(dataTable_cluster_hosts, @@ -487,9 +503,6 @@ function updateHostSelect(){ } - - - /* -------- Virtual Networks datatable -------- */ //Setup actions @@ -502,15 +515,15 @@ var cluster_vnet_actions = { error: onError }, - "ClusterVN.autorefresh" : { - type: "custom", - call: function() { - OpenNebula.Network.list({timeout: true, success: updateVNetworksView, error: onError}); - } + "ClusterVNInfo.list" : { + type: "list", + call: OpenNebula.Network.list, + callback: updateClusterVNetworksInfoView, + error: onError } } -//updates the list of virtual networks +//updates the list of virtual networks for Create dialog function updateVNetworksView(request, network_list){ var network_list_array = []; @@ -521,6 +534,18 @@ function updateVNetworksView(request, network_list){ updateView(network_list_array,dataTable_cluster_vnets); } +//callback to update the list of vnets for info panel +function updateClusterVNetworksInfoView (request,vnet_list){ + var vnet_list_array = []; + + $.each(vnet_list,function(){ + if(this.VNET.CLUSTER_ID == cluster_info.ID) + vnet_list_array.push(vNetworkElementArray(this)); + }); + + updateView(vnet_list_array,dataTable_cluster_vnets_panel); +} + /* -------- Datastores datatable -------- */ @@ -534,15 +559,15 @@ var cluster_datastore_actions = { error: onError }, - "ClusterDS.autorefresh" : { - type: "custom", - call : function() { - OpenNebula.Datastore.list({timeout: true, success: updateDatastoresView,error: onError}); - } + "ClusterDSInfo.list" : { + type: "list", + call: OpenNebula.Datastore.list, + callback: updateClusterDatastoresInfoView, + error: onError } } -//updates the list of datastores +//updates the list of datastores for Create dialog function updateDatastoresView(request, list){ var list_array = []; @@ -555,6 +580,18 @@ function updateDatastoresView(request, list){ updateInfraDashboard("datastores",list); } +//callback to update the list of datastores for info panel +function updateClusterDatastoresInfoView (request,datastore_list){ + var datastore_list_array = []; + + $.each(datastore_list,function(){ + if(this.DATASTORE.CLUSTER_ID == cluster_info.ID) + datastore_list_array.push(datastoreElementArray(this)); + }); + + updateView(datastore_list_array,dataTable_cluster_datastores_panel); +} + /* -------- End of datatables section -------- */ @@ -629,7 +666,14 @@ var cluster_actions = { "Cluster.show" : { type: "single", call: OpenNebula.Cluster.show, - callback: updateClusterElement, + callback: updateClusterInfo, + error: onError + }, + + "Cluster.showinfo" : { + type: "single", + call: OpenNebula.Cluster.show, + callback: updateClusterInfo, error: onError }, @@ -774,6 +818,27 @@ var clusters_tab = { parentTab: "infra_tab" }; +var cluster_info_panel = { + "cluster_info_tab" : { + title: tr("Cluster information"), + content:"" + }, + + "cluster_host_tab" : { + title: tr("Cluster Hosts"), + content: "" + }, + "cluster_vnet_tab" : { + title: tr("Cluster Virtual Networks"), + content: "" + }, + "cluster_datastore_tab" : { + title: tr("Cluster Datastores"), + content: "" + } + +}; + // Cluster monitoring configuration. This config controls the monitoring // which is plotted in the cluster dashboards. @@ -906,7 +971,7 @@ Sunstone.addActions(cluster_vnet_actions); Sunstone.addActions(cluster_datastore_actions); Sunstone.addActions(cluster_actions); Sunstone.addMainTab('clusters_tab',clusters_tab); -//Sunstone.addInfoPanel("host_info_panel",host_info_panel); +Sunstone.addInfoPanel("cluster_info_panel",cluster_info_panel); //return lists of selected elements in cluster list function clusterElements(){ @@ -1001,6 +1066,160 @@ function updateClustersView (request,list){ updateInfraDashboard("clusters",list); }; +// Updates the cluster info panel tab content and pops it up +function updateClusterInfo(request,cluster){ + cluster_info = cluster.CLUSTER; + + //Information tab + var info_tab = { + title : tr("Cluster information"), + content : + '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
' + tr("Cluster information") + ' - '+cluster_info.NAME+'
' + tr("id") + ''+cluster_info.ID+'
' + tr("Name") + ''+cluster_info.NAME+'
\ + \ + '+ + prettyPrintJSON(cluster_info.TEMPLATE)+ + '
' + tr("Cluster template") + '
' + } + + var cluster_host_tab = { + title: tr("Hosts"), + content : '
' + host_datatable_table_tmpl + '
' + } + + var cluster_vnet_tab = { + title: tr("Virtual Networks"), + content : '
' + vnet_datatable_table_tmpl + '
' + } + + var cluster_datastore_tab = { + title: tr("Datastores"), + content : '
' + datastore_datatable_table_tmpl + '
' + } + + //Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object); + Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_info_tab",info_tab); + Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_host_tab",cluster_host_tab); + Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_vnet_tab",cluster_vnet_tab); + Sunstone.updateInfoPanelTab("cluster_info_panel","cluster_datastore_tab",cluster_datastore_tab); + + Sunstone.popUpInfoPanel("cluster_info_panel"); + + // Hosts datatable + + dataTable_cluster_hosts_panel = $("#datatable_cluster_hosts_info_panel").dataTable({ + "bJQueryUI": true, + "bSortClasses": false, + "sDom" : '<"H"lfrC>t<"F"ip>', + "oColVis": { //exclude checkbox column + "aiExclude": [ 0 ] + }, + "bAutoWidth":false, + "sPaginationType": "full_numbers", + "aoColumnDefs": [ + { "bSortable": false, "aTargets": ["check"] }, + { "sWidth": "60px", "aTargets": [0,4] }, + { "sWidth": "35px", "aTargets": [1] }, + { "sWidth": "100px", "aTargets": [9,3,10,11,12] }, + { "sWidth": "150", "aTargets": [5,6,7,8] }, + { "bVisible": false, "aTargets": [0,3,5,6,7,8,10,11,12]} + ], + "oLanguage": (datatable_lang != "") ? + { + sUrl: "locale/"+lang+"/"+datatable_lang + } : "" + }); + + //preload it + dataTable_cluster_hosts_panel.fnClearTable(); + + addElement([ + spinner, + '','','','','','','','','','','',''],dataTable_cluster_hosts_panel); + + // Virtual networks datatable + + dataTable_cluster_vnets_panel = $("#datatable_cluster_vnets_info_panel", dialog).dataTable({ + "bJQueryUI": true, + "bSortClasses": false, + "bAutoWidth":false, + "sDom" : '<"H"lfrC>t<"F"ip>', + "oColVis": { + "aiExclude": [ 0 ] + }, + "sPaginationType": "full_numbers", + "aoColumnDefs": [ + { "bSortable": false, "aTargets": ["check"] }, + { "sWidth": "60px", "aTargets": [0,6,7,8] }, + { "sWidth": "35px", "aTargets": [1] }, + { "sWidth": "100px", "aTargets": [2,3,5] }, + { "bVisible": false, "aTargets": [0,5,7]} + ], + "oLanguage": (datatable_lang != "") ? + { + sUrl: "locale/"+lang+"/"+datatable_lang + } : "" + }); + + + //preload it + dataTable_cluster_vnets_panel.fnClearTable(); + addElement([ + spinner, + '','','','','','','','','','','',''],dataTable_cluster_vnets_panel); + + // Datastores datatable + + dataTable_cluster_datastores_panel = $("#datatable_cluster_datastores_info_panel", dialog).dataTable({ + "bJQueryUI": true, + "bSortClasses": false, + "sDom" : '<"H"lfrC>t<"F"ip>', + "oColVis": { + "aiExclude": [ 0 ] + }, + "sPaginationType": "full_numbers", + "bAutoWidth":false, + "aoColumnDefs": [ + { "bSortable": false, "aTargets": ["check"] }, + { "sWidth": "60px", "aTargets": [0] }, + { "sWidth": "35px", "aTargets": [1,9] }, + { "sWidth": "100px", "aTargets": [2,3,5,7,8] }, + { "bVisible": false, "aTargets": [0,5,6,7,8,9] } + ], + "oLanguage": (datatable_lang != "") ? + { + sUrl: "locale/"+lang+"/"+datatable_lang + } : "" + }); + + + //preload it + dataTable_cluster_datastores_panel.fnClearTable(); + addElement([ + spinner, + '','','','','','','','','','','',''],dataTable_cluster_datastores_panel); + + // initializa datatables values + + Sunstone.runAction("ClusterHostInfo.list"); + Sunstone.runAction("ClusterVNInfo.list"); + Sunstone.runAction("ClusterDSInfo.list"); +} + + //generates the HTML for the dashboard of a specific cluster function clusterTabContent(cluster_json) { var cluster = cluster_json.CLUSTER; @@ -1415,6 +1634,6 @@ $(document).ready(function(){ initCheckAllBoxes(dataTable_clusters); tableCheckboxesListener(dataTable_clusters); - infoListener(dataTable_clusters); + infoListener(dataTable_clusters, "Cluster.showinfo"); });