diff --git a/serverStatus/static/serverStatus/serverStatus.js b/serverStatus/static/serverStatus/serverStatus.js index 61e42219d..17f8c8e09 100755 --- a/serverStatus/static/serverStatus/serverStatus.js +++ b/serverStatus/static/serverStatus/serverStatus.js @@ -249,6 +249,57 @@ app.controller('litespeedStatus', function ($scope, $http) { }; + $scope.refreshLicense = function () { + + $scope.cpLoading = false; + + var url = "/serverstatus/refreshLicense"; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + data = {}; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.cpLoading = true; + new PNotify({ + title: 'Success!', + text: 'License successfully refreshed', + type: 'success' + }); + } else { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: response.data.erroMessage, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + } + + + }; + }); /* Java script code to start/stop litespeed */ diff --git a/serverStatus/templates/serverStatus/litespeedStatus.html b/serverStatus/templates/serverStatus/litespeedStatus.html index 51278032f..8f9cb00c7 100755 --- a/serverStatus/templates/serverStatus/litespeedStatus.html +++ b/serverStatus/templates/serverStatus/litespeedStatus.html @@ -332,7 +332,7 @@
-
+
@@ -342,7 +342,7 @@
-
+
@@ -353,6 +353,17 @@
+ +
diff --git a/serverStatus/urls.py b/serverStatus/urls.py index c3b6eadc5..ca33c74b0 100755 --- a/serverStatus/urls.py +++ b/serverStatus/urls.py @@ -15,6 +15,7 @@ urlpatterns = [ url(r'^switchTOLSWSStatus$', views.switchTOLSWSStatus, name='switchTOLSWSStatus'), url(r'^licenseStatus$', views.licenseStatus, name='licenseStatus'), url(r'^changeLicense$', views.changeLicense, name='changeLicense'), + url(r'^refreshLicense$', views.refreshLicense, name='refreshLicense'), url(r'^topProcesses$', views.topProcesses, name='topProcesses'), url(r'^topProcessesStatus$', views.topProcessesStatus, name='topProcessesStatus'), url(r'^killProcess$', views.killProcess, name='killProcess'), diff --git a/serverStatus/views.py b/serverStatus/views.py index aa048059a..2f8689f61 100755 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -417,6 +417,11 @@ def licenseStatus(request): command = 'sudo cat /usr/local/lsws/conf/serial.no' serial = ProcessUtilities.outputExecutioner(command) + if serial.find('No such file or directory') > -1: + final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': 'Trial License in use.', 'lsexpiration': 'Trial license expires 15 days after activation.'} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + command = 'sudo /usr/local/lsws/bin/lshttpd -V' expiration = ProcessUtilities.outputExecutioner(command) @@ -433,6 +438,35 @@ def licenseStatus(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) +def refreshLicense(request): + try: + userID = request.session['userID'] + + try: + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson('status', 0) + + + command = 'sudo /usr/local/lsws/bin/lshttpd -V' + ProcessUtilities.outputExecutioner(command) + + final_dic = {'status': 1} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + + except BaseException as msg: + final_dic = {'status': 0, 'erroMessage': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except KeyError as msg: + final_dic = {'status': 0, 'erroMessage': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + def changeLicense(request): try: diff --git a/static/serverStatus/serverStatus.js b/static/serverStatus/serverStatus.js index 61e42219d..17f8c8e09 100644 --- a/static/serverStatus/serverStatus.js +++ b/static/serverStatus/serverStatus.js @@ -249,6 +249,57 @@ app.controller('litespeedStatus', function ($scope, $http) { }; + $scope.refreshLicense = function () { + + $scope.cpLoading = false; + + var url = "/serverstatus/refreshLicense"; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + data = {}; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.cpLoading = true; + new PNotify({ + title: 'Success!', + text: 'License successfully refreshed', + type: 'success' + }); + } else { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: response.data.erroMessage, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cpLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + } + + + }; + }); /* Java script code to start/stop litespeed */