Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Wait for previous journal request to finish before sending new request
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com>
  • Loading branch information
Bruno Bottazzini committed Nov 4, 2015
1 parent dbc6141 commit c081f43
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions client/js/controllers/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
app.controller ('SystemdJournald', ['$scope', '$http', '$interval', '$location', 'svConf',
function ($scope, $http, $interval, $location, svConf) {

var promiseJournal;
$scope.journalRefreshPeriod = 3000;

svConf.fetchConf().success(function(data){
var journal = data.journal_access;
$scope.journalRefreshPeriod= parseInt(data.journal_refresh_period);
Expand All @@ -44,24 +46,26 @@
});

$scope.run = function() {
$scope.stopJournal();
$http.get('/api/journald').success(function(data) {
$scope.JournaldViewer = data;
$scope.startJournal();
}).error(function(){
$scope.startJournal();
$scope.JournaldViewer = "Erro getting systemd journald";
});
};

$scope.startJournal = function() {
$http.get('/api/journald').success(function(data) {
$scope.JournaldViewer = data;
}).error(function(){
$scope.JournaldViewer = "Erro getting systemd journald";
});

$interval(function () {
promiseJournal = $interval(function () {
$scope.run();
}, $scope.journalRefreshPeriod);
};

$scope.stopJournal = function() {
$interval.cancel(promiseJournal);
};

}]);
}());

0 comments on commit c081f43

Please sign in to comment.