Calculated total stats in frontend

This commit is contained in:
utkarshcmu 2016-02-02 11:50:01 -08:00
parent 00a6efa15e
commit c6ab63ec47
2 changed files with 53 additions and 0 deletions

View File

@ -57,6 +57,7 @@ function (angular, $, config, moment) {
dashboardKeybindings.shortcuts($scope);
$scope.evaluateTotalStats();
$scope.updateSubmenuVisibility();
$scope.setWindowTitleAndTheme();
@ -67,6 +68,25 @@ function (angular, $, config, moment) {
});
};
$scope.evaluateTotalStats = function() {
$scope.dashboard.totalRows = 0;
$scope.dashboard.totalPanels = 0;
$scope.dashboard.totalQueries = 0;
if ($scope.dashboard.rows) {
$scope.dashboard.totalRows = $scope.dashboard.rows.length;
for (var i=0; i<$scope.dashboard.rows.length; i++) {
if ($scope.dashboard.rows[i].panels) {
$scope.dashboard.totalPanels += $scope.dashboard.rows[i].panels.length;
for (var j=0; j<$scope.dashboard.rows[i].panels.length; j++) {
if ($scope.dashboard.rows[i].panels[j].targets) {
$scope.dashboard.totalQueries += $scope.dashboard.rows[i].panels[j].targets.length;
}
}
}
}
}
};
$scope.updateSubmenuVisibility = function() {
$scope.submenuEnabled = $scope.dashboard.isSubmenuFeaturesEnabled();
};

View File

@ -164,6 +164,39 @@
</div>
</div>
<div class="pull-left tight-form">
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 120px">
Total Rows:
</li>
<li class="tight-form-item" style="width: 180px">
{{dashboard.totalRows}}
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 120px">
Total Panels:
</li>
<li class="tight-form-item" style="width: 180px">
{{dashboard.totalPanels}}
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 120px">
Total Queries:
</li>
<li class="tight-form-item" style="width: 180px">
{{dashboard.totalQueries}}
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 120px">