From 381f5e050888b909ed56ffebcac659473e1ea508 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sun, 27 May 2018 14:18:03 +0000 Subject: [PATCH] Fixed issue with controlling lsws from service page --- .../static/serverStatus/serverStatus.js | 28 +++++++++---------- .../templates/serverStatus/services.html | 2 +- serverStatus/views.py | 7 +++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/serverStatus/static/serverStatus/serverStatus.js b/serverStatus/static/serverStatus/serverStatus.js index f3b0624c6..dad82b360 100644 --- a/serverStatus/static/serverStatus/serverStatus.js +++ b/serverStatus/static/serverStatus/serverStatus.js @@ -377,7 +377,7 @@ app.controller('servicesManager', function($scope,$http) { $scope.serviceAction = function(serviceName, action){ $scope.ActionProgress = true; $scope.btnDisable = true; - $scope.ActionSuccessfull = false; + $scope.ActionSuccessful = false; $scope.ActionFailed = false; $scope.couldNotConnect = false; $scope.actionLoader = true; @@ -403,32 +403,32 @@ app.controller('servicesManager', function($scope,$http) { if(response.data.serviceAction == 1){ setTimeout(function() { getServiceStatus(); - setTimeout(function() { - $scope.ActionSuccessfull = true; - $scope.ActionFailed = false; - $scope.couldNotConnect = false; - $scope.actionLoader = false; - $scope.btnDisable = false; - },1000) - }, 3000); + //setTimeout(function() { + $scope.ActionSuccessful = true; + $scope.ActionFailed = false; + $scope.couldNotConnect = false; + $scope.actionLoader = false; + $scope.btnDisable = false; + //},1000) + }, 1000); } else{ setTimeout(function() { getServiceStatus(); - setTimeout(function() { - $scope.ActionSuccessfull = false; + //setTimeout(function() { + $scope.ActionSuccessful = false; $scope.ActionFailed = true; $scope.couldNotConnect = false; $scope.actionLoader = false; $scope.btnDisable = false; - },1000) - }, 5000); + //},1000) + }, 1000); } } function cantLoadInitialDatas(response) { - $scope.ActionSuccessfull = false; + $scope.ActionSuccessful = false; $scope.ActionFailed = false; $scope.couldNotConnect = true; $scope.actionLoader = false; diff --git a/serverStatus/templates/serverStatus/services.html b/serverStatus/templates/serverStatus/services.html index 635580923..d7f956c88 100644 --- a/serverStatus/templates/serverStatus/services.html +++ b/serverStatus/templates/serverStatus/services.html @@ -130,7 +130,7 @@

Action Failed

-
+

Action Completed

diff --git a/serverStatus/views.py b/serverStatus/views.py index fdc92b164..e01f6c4a6 100644 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -293,8 +293,11 @@ def servicesAction(request): return HttpResponse(final_json) else: - - command = 'sudo systemctl %s %s' % (action, service) + + if service == "lsws": + command = "sudo /usr/local/lsws/bin/lswsctrl %s" % (action) + else: + command = 'sudo systemctl %s %s' % (action, service) cmd = shlex.split(command) res = subprocess.call(cmd)