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 service status request to finish before sending new…
Browse files Browse the repository at this point in the history
… request

Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com>
  • Loading branch information
Bruno Bottazzini committed Nov 5, 2015
1 parent c081f43 commit 241bda8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions client/js/controllers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
FetchFileFactory, usSpinnerService, svConf) {
var isRunningSyntax = false;
var promiseCheckSyntax;
var promiseServiceStatus;
var promiseRunViewer;
var markId;
var diag;
Expand All @@ -55,12 +56,9 @@
$scope.runJournal = data.journal_access;
$scope.runDialogRefreshPeriod = parseInt(data.run_dialog_refresh_period);
$scope.syntaxCheckRefreshPeriod = parseInt(data.syntax_check_refresh_period);
var refreshPeriod = parseInt(data.fbp_service_status_refresh_period);
$scope.refreshPeriod = parseInt(data.fbp_service_status_refresh_period);
if ($scope.runJournal === true) {
$scope.getServiceStatus();
$interval(function () {
$scope.getServiceStatus();
}, refreshPeriod);
$scope.startServiceStatus();
}
});
$scope.libChecked = false;
Expand Down Expand Up @@ -711,12 +709,20 @@

};

$scope.startServiceStatus = function () {
promiseServiceStatus = $interval(function () {
$interval.cancel(promiseServiceStatus);
$scope.getServiceStatus();
}, $scope.refreshPeriod);
};

$scope.getServiceStatus = function () {
$http.get('/api/service/status',
{params: {
"service": "fbp-runner.service"
}
}).success(function(data) {
$scope.startServiceStatus();
$scope.ServiceStatus = data.trim();
if ($scope.ServiceStatus.indexOf("active (running)") > -1) {
$scope.isServiceRunning = true;
Expand All @@ -725,6 +731,7 @@
}
$scope.ServiceStatus = $scope.ServiceStatus.replace(/since.*;/,"");
}).error(function(){
$scope.startServiceStatus();
$scope.ServiceStatus = "Failed to get service information";
});
};
Expand Down

0 comments on commit 241bda8

Please sign in to comment.