mirror of
https://github.com/sismics/docs.git
synced 2024-11-15 18:57:56 +01:00
Alert in navigation bar if there is a new error in logs
This commit is contained in:
parent
a858699391
commit
62a5840777
@ -1,2 +1 @@
|
||||
- Check regulary for > INFO logs (client)
|
||||
- Show number of files on documents list (client/server)
|
@ -110,6 +110,7 @@ public class AppResource extends BaseResource {
|
||||
throw new ForbiddenClientException();
|
||||
}
|
||||
checkBaseFunction(BaseFunction.ADMIN);
|
||||
// TODO Change level by minLevel (returns all logs above)
|
||||
|
||||
// Get the memory appender
|
||||
Logger logger = Logger.getRootLogger();
|
||||
|
@ -5,7 +5,42 @@
|
||||
*/
|
||||
App.controller('Navigation', function($scope, $http, $state, $rootScope, User, Restangular) {
|
||||
$rootScope.userInfo = User.userInfo();
|
||||
|
||||
|
||||
// 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({
|
||||
limit: 100,
|
||||
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();
|
||||
});
|
||||
})
|
||||
}, 10000);
|
||||
|
||||
/**
|
||||
* Navigate to error logs.
|
||||
*/
|
||||
$scope.openLogs = function() {
|
||||
$scope.errorNumber = 0;
|
||||
$state.transitionTo('settings.log');
|
||||
};
|
||||
|
||||
/**
|
||||
* User logout.
|
||||
*/
|
||||
@ -16,7 +51,10 @@ App.controller('Navigation', function($scope, $http, $state, $rootScope, User, R
|
||||
});
|
||||
$event.preventDefault();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if at least an asynchronous request is in progress.
|
||||
*/
|
||||
$scope.isLoading = function() {
|
||||
return $http.pendingRequests.length > 0;
|
||||
};
|
||||
|
@ -72,6 +72,11 @@
|
||||
</ul>
|
||||
|
||||
<ul class="nav pull-right" ng-show="!userInfo.anonymous">
|
||||
<li ng-show="errorNumber > 0">
|
||||
<a href="#/settings/log" ng-click="openLogs()" class="nav-text-error">
|
||||
<span class="icon-warning-sign"></span> {{ errorNumber }} new error{{ errorNumber > 1 ? 's' : '' }}
|
||||
</a>
|
||||
</li>
|
||||
<li ng-class="{active: $uiRoute}" ui-route="/settings.*"><a href="#/settings/account"><span class="icon-cog"></span><span class="hidden-phone"> Settings</span></a></li>
|
||||
<li><a href="#" ng-click="logout($event)"><span class="icon-off"></span><span class="hidden-phone"> Logout</span></a></li>
|
||||
</ul>
|
||||
|
@ -133,4 +133,8 @@ input[readonly].share-link {
|
||||
ul > li {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-text-error {
|
||||
color: #b94a48 !important;
|
||||
}
|
Loading…
Reference in New Issue
Block a user