提交 ba9db27b 编写于 作者: N Nicolas Hennion 提交者: GitHub

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

[Web UI] display ongoing alert counter in favicon
......@@ -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"
}
}
glancesApp.service('favicoService', function() {
var favico = new Favico({
animation : 'none'
});
this.badge = function(nb) {
favico.badge(nb);
};
this.reset = function() {
favico.reset();
};
});
......@@ -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',
......
......@@ -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;
}
});
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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册