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

Commit

Permalink
Add loading button when clicking in run/stop button
Browse files Browse the repository at this point in the history
This will give an interface that shows something is being processed.

Also, this patch instroduces a fix that don't allow to send multiple
requests when a run/stop is being loading.

Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com>
  • Loading branch information
Bruno Bottazzini committed May 11, 2016
1 parent e8af7c2 commit 3fb7474
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 30 deletions.
10 changes: 10 additions & 0 deletions client/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ iframe{
margin-left: 5px;
}

.button_loading {
background:url(../imgs/button_loading.gif);
background-repeat: no-repeat;
width:78px;
height:32px;
outline: 0;
margin-top: -5px;
margin-left: 5px;
}

.button_stop {
background:url(../imgs/button_stop.png);
background-repeat: no-repeat;
Expand Down
Binary file added client/imgs/button_loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 43 additions & 30 deletions client/js/controllers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
$scope.loginConf = false;
$scope.runJournal = false;
$scope.shouldSave = false;
$scope.runningStartStop = false;
svConf.fetchConf().success(function(data){
$scope.runConf = data.run_fbp_access;
$scope.loginConf = data.login_system;
Expand Down Expand Up @@ -328,40 +329,48 @@
};

$scope.run = function() {
if ($scope.isServiceRunning) {
//Post stop service
$http.post('/api/fbp/stop').success(function(data) {
if (data == 1) {
alert("FBP Service failed to stop");
}
});
} else if ($scope.fbpType === true) {
var fbpCode = editor.getSession().getValue();
var fbpName = $scope.fileName;
$scope.newFile = true;
var conf = $scope.selectConfigPath;
if (conf === "none") {
conf = null;
}
if (!filePath) {
filePath = "/tmp/cached.fbp";
}
$http.post('/api/fbp/run',
{params: {
"fbp_name": fbpName,
"fbp_path": filePath,
"code": fbpCode,
"conf": conf
}
if (!$scope.runningStartStop) {
if ($scope.isServiceRunning) {
//Post stop service
$scope.runningStartStop = true;
$http.post('/api/fbp/stop').success(function(data) {
if (data == 1) {
alert("FBP Service failed to stop");
}
}).error(function(){
$scope.runningStartStop = false;
});
} else if ($scope.fbpType === true) {
$scope.runningStartStop = true;
var fbpCode = editor.getSession().getValue();
var fbpName = $scope.fileName;
$scope.newFile = true;
var conf = $scope.selectConfigPath;
if (conf === "none") {
conf = null;
}
if (!filePath) {
filePath = "/tmp/cached.fbp";
}
$http.post('/api/fbp/run',
{params: {
"fbp_name": fbpName,
"fbp_path": filePath,
"code": fbpCode,
"conf": conf
}
}).success(function(data) {
if (data) {
$scope.openRunDialog();
} else {
alert("FBP Failed to run");
}
$scope.runningStartStop = false;
}).error(function(){
$scope.openRunDialog();
$scope.runningStartStop = false;
});
}
}
};

Expand Down Expand Up @@ -902,13 +911,17 @@
if (!$scope.runConf) {
return "disable_div";
} else {
if ($scope.isServiceRunning) {
return "button_stop";
if ($scope.runningStartStop) {
return "button_loading";
} else {
if ($scope.fbpType === true) {
return "button_run_on";
if ($scope.isServiceRunning) {
return "button_stop";
} else {
return "button_run_off";
if ($scope.fbpType === true) {
return "button_run_on";
} else {
return "button_run_off";
}
}
}
}
Expand Down

0 comments on commit 3fb7474

Please sign in to comment.