From b9e9f9660f1bc463e782c81d09698e3c3861089e Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Mon, 24 Jul 2017 16:13:44 +0200 Subject: [PATCH] Added subheader in all resource-tab (#414) * Added total ACLs * Added total Zones * Added total Clusters * Added total Security Groups * Added total MarketPlaceApps * Added total MarketPlaces * Added total Files * Added total Images * Added total Datastores * Added total VRouters * Added total Templates * Added total Virtual Routers --- src/sunstone/public/app/tabs/acls-tab.js | 4 ++- .../public/app/tabs/acls-tab/datatable.js | 14 +++++++++++ src/sunstone/public/app/tabs/clusters-tab.js | 4 ++- .../public/app/tabs/clusters-tab/datatable.js | 14 +++++++++++ .../public/app/tabs/datastores-tab.js | 4 ++- .../app/tabs/datastores-tab/datatable.js | 25 +++++++++++++++++++ src/sunstone/public/app/tabs/files-tab.js | 4 ++- .../public/app/tabs/files-tab/datatable.js | 12 +++++++++ src/sunstone/public/app/tabs/images-tab.js | 3 ++- .../public/app/tabs/marketplaceapps-tab.js | 4 ++- .../app/tabs/marketplaceapps-tab/datatable.js | 14 +++++++++++ .../public/app/tabs/marketplaces-tab.js | 4 ++- .../app/tabs/marketplaces-tab/datatable.js | 13 ++++++++++ src/sunstone/public/app/tabs/secgroups-tab.js | 4 ++- .../app/tabs/secgroups-tab/datatable.js | 13 ++++++++++ src/sunstone/public/app/tabs/templates-tab.js | 4 ++- .../app/tabs/templates-tab/datatable.js | 13 ++++++++++ .../public/app/tabs/vrouter-templates-tab.js | 4 ++- .../tabs/vrouter-templates-tab/datatable.js | 13 ++++++++++ src/sunstone/public/app/tabs/vrouters-tab.js | 4 ++- .../public/app/tabs/vrouters-tab/datatable.js | 13 ++++++++++ src/sunstone/public/app/tabs/zones-tab.js | 4 ++- .../public/app/tabs/zones-tab/datatable.js | 14 +++++++++++ 23 files changed, 193 insertions(+), 12 deletions(-) diff --git a/src/sunstone/public/app/tabs/acls-tab.js b/src/sunstone/public/app/tabs/acls-tab.js index 8aab1829f7..0fc6acf447 100644 --- a/src/sunstone/public/app/tabs/acls-tab.js +++ b/src/sunstone/public/app/tabs/acls-tab.js @@ -40,7 +40,9 @@ define(function(require) { tabClass: "subTab", parentTab: "system-top-tab", listHeader: Locale.tr("Access Control Lists"), - subheader: ' ', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'Acl', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/acls-tab/datatable.js b/src/sunstone/public/app/tabs/acls-tab/datatable.js index ebf74a99f0..20582f92aa 100644 --- a/src/sunstone/public/app/tabs/acls-tab/datatable.js +++ b/src/sunstone/public/app/tabs/acls-tab/datatable.js @@ -57,6 +57,8 @@ define(function(require) { ] }; + this.totalACLs = 0; + this.columns = [ Locale.tr("ID"), Locale.tr("Applies to"), @@ -82,6 +84,8 @@ define(function(require) { Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -96,6 +100,8 @@ define(function(require) { var acl_array = _parseAclString(acl_string); + this.totalACLs++; + return [ '  ', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'Cluster', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/clusters-tab/datatable.js b/src/sunstone/public/app/tabs/clusters-tab/datatable.js index a0cfe9b52b..efcdc9c13b 100644 --- a/src/sunstone/public/app/tabs/clusters-tab/datatable.js +++ b/src/sunstone/public/app/tabs/clusters-tab/datatable.js @@ -76,12 +76,16 @@ define(function(require) { "you_selected_multiple": Locale.tr("You selected the following clusters:") }; + this.totalClusters = 0; + TabDataTable.call(this); } Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -91,6 +95,7 @@ define(function(require) { function _elementArray(element_json) { var element = element_json[XML_ROOT]; + this.totalClusters++; return [ ' '+Locale.tr("TOTAL")+' \ + '+Locale.tr("ON")+' \ + '+Locale.tr("OFF")+'', resource: 'Datastore', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/datastores-tab/datatable.js b/src/sunstone/public/app/tabs/datastores-tab/datatable.js index 554089c206..3f3f6e45af 100644 --- a/src/sunstone/public/app/tabs/datastores-tab/datatable.js +++ b/src/sunstone/public/app/tabs/datastores-tab/datatable.js @@ -106,12 +106,18 @@ define(function(require) { this.conf.searchDropdownHTML = SearchDropdown({tableId: this.dataTableId}); this.searchColumn = SEARCH_COLUMN; + this.totalDSs = 0; + this.totalON = 0; + this.totalOFF = 0; + TabDataTable.call(this); }; Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -121,6 +127,7 @@ define(function(require) { function _elementArray(element_json) { var element = element_json.DATASTORE; + this.totalDSs++; var clusters = '-'; if (element.CLUSTERS.ID != undefined){ @@ -129,6 +136,12 @@ define(function(require) { var state = OpenNebulaDatastore.stateStr(element.STATE); + if(state == "ON"){ + this.totalON++; + } else if(state == "OFF"){ + this.totalOFF++; + } + var search = { NAME: element.NAME, UNAME: element.UNAME, @@ -157,4 +170,16 @@ define(function(require) { btoa(unescape(encodeURIComponent(JSON.stringify(search)))) ]; } + + function _preUpdateView() { + this.totalDSs = 0; + this.totalON = 0; + this.totalOFF = 0; + } + + function _postUpdateView() { + $(".total_ds").text(this.totalDSs); + $(".total_on").text(this.totalON); + $(".total_off").text(this.totalOFF); + } }); diff --git a/src/sunstone/public/app/tabs/files-tab.js b/src/sunstone/public/app/tabs/files-tab.js index f98d97648c..0f6b574e1f 100644 --- a/src/sunstone/public/app/tabs/files-tab.js +++ b/src/sunstone/public/app/tabs/files-tab.js @@ -45,7 +45,9 @@ define(function(require) { parentTab: "storage-top-tab", listHeader: Locale.tr("Files"), infoHeader: Locale.tr("File"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'File', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/files-tab/datatable.js b/src/sunstone/public/app/tabs/files-tab/datatable.js index 1a728c1627..6b15a147d4 100644 --- a/src/sunstone/public/app/tabs/files-tab/datatable.js +++ b/src/sunstone/public/app/tabs/files-tab/datatable.js @@ -47,12 +47,15 @@ define(function(require) { "you_selected_multiple": Locale.tr("You selected the following files:") }; + this.totalFiles = 0; ImageCommonDataTable.call(this, RESOURCE, TAB_NAME, dataTableId, conf); }; Table.prototype = Object.create(ImageCommonDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -69,6 +72,15 @@ define(function(require) { return false; } + this.totalFiles++; return this.elementArrayCommon(element_json); } + + function _preUpdateView() { + this.totalFiles = 0; + } + + function _postUpdateView() { + $(".total_files").text(this.totalFiles); + } }); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/images-tab.js b/src/sunstone/public/app/tabs/images-tab.js index ef326fa65f..464d8d907e 100644 --- a/src/sunstone/public/app/tabs/images-tab.js +++ b/src/sunstone/public/app/tabs/images-tab.js @@ -50,7 +50,8 @@ define(function(require) { parentTab: "storage-top-tab", listHeader: Locale.tr("Images"), infoHeader: Locale.tr("Image"), - subheader: '', + subheader: ' '+Locale.tr("TOTAL")+' \ + '+Locale.tr("TOTAL SIZE")+'', resource: 'Image', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab.js b/src/sunstone/public/app/tabs/marketplaceapps-tab.js index 46570bf808..3b89870050 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab.js @@ -52,7 +52,9 @@ define(function(require) { parentTab: "storage-top-tab", listHeader: Locale.tr("Apps"), infoHeader: Locale.tr("App"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'MarketPlaceApp', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/datatable.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/datatable.js index 7e145bf86e..445e18c4aa 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/datatable.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/datatable.js @@ -106,6 +106,8 @@ define(function(require) { "you_selected_multiple": Locale.tr("You selected the following appliances:") } + this.totalApps = 0; + this.conf.searchDropdownHTML = SearchDropdown({tableId: this.dataTableId}); this.searchColumn = SEARCH_COLUMN; @@ -115,6 +117,8 @@ define(function(require) { Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -128,6 +132,8 @@ define(function(require) { var state = OpenNebulaMarketPlaceApp.stateStr(element.STATE); var zone = OpenNebulaZone.getName(element.ZONE_ID); + this.totalApps++; + var search = { NAME: element.NAME, UNAME: element.UNAME, @@ -168,4 +174,12 @@ define(function(require) { return l; } + + function _preUpdateView() { + this.totalApps = 0; + } + + function _postUpdateView() { + $(".total_apps").text(this.totalApps); + } }); diff --git a/src/sunstone/public/app/tabs/marketplaces-tab.js b/src/sunstone/public/app/tabs/marketplaces-tab.js index 9bb60ad9f9..98773d41a7 100644 --- a/src/sunstone/public/app/tabs/marketplaces-tab.js +++ b/src/sunstone/public/app/tabs/marketplaces-tab.js @@ -51,7 +51,9 @@ define(function(require) { parentTab: "storage-top-tab", listHeader: Locale.tr("MarketPlaces"), infoHeader: Locale.tr("MarketPlace"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'MarketPlace', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/marketplaces-tab/datatable.js b/src/sunstone/public/app/tabs/marketplaces-tab/datatable.js index 697a05de00..2ae1176186 100644 --- a/src/sunstone/public/app/tabs/marketplaces-tab/datatable.js +++ b/src/sunstone/public/app/tabs/marketplaces-tab/datatable.js @@ -104,12 +104,16 @@ define(function(require) { this.conf.searchDropdownHTML = SearchDropdown({tableId: this.dataTableId}); this.searchColumn = SEARCH_COLUMN; + this.totalMarkets = 0; + TabDataTable.call(this); }; Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -119,6 +123,7 @@ define(function(require) { function _elementArray(element_json) { var element = element_json[XML_ROOT]; + this.totalMarkets++; var zone = OpenNebulaZone.getName(element.ZONE_ID); @@ -156,4 +161,12 @@ define(function(require) { return l; } + + function _preUpdateView() { + this.totalMarkets = 0; + } + + function _postUpdateView() { + $(".total_markets").text(this.totalMarkets); + } }); diff --git a/src/sunstone/public/app/tabs/secgroups-tab.js b/src/sunstone/public/app/tabs/secgroups-tab.js index f1995e67b5..682944597c 100644 --- a/src/sunstone/public/app/tabs/secgroups-tab.js +++ b/src/sunstone/public/app/tabs/secgroups-tab.js @@ -48,7 +48,9 @@ define(function(require) { parentTab: "network-top-tab", listHeader: Locale.tr("Security Groups"), infoHeader: Locale.tr("Security Group"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'SecurityGroup', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/secgroups-tab/datatable.js b/src/sunstone/public/app/tabs/secgroups-tab/datatable.js index 72cc1baf42..3d556bddd8 100644 --- a/src/sunstone/public/app/tabs/secgroups-tab/datatable.js +++ b/src/sunstone/public/app/tabs/secgroups-tab/datatable.js @@ -78,6 +78,8 @@ define(function(require) { "you_selected_multiple": Locale.tr("You selected the following security groups:") }; + this.totalSecGroups = 0; + this.conf.searchDropdownHTML = SearchDropdown({tableId: this.dataTableId}); this.searchColumn = SEARCH_COLUMN; @@ -87,6 +89,8 @@ define(function(require) { Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -96,6 +100,7 @@ define(function(require) { function _elementArray(element_json) { var element = element_json[XML_ROOT]; + this.totalSecGroups++; var search = { NAME: element.NAME, @@ -115,4 +120,12 @@ define(function(require) { btoa(unescape(encodeURIComponent(JSON.stringify(search)))) ]; } + + function _preUpdateView() { + this.totalSecGroups = 0; + } + + function _postUpdateView() { + $(".total_secgroups").text(this.totalSecGroups); + } }); diff --git a/src/sunstone/public/app/tabs/templates-tab.js b/src/sunstone/public/app/tabs/templates-tab.js index de66524bfc..986694b0d3 100644 --- a/src/sunstone/public/app/tabs/templates-tab.js +++ b/src/sunstone/public/app/tabs/templates-tab.js @@ -50,7 +50,9 @@ define(function(require) { parentTab: "templates-top-tab", listHeader: Locale.tr("VM Templates"), infoHeader: Locale.tr("VM Template"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'Template', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/templates-tab/datatable.js b/src/sunstone/public/app/tabs/templates-tab/datatable.js index d66aecd846..e195bb6709 100644 --- a/src/sunstone/public/app/tabs/templates-tab/datatable.js +++ b/src/sunstone/public/app/tabs/templates-tab/datatable.js @@ -34,11 +34,14 @@ define(function(require) { function Table(dataTableId, conf) { CommonDataTable.call(this, RESOURCE, TAB_NAME, dataTableId, conf); + this.totalTemplates = 0; }; Table.prototype = Object.create(CommonDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -55,6 +58,16 @@ define(function(require) { return false; } + this.totalTemplates++; + return this.elementArrayCommon(element_json); } + + function _preUpdateView() { + this.totalTemplates = 0; + } + + function _postUpdateView() { + $(".total_templates").text(this.totalTemplates); + } }); diff --git a/src/sunstone/public/app/tabs/vrouter-templates-tab.js b/src/sunstone/public/app/tabs/vrouter-templates-tab.js index fc70ead3de..6a901988b9 100644 --- a/src/sunstone/public/app/tabs/vrouter-templates-tab.js +++ b/src/sunstone/public/app/tabs/vrouter-templates-tab.js @@ -48,7 +48,9 @@ define(function(require) { parentTab: "templates-top-tab", listHeader: Locale.tr("Virtual Router VM Templates"), infoHeader: Locale.tr("Virtual Router VM Template"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'VirtualRouterTemplate', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/vrouter-templates-tab/datatable.js b/src/sunstone/public/app/tabs/vrouter-templates-tab/datatable.js index e25c2d13a3..dc9c10c931 100644 --- a/src/sunstone/public/app/tabs/vrouter-templates-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vrouter-templates-tab/datatable.js @@ -34,11 +34,14 @@ define(function(require) { function Table(dataTableId, conf) { CommonDataTable.call(this, RESOURCE, TAB_NAME, dataTableId, conf); + this.totalVRouters = 0; }; Table.prototype = Object.create(CommonDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -55,6 +58,16 @@ define(function(require) { return false; } + this.totalVRouters++; + return this.elementArrayCommon(element_json); } + + function _preUpdateView() { + this.totalVRouters = 0; + } + + function _postUpdateView() { + $(".total_vrouters").text(this.totalVRouters); + } }); diff --git a/src/sunstone/public/app/tabs/vrouters-tab.js b/src/sunstone/public/app/tabs/vrouters-tab.js index b59efbc9da..beb6e76713 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab.js +++ b/src/sunstone/public/app/tabs/vrouters-tab.js @@ -49,7 +49,9 @@ define(function(require) { parentTab: "instances-top-tab", listHeader: Locale.tr("Virtual Routers"), infoHeader: Locale.tr("Virtual Router"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'VirtualRouter', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/vrouters-tab/datatable.js b/src/sunstone/public/app/tabs/vrouters-tab/datatable.js index 7a289d10f7..59b2175aa7 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/datatable.js @@ -78,6 +78,8 @@ define(function(require) { "you_selected_multiple": Locale.tr("You selected the following virtual routers:") }; + this.totalRouters = 0; + this.conf.searchDropdownHTML = SearchDropdown({tableId: this.dataTableId}); this.searchColumn = SEARCH_COLUMN; @@ -87,6 +89,8 @@ define(function(require) { Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -96,6 +100,7 @@ define(function(require) { function _elementArray(element_json) { var element = element_json[XML_ROOT]; + this.totalRouters++; var search = { NAME: element.NAME, @@ -115,4 +120,12 @@ define(function(require) { btoa(unescape(encodeURIComponent(JSON.stringify(search)))) ]; } + + function _preUpdateView() { + this.totalRouters = 0; + } + + function _postUpdateView() { + $(".total_routers").text(this.totalRouters); + } }); diff --git a/src/sunstone/public/app/tabs/zones-tab.js b/src/sunstone/public/app/tabs/zones-tab.js index a17d7c0026..787629a40f 100644 --- a/src/sunstone/public/app/tabs/zones-tab.js +++ b/src/sunstone/public/app/tabs/zones-tab.js @@ -43,7 +43,9 @@ define(function(require) { parentTab: "infrastructure-top-tab", listHeader: Locale.tr("Zones"), infoHeader: Locale.tr("Zone"), - subheader: '', + subheader: '\ + '+Locale.tr("TOTAL")+'\ + ', resource: 'Zone', buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/zones-tab/datatable.js b/src/sunstone/public/app/tabs/zones-tab/datatable.js index 6b239b23a5..8233a91038 100644 --- a/src/sunstone/public/app/tabs/zones-tab/datatable.js +++ b/src/sunstone/public/app/tabs/zones-tab/datatable.js @@ -74,12 +74,16 @@ define(function(require) { "you_selected_multiple": Locale.tr("You selected the following Zones:") }; + this.totalZones = 0; + TabDataTable.call(this); }; Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -89,6 +93,7 @@ define(function(require) { function _elementArray(element_json) { var element = element_json.ZONE; + this.totalZones++; return [ '