diff --git a/src/sunstone/public/app/tabs/dashboard-tab/vms.hbs b/src/sunstone/public/app/tabs/dashboard-tab/vms.hbs new file mode 100644 index 0000000000..e2a35b5b29 --- /dev/null +++ b/src/sunstone/public/app/tabs/dashboard-tab/vms.hbs @@ -0,0 +1,58 @@ +
+ \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vms-tab/datatable.js b/src/sunstone/public/app/tabs/vms-tab/datatable.js index 5993c246dd..c24bdc92b0 100644 --- a/src/sunstone/public/app/tabs/vms-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vms-tab/datatable.js @@ -71,14 +71,21 @@ define(function(require) { "you_selected_multiple": Locale.tr("You selected the following VMs:") }; + this.totalVms = 0; + this.activeVms = 0; + this.pendingVms = 0; + this.failedVms = 0; + this.offVms = 0; + TabDataTable.call(this); }; Table.prototype = Object.create(TabDataTable.prototype); Table.prototype.constructor = Table; Table.prototype.elementArray = _elementArray; - Table.prototype.onUpdateView = _onUpdateView; Table.prototype.initialize = _initialize; + Table.prototype.preUpdateView = _preUpdateView; + Table.prototype.postUpdateView = _postUpdateView; return Table; @@ -91,27 +98,27 @@ define(function(require) { var state = OpenNebulaVM.stateStr(element.STATE); - /* TODO + this.totalVms++; switch (state) { - case tr("INIT"): - case tr("PENDING"): - case tr("HOLD"): - pending_vms++; + case "INIT": + case "PENDING": + case "HOLD": + this.pendingVms++; break; - case tr("FAILED"): - failed_vms++; + case "FAILED": + this.failedVms++; break; - case tr("ACTIVE"): - active_vms++; + case "ACTIVE": + this.activeVms++; break; - case tr("STOPPED"): - case tr("SUSPENDED"): - case tr("POWEROFF"): - off_vms++; + case "STOPPED": + case "SUSPENDED": + case "POWEROFF": + this.offVms++; break; default: break; - }*/ + } if (state == "ACTIVE") { state = OpenNebulaVM.shortLcmStateStr(element.LCM_STATE); @@ -146,8 +153,22 @@ define(function(require) { ]; } - function _onUpdateView() { + function _preUpdateView() { StateActions.resetStateButtons(); + + this.totalVms = 0; + this.activeVms = 0; + this.pendingVms = 0; + this.failedVms = 0; + this.offVms = 0; + } + + function _postUpdateView() { + $(".total_vms").text(this.totalVms); + $(".active_vms").text(this.activeVms); + $(".pending_vms").text(this.pendingVms); + $(".failed_vms").text(this.failedVms); + $(".off_vms").text(this.offVms); } function _initialize(opts) { diff --git a/src/sunstone/public/app/utils/accounting.js b/src/sunstone/public/app/utils/accounting.js index 0267277449..0a01f4c775 100644 --- a/src/sunstone/public/app/utils/accounting.js +++ b/src/sunstone/public/app/utils/accounting.js @@ -625,6 +625,7 @@ define(function(require) { return { 'html': _html, - 'setup': _setup + 'setup': _setup, + 'fillAccounting': _fillAccounting }; });