From b99eef1be545da7b01af1e84a1692ab65050f248 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 5 Mar 2013 17:55:47 +0100 Subject: [PATCH] feature #1664: Update dashboard --- src/sunstone/public/css/app.css | 14 +++- .../public/js/plugins/dashboard-tab.js | 68 +++++++++++-------- src/sunstone/public/js/plugins/groups-tab.js | 22 ++++-- src/sunstone/public/js/plugins/hosts-tab.js | 64 ++++++++++++++--- src/sunstone/public/js/plugins/images-tab.js | 23 ++++++- src/sunstone/public/js/plugins/users-tab.js | 25 +++++-- src/sunstone/public/js/plugins/vms-tab.js | 54 ++++++++++++++- src/sunstone/public/js/plugins/vnets-tab.js | 22 +++++- src/sunstone/public/js/sunstone-util.js | 20 ++++++ src/sunstone/public/sass/app.scss | 10 ++- 10 files changed, 263 insertions(+), 59 deletions(-) diff --git a/src/sunstone/public/css/app.css b/src/sunstone/public/css/app.css index ccbc70b0af..8d39872dc0 100644 --- a/src/sunstone/public/css/app.css +++ b/src/sunstone/public/css/app.css @@ -6585,7 +6585,7 @@ form.creation { } /* line 606, ../sass/app.scss */ -.dashboard h1.subheader { +.dashboard h2.subheader { margin-bottom: 0; margin-top: 0; } @@ -6596,11 +6596,21 @@ form.creation { } /* line 615, ../sass/app.scss */ +.dashboard h3.subheader { + margin-top: 0; +} + +/* line 619, ../sass/app.scss */ ul.button-group { margin-bottom: 0; } -/* line 619, ../sass/app.scss */ +/* line 623, ../sass/app.scss */ .value_td { text-overflow: ellipsis; } + +/* line 627, ../sass/app.scss */ +small { + color: #b6b6b6 !important; +} diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index 478de159cd..de375ab701 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -192,17 +192,21 @@ var dashboard_tab_content = '\

'+tr("Hosts")+'

\ \
\ -
\ -

112

\ -
'+tr("TOTAL")+'
\ +
\ +

\ +

'+tr("TOTAL")+'

\
\ -
\ -

90

\ -
'+tr("ON")+'
\ +
\ +

\ +

'+tr("ON")+'

\
\ -
\ -

22

\ -
'+tr("ERROR")+'
\ +
\ +

\ +

'+tr("OFF")+'

\ +
\ +
\ +

\ +

'+tr("ERROR")+'

\
\
\
\ @@ -213,17 +217,21 @@ var dashboard_tab_content = '\

'+tr("Virtual Machines")+'

\
\
\ -
\ -

112

\ -
'+tr("TOTAL")+'
\ +
\ +

\ +

'+tr("TOTAL")+'

\
\ -
\ -

90

\ -
'+tr("ACTIVE")+'
\ +
\ +

\ +

'+tr("ACTIVE")+'

\
\ -
\ -

22

\ -
'+tr("FAILED")+'
\ +
\ +

\ +

'+tr("PENDING")+'

\ +
\ +
\ +

\ +

'+tr("FAILED")+'

\
\
\
\ @@ -237,12 +245,12 @@ var dashboard_tab_content = '\
\
\
\ -

1254

\ -
'+tr("IMAGES")+'
\ +

\ +

'+tr("IMAGES")+'

\
\
\ -

7 TB

\ -
'+tr("SIZE")+'
\ +

\ +

'+tr("SIZE")+'

\
\
\
\ @@ -254,12 +262,12 @@ var dashboard_tab_content = '\
\
\
\ -

8343

\ -
'+tr("USERS")+'
\ +

\ +

'+tr("USERS")+'

\
\
\ -

297

\ -
'+tr("GROUPS")+'
\ +

297

\ +

'+tr("GROUPS")+'

\
\
\ \ @@ -271,12 +279,12 @@ var dashboard_tab_content = '\ \
\
\ -

50

\ -
'+tr("VNETS")+'
\ +

\ +

'+tr("VNETS")+'

\
\
\ -

1243

\ -
'+tr("ADDRESSES")+'
\ +

\ +

'+tr("ADDRESSES")+'

\
\
\ \ diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index 4ac5d2d915..8285731979 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -42,9 +42,16 @@ var groups_tab_content = '\
\
\
\ -
\ +
\

'+tr("Groups")+'

\
\ +
\ +
\ +
\ +

'+tr("TOTAL")+'

\ +
\ +
\ +
\
\
\
\ @@ -448,9 +455,16 @@ function updateGroupsView(request, group_list){ }); updateView(group_list_array,dataTable_groups); updateGroupSelect(group_list); - SunstoneMonitoring.monitor('GROUP', group_list) - if (mustBeAdmin()) - updateSystemDashboard("groups",group_list); + //SunstoneMonitoring.monitor('GROUP', group_list) + //if (mustBeAdmin()) + // updateSystemDashboard("groups",group_list); + + + $("#total_groups", $dashboard).text(group_list.length); + + var form = $("#group_form"); + + $("#total_groups", form).text(group_list.length); } function updateGroupInfo(request,group){ diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 9491e41d1b..518c833a19 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -40,9 +40,16 @@ var hosts_tab_content = '\ \
\
\ -
\ +
\

'+tr("Hosts")+'

\
\ +
\ +
\ +
\ +

'+tr("TOTAL")+'  '+tr("ON")+'  '+tr("OFF")+'  '+tr("ERROR")+'

\ +
\ +
\ +
\
\
\
\ @@ -641,6 +648,24 @@ function hostElementArray(host_json){ var info_str = humanize_size(real_mem) + ' / ' + humanize_size(max_mem) + ' (' + ratio_real_mem + '%)'; var pb_real_mem = quotaBarHtml(real_mem, max_mem, info_str); + var state_simple = OpenNebula.Helper.resource_state("host_simple",host.STATE); + switch (state_simple) { + case tr("INIT"): + case tr("UPDATE"): + case tr("ON"): + on_hosts++; + break; + case tr("ERROR"): + case tr("RETRY"): + error_hosts++; + break; + case tr("OFF"): + off_hosts++; + break; + default: + break; + } + return [ '', host.ID, @@ -651,7 +676,7 @@ function hostElementArray(host_json){ pb_allocated_cpu, pb_real_mem, pb_allocated_mem, - OpenNebula.Helper.resource_state("host_simple",host.STATE), + state_simple, host.IM_MAD, host.VM_MAD, pretty_time(host.LAST_MON_TIME) @@ -694,21 +719,40 @@ function addHostElement(request,host_json){ function updateHostsView (request,host_list){ var host_list_array = []; + on_hosts = 0; + off_hosts = 0; + error_hosts = 0; + $.each(host_list,function(){ //Grab table data from the host_list host_list_array.push(hostElementArray(this)); }); - SunstoneMonitoring.monitor('HOST', host_list) - - //if clusters_sel is there, it means the clusters have arrived. - //Otherwise do not attempt to monitor them. - if (typeof(monitorClusters) != 'undefined' && clusters_sel()) - monitorClusters(host_list) updateView(host_list_array,dataTable_hosts); updateHostSelect(); + + $("#total_hosts", $dashboard).text(host_list.length); + $("#on_hosts", $dashboard).text(on_hosts); + $("#off_hosts", $dashboard).text(off_hosts); + $("#error_hosts", $dashboard).text(error_hosts); + + var form_hosts = $("#form_hosts"); + + $("#total_hosts", form_hosts).text(host_list.length); + $("#on_hosts", form_hosts).text(on_hosts); + $("#off_hosts", form_hosts).text(off_hosts); + $("#error_hosts", form_hosts).text(error_hosts); + + + //SunstoneMonitoring.monitor('HOST', host_list) +// + ////if clusters_sel is there, it means the clusters have arrived. + ////Otherwise do not attempt to monitor them. + //if (typeof(monitorClusters) != 'undefined' && clusters_sel()) + // monitorClusters(host_list) + //dependency with the dashboard plugin - updateInfraDashboard("hosts",host_list); + //updateInfraDashboard("hosts",host_list); } //Updates the host info panel tab content and pops it up @@ -942,7 +986,7 @@ $(document).ready(function(){ }); $('#hosts_search').keyup(function(){ - dataTable_templates.fnFilter( $(this).val() ); + dataTable_hosts.fnFilter( $(this).val() ); }) //preload it diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index d254a1a274..5e32935ddc 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -20,9 +20,16 @@ var images_tab_content = '\ \
\
\ -
\ +
\

'+tr("Images")+'

\
\ +
\ +
\ +
\ +

'+tr("TOTAL")+'  '+tr("SIZE")+'

\ +
\ +
\ +
\
\
\
\ @@ -571,6 +578,8 @@ function imageElementArray(image_json){ //Changing this? It may affect to the is_persistent() functions. var image = image_json.IMAGE; + size_images = size_images + parseInt(image.SIZE); + //add also persistent/non-persistent selects, type select. return [ '', @@ -611,12 +620,24 @@ function addImageElement(request, image_json){ function updateImagesView(request, images_list){ var image_list_array = []; + size_images = 0; + $.each(images_list,function(){ image_list_array.push(imageElementArray(this)); }); updateView(image_list_array,dataTable_images); updateVResDashboard("images",images_list); + + var size = humanize_size_from_mb(size_images) + + $("#total_images", $dashboard).text(images_list.length); + $("#size_images", $dashboard).text(size); + + var form = $("#image_form"); + + $("#total_images", form).text(images_list.length); + $("#size_images", form).text(size); } // Callback to update the information panel tabs and pop it up diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index 89997e3f18..ff66e7defd 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -45,9 +45,16 @@ var users_tab_content = '\ \
\
\ -
\ +
\

'+tr("Users")+'

\
\ +
\ +
\ +
\ +

'+tr("TOTAL")+'

\ +
\ +
\ +
\
\
\
\ @@ -599,15 +606,21 @@ function updateUsersView(request,users_list){ var user_list_array = []; $.each(users_list,function(){ - if (this.USER.ID == uid) - dashboardQuotasHTML(this.USER); + //if (this.USER.ID == uid) + // dashboardQuotasHTML(this.USER); user_list_array.push(userElementArray(this)); }); updateView(user_list_array,dataTable_users); - SunstoneMonitoring.monitor('USER', users_list) - if (mustBeAdmin()) - updateSystemDashboard("users",users_list); + //SunstoneMonitoring.monitor('USER', users_list) + //if (mustBeAdmin()) + // updateSystemDashboard("users",users_list); updateUserSelect(); + + $("#total_users", $dashboard).text(users_list.length); + + var form = $("#user_form"); + + $("#total_users", form).text(users_list.length); }; function updateUserInfo(request,user){ diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index d3e70f1a8a..1b0a7762ec 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -64,9 +64,16 @@ var vms_tab_content = '\ \
\
\ -
\ +
\

'+tr("Virtual Machines")+'

\
\ +
\ +
\ +
\ +

'+tr("TOTAL")+'  '+tr("ACTIVE")+'  '+tr("OFF")+'  '+tr("PENDING")+'  '+tr("FAILED")+'

\ +
\ +
\ +
\
\
\
\ @@ -829,10 +836,33 @@ function vMachineElementArray(vm_json){ }; }; + + switch (state) { + case tr("INIT"): + case tr("PENDING"): + case tr("HOLD"): + pending_vms++; + break; + case tr("FAILED"): + failed_vms++; + break; + case tr("ACTIVE"): + active_vms++; + break; + case tr("STOPPED"): + case tr("SUSPENDED"): + case tr("POWEROFF"): + off_vms++; + break; + default: + break; + } + if (state == tr("ACTIVE")) { state = OpenNebula.Helper.resource_state("vm_lcm",vm.LCM_STATE); }; + return [ '', vm.ID, @@ -879,13 +909,31 @@ function addVMachineElement(request,vm_json){ function updateVMachinesView(request, vmachine_list){ var vmachine_list_array = []; + active_vms = 0; + pending_vms = 0; + failed_vms = 0; + off_vms = 0; + $.each(vmachine_list,function(){ vmachine_list_array.push( vMachineElementArray(this)); }); updateView(vmachine_list_array,dataTable_vMachines); - SunstoneMonitoring.monitor('VM', vmachine_list) - updateVResDashboard("vms",vmachine_list); + //SunstoneMonitoring.monitor('VM', vmachine_list) + //updateVResDashboard("vms",vmachine_list); + + $("#total_vms", $dashboard).text(vmachine_list.length); + $("#active_vms", $dashboard).text(active_vms); + $("#pending_vms", $dashboard).text(pending_vms); + $("#failed_vms", $dashboard).text(failed_vms); + + var form = $("#virtualMachine_list"); + + $("#total_vms", form).text(vmachine_list.length); + $("#active_vms", form).text(active_vms); + $("#pending_vms", form).text(pending_vms); + $("#failed_vms", form).text(failed_vms); + $("#off_vms", form).text(off_vms); }; diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index 7fcf623b98..86825fe855 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -20,9 +20,16 @@ var vnets_tab_content = '\ \
\
\ -
\ +
\

'+tr("Virtual Networks")+'

\
\ +
\ +
\ +
\ +

'+tr("TOTAL")+'  '+tr("ADDRESSES")+'

\ +
\ +
\ +
\
\
\
\ @@ -672,6 +679,8 @@ function vnShow(req){ function vNetworkElementArray(vn_json){ var network = vn_json.VNET; + addresses_vnets = addresses_vnets + parseInt(network.TOTAL_LEASES); + return [ '', network.ID, @@ -711,14 +720,23 @@ function addVNetworkElement(request,vn_json){ function updateVNetworksView(request, network_list){ var network_list_array = []; + addresses_vnets = 0; + $.each(network_list,function(){ network_list_array.push(vNetworkElementArray(this)); }); updateView(network_list_array,dataTable_vNetworks); //dependency with dashboard - updateInfraDashboard("vnets",network_list); + //updateInfraDashboard("vnets",network_list); + $("#total_vnets", $dashboard).text(network_list.length); + $("#addresses_vnets", $dashboard).text(addresses_vnets); + + var form = $("#virtualNetworks_form"); + + $("#total_vnets", form).text(network_list.length); + $("#addresses_vnets", form).text(addresses_vnets); } //updates the information panel tabs and pops the panel up diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index db33accb2a..502e742a3b 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -104,6 +104,26 @@ function humanize_size(value,from_bytes) { return st; } +function humanize_size_from_mb(value) { + if (typeof(value) === "undefined") { + value = 0; + } + var binarySufix = ["MB", "GB", "TB" ]; + var i=0; + while (value > 1024 && i < 3){ + value = value / 1024; + i++; + } + value = Math.round(value * 10) / 10; + + if (value - Math.round(value) == 0) { + value = Math.round(value); + } + + var st = value + binarySufix[i]; + return st; +} + //Wrapper to add an element to a dataTable function addElement(element,dataTable){ dataTable.fnAddData(element); diff --git a/src/sunstone/public/sass/app.scss b/src/sunstone/public/sass/app.scss index f8b8f8f1b7..ddef4c3fe6 100644 --- a/src/sunstone/public/sass/app.scss +++ b/src/sunstone/public/sass/app.scss @@ -603,7 +603,7 @@ form.creation { text-align: center; } -.dashboard h1.subheader { +.dashboard h2.subheader { margin-bottom: 0; margin-top: 0; } @@ -612,10 +612,18 @@ form.creation { margin-top: 0; } +.dashboard h3.subheader { + margin-top: 0; +} + ul.button-group { margin-bottom: 0; } .value_td { text-overflow:ellipsis; +} + +small { + color: rgb(182, 182, 182) !important; } \ No newline at end of file