Merge pull request #914 from nclsHart/webui-ongoing-alert-counter

[Web UI] display ongoing alert counter in favicon
This commit is contained in:
Nicolas Hennion
2016-09-11 11:24:00 +02:00
committed by GitHub
7 changed files with 45 additions and 16 deletions

View File

@@ -4,6 +4,7 @@
"dependencies": {
"angular": "^1.5.8",
"angular-route": "^1.5.8",
"lodash": "^4.13.1"
"lodash": "^4.13.1",
"favico.js": "^0.3.10"
}
}

View File

@@ -0,0 +1,14 @@
glancesApp.service('favicoService', function() {
var favico = new Favico({
animation : 'none'
});
this.badge = function(nb) {
favico.badge(nb);
};
this.reset = function() {
favico.reset();
};
});

View File

@@ -5,7 +5,7 @@ glancesApp.service('GlancesStats', function($http, $injector, $q, GlancesPlugin)
'alert': 'GlancesPluginAlert',
'cpu': 'GlancesPluginCpu',
'diskio': 'GlancesPluginDiskio',
'irq' : 'GlancesPluginIrq',
'irq' : 'GlancesPluginIrq',
'docker': 'GlancesPluginDocker',
'ip': 'GlancesPluginIp',
'fs': 'GlancesPluginFs',

View File

@@ -29,7 +29,7 @@ glancesApp.service('GlancesPluginAlert', function () {
, minutes = parseInt((duration / (1000 * 60)) % 60)
, hours = parseInt((duration / (1000 * 60 * 60)) % 24);
alert.duration = _.padLeft(hours, 2, '0') + ":" + _.padLeft(minutes, 2, '0') + ":" + _.padLeft(seconds, 2, '0');
alert.duration = _.padStart(hours, 2, '0') + ":" + _.padStart(minutes, 2, '0') + ":" + _.padStart(seconds, 2, '0');
}
_alerts.push(alert);
@@ -47,4 +47,12 @@ glancesApp.service('GlancesPluginAlert', function () {
this.count = function () {
return _alerts.length;
};
this.hasOngoingAlerts = function () {
return _.filter(_alerts, { 'ongoing': true }).length > 0;
};
this.countOngoingAlerts = function () {
return _.filter(_alerts, { 'ongoing': true }).length;
}
});

View File

@@ -1,4 +1,4 @@
glancesApp.controller('statsController', function ($scope, $rootScope, $interval, GlancesStats, help, arguments) {
glancesApp.controller('statsController', function ($scope, $rootScope, $interval, GlancesStats, help, arguments, favicoService) {
$scope.help = help;
$scope.arguments = arguments;
@@ -24,7 +24,7 @@ glancesApp.controller('statsController', function ($scope, $rootScope, $interval
$scope.statsAlert = GlancesStats.getPlugin('alert');
$scope.statsCpu = GlancesStats.getPlugin('cpu');
$scope.statsDiskio = GlancesStats.getPlugin('diskio');
$scope.statsIrq = GlancesStats.getPlugin('irq');
$scope.statsIrq = GlancesStats.getPlugin('irq');
$scope.statsDocker = GlancesStats.getPlugin('docker');
$scope.statsFs = GlancesStats.getPlugin('fs');
$scope.statsFolders = GlancesStats.getPlugin('folders');
@@ -46,6 +46,12 @@ glancesApp.controller('statsController', function ($scope, $rootScope, $interval
$rootScope.title = $scope.statsSystem.hostname + ' - Glances';
if ($scope.statsAlert.hasOngoingAlerts()) {
favicoService.badge($scope.statsAlert.countOngoingAlerts());
} else {
favicoService.reset();
}
$scope.is_disconnected = false;
$scope.dataLoaded = true;
}, function() {
@@ -104,8 +110,8 @@ glancesApp.controller('statsController', function ($scope, $rootScope, $interval
// d => Show/hide disk I/O stats
$scope.arguments.disable_diskio = !$scope.arguments.disable_diskio;
break;
case $event.shiftKey && $event.keyCode == keycodes.Q:
// R => Show/hide IRQ
case $event.shiftKey && $event.keyCode == keycodes.Q:
// Q => Show/hide IRQ
$scope.arguments.disable_irq = !$scope.arguments.disable_irq;
break;
case !$event.shiftKey && $event.keyCode == keycodes.f:

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long