mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 14:26:16 +01:00
refresh license button
This commit is contained in:
@@ -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 */
|
/* Java script code to start/stop litespeed */
|
||||||
|
|||||||
@@ -332,7 +332,7 @@
|
|||||||
<div class="content-box-wrapper">
|
<div class="content-box-wrapper">
|
||||||
<div class="row mt-5 mx-10">
|
<div class="row mt-5 mx-10">
|
||||||
|
|
||||||
<div class="col-md-6 panel-body">
|
<div class="col-md-4 panel-body">
|
||||||
<a ng-click="licenseStatus(1)" href="" title="{% trans 'License Status' %}">
|
<a ng-click="licenseStatus(1)" href="" title="{% trans 'License Status' %}">
|
||||||
<img src="{% static 'images/license-status.png' %}" width="65" class="mr-10 ">
|
<img src="{% static 'images/license-status.png' %}" width="65" class="mr-10 ">
|
||||||
</a>
|
</a>
|
||||||
@@ -342,7 +342,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6 panel-body">
|
<div class="col-md-4 panel-body">
|
||||||
<a ng-click="showSerialBox()" href="" title="{% trans 'Change License' %}">
|
<a ng-click="showSerialBox()" href="" title="{% trans 'Change License' %}">
|
||||||
<img src="{% static 'images/change-license.png' %}" width="65" class="mr-10">
|
<img src="{% static 'images/change-license.png' %}" width="65" class="mr-10">
|
||||||
</a>
|
</a>
|
||||||
@@ -353,6 +353,17 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4 panel-body">
|
||||||
|
<a ng-click="refreshLicense()" href="" title="{% trans 'Refresh License' %}">
|
||||||
|
<img src="{% static 'images/change-license.png' %}" width="65" class="mr-10">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a ng-click="refreshLicense()" href="" title="{% trans 'Refresh License' %}">
|
||||||
|
<span class="h4">{% trans 'Refresh License' %}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<div ng-hide="fetchedData">
|
<div ng-hide="fetchedData">
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ urlpatterns = [
|
|||||||
url(r'^switchTOLSWSStatus$', views.switchTOLSWSStatus, name='switchTOLSWSStatus'),
|
url(r'^switchTOLSWSStatus$', views.switchTOLSWSStatus, name='switchTOLSWSStatus'),
|
||||||
url(r'^licenseStatus$', views.licenseStatus, name='licenseStatus'),
|
url(r'^licenseStatus$', views.licenseStatus, name='licenseStatus'),
|
||||||
url(r'^changeLicense$', views.changeLicense, name='changeLicense'),
|
url(r'^changeLicense$', views.changeLicense, name='changeLicense'),
|
||||||
|
url(r'^refreshLicense$', views.refreshLicense, name='refreshLicense'),
|
||||||
url(r'^topProcesses$', views.topProcesses, name='topProcesses'),
|
url(r'^topProcesses$', views.topProcesses, name='topProcesses'),
|
||||||
url(r'^topProcessesStatus$', views.topProcessesStatus, name='topProcessesStatus'),
|
url(r'^topProcessesStatus$', views.topProcessesStatus, name='topProcessesStatus'),
|
||||||
url(r'^killProcess$', views.killProcess, name='killProcess'),
|
url(r'^killProcess$', views.killProcess, name='killProcess'),
|
||||||
|
|||||||
@@ -417,6 +417,11 @@ def licenseStatus(request):
|
|||||||
command = 'sudo cat /usr/local/lsws/conf/serial.no'
|
command = 'sudo cat /usr/local/lsws/conf/serial.no'
|
||||||
serial = ProcessUtilities.outputExecutioner(command)
|
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'
|
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
|
||||||
expiration = ProcessUtilities.outputExecutioner(command)
|
expiration = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
@@ -433,6 +438,35 @@ def licenseStatus(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
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):
|
def changeLicense(request):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -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 */
|
/* Java script code to start/stop litespeed */
|
||||||
|
|||||||
Reference in New Issue
Block a user