mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 15:17:57 +01:00
stop polling for errors
This commit is contained in:
parent
6c99de1e89
commit
e5f85c931c
@ -3,47 +3,11 @@
|
|||||||
/**
|
/**
|
||||||
* Navigation controller.
|
* Navigation controller.
|
||||||
*/
|
*/
|
||||||
angular.module('docs').controller('Navigation', function($scope, $state, $rootScope, User, Restangular) {
|
angular.module('docs').controller('Navigation', function($scope, $state, $rootScope, User) {
|
||||||
User.userInfo().then(function(data) {
|
User.userInfo().then(function(data) {
|
||||||
$rootScope.userInfo = data;
|
$rootScope.userInfo = data;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Last time when the errors logs was checked
|
|
||||||
$scope.lastLogCheck = new Date().getTime();
|
|
||||||
|
|
||||||
// Number of errors logs
|
|
||||||
$scope.errorNumber = 0;
|
|
||||||
|
|
||||||
// Check repeatedly if there is a new error log
|
|
||||||
setInterval(function() {
|
|
||||||
$scope.$apply(function() {
|
|
||||||
Restangular.one('app/log').get({
|
|
||||||
// Error count will be wrong if there is more than 10 errors in 60 seconds
|
|
||||||
limit: 10,
|
|
||||||
level: 'ERROR'
|
|
||||||
}).then(function(data) {
|
|
||||||
// Add new errors
|
|
||||||
$scope.errorNumber += _.reduce(data.logs, function(number, log) {
|
|
||||||
if (log.date > $scope.lastLogCheck) {
|
|
||||||
return ++number; // It's a new error
|
|
||||||
}
|
|
||||||
return number; // Not a new error
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// Update last check timestamp
|
|
||||||
$scope.lastLogCheck = new Date().getTime();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}, 60000);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Navigate to error logs.
|
|
||||||
*/
|
|
||||||
$scope.openLogs = function() {
|
|
||||||
$scope.errorNumber = 0;
|
|
||||||
$state.go('settings.log');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User logout.
|
* User logout.
|
||||||
*/
|
*/
|
||||||
|
@ -139,12 +139,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul class="nav navbar-nav navbar-right" ng-show="!userInfo.anonymous">
|
<ul class="nav navbar-nav navbar-right" ng-show="!userInfo.anonymous">
|
||||||
<li ng-show="errorNumber > 0">
|
|
||||||
<a href="#/settings/log" ng-click="openLogs()" class="nav-text-error">
|
|
||||||
<span class="fas fa-exclamation-triangle"></span>
|
|
||||||
<span translate="index.error_info" translate-values="{ count: errorNumber }"></span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ userInfo.username == 'guest' ? '#/user/guest' : '#/settings/account' }}"
|
<a href="{{ userInfo.username == 'guest' ? '#/user/guest' : '#/settings/account' }}"
|
||||||
translate-attr="{ title: 'index.logged_as' }" translate-values="{ username: userInfo.username }">
|
translate-attr="{ title: 'index.logged_as' }" translate-values="{ username: userInfo.username }">
|
||||||
|
Loading…
Reference in New Issue
Block a user