mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 08:16:11 +01:00
bug fix: topProcessesStatus
This commit is contained in:
@@ -812,6 +812,8 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.allPackages = JSON.parse(response.data.packages);
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.fetchedPackages = response.data.fetchedPackages;
|
||||
$scope.totalPackages = response.data.totalPackages;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
||||
@@ -33,6 +33,12 @@
|
||||
<p>Howdy, I'm in Section 4.</p>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab6">
|
||||
<a style="float: left ; margin-bottom: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure" href="#"
|
||||
title=""><span>Total Packages: {$ totalPackages $}</span></a>
|
||||
<a style="float: left; margin-bottom: 2%; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt" href="#"
|
||||
title=""><span>Fetched Packages: {$ fetchedPackages $}</span></a>
|
||||
<div class="col-sm-10"
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input placeholder="Search..."
|
||||
@@ -46,6 +52,7 @@
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
<option>500</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -579,16 +579,44 @@ def topProcessesStatus(request):
|
||||
data['Softirqs'] = loadNow[13] + '%'
|
||||
|
||||
## Memory
|
||||
data['totalMemory'] = str(int(float(memory[3]) / 1024)) + 'MB'
|
||||
|
||||
if memory[3].find('+') > -1:
|
||||
memoryFinal = memory[3].split('+')[0]
|
||||
else:
|
||||
memoryFinal = memory[3]
|
||||
|
||||
data['totalMemory'] = str(int(float(memoryFinal) / 1024)) + 'MB'
|
||||
|
||||
##
|
||||
|
||||
if memory[5].find('free') > -1:
|
||||
data['freeMemory'] = str(int(float(memory[4]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
|
||||
|
||||
##
|
||||
|
||||
if memory[7].find('used') > -1:
|
||||
data['usedMemory'] = str(int(float(memory[6]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
|
||||
|
||||
if memory[9].find('buff') > -1:
|
||||
data['buffCache'] = str(int(float(memory[8]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
|
||||
|
||||
## Swap
|
||||
|
||||
|
||||
data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB'
|
||||
data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB'
|
||||
data['swapUsedMemory'] = str(int(float(swap[6]) / 1024)) + 'MB'
|
||||
|
||||
if swap[8].find('+') > -1:
|
||||
finalBuffCache = swap[8].split('+')[0]
|
||||
data['swapBuffCache'] = str(int(float(finalBuffCache) / 1024)) + 'MB'
|
||||
else:
|
||||
data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB'
|
||||
|
||||
## Processes
|
||||
@@ -686,7 +714,7 @@ def fetchPackages(request):
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = json.loads(request.body)
|
||||
page = int(data['page'].rstrip('\n'))
|
||||
page = int(str(data['page']).rstrip('\n'))
|
||||
recordsToShow = int(data['recordsToShow'])
|
||||
|
||||
packageInformation = '/home/cyberpanel/OSPackages'
|
||||
@@ -704,12 +732,12 @@ def fetchPackages(request):
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
|
||||
pagination = S3Backups.getPagination(len(packages), recordsToShow)
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(pagination))
|
||||
endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow)
|
||||
finalPackages = packages[finalPageNumber:endPageNumber]
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
counter = 0
|
||||
|
||||
# if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
|
||||
@@ -717,6 +745,7 @@ def fetchPackages(request):
|
||||
for items in finalPackages:
|
||||
items = re.sub(r'("[\s\w]*)"([\s\w])*"([\s\w]*)',r"\1\2\3", items)
|
||||
try:
|
||||
counter = counter + 1
|
||||
if checker == 0:
|
||||
json_data = json_data + items
|
||||
checker = 1
|
||||
@@ -727,7 +756,7 @@ def fetchPackages(request):
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination}
|
||||
data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter, 'totalPackages': len(packages)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
4
static/databases/databases.js
Executable file → Normal file
4
static/databases/databases.js
Executable file → Normal file
@@ -106,7 +106,7 @@ app.controller('createDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -447,7 +447,7 @@ app.controller('listDBs', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
|
||||
@@ -113,7 +113,7 @@ app.controller('createFTPAccount', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.ftpPassword = randomPassword(12);
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -451,7 +451,7 @@ app.controller('listFTPAccounts', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.ftpPassword = randomPassword(12);
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
|
||||
@@ -110,7 +110,7 @@ app.controller('createEmailAccount', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.emailPassword = randomPassword(12);
|
||||
$scope.emailPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -465,7 +465,7 @@ app.controller('changeEmailPassword', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.emailPassword = randomPassword(12);
|
||||
$scope.emailPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Java script code to start/stop litespeed */
|
||||
app.controller('litespeedStatus', function ($scope, $http) {
|
||||
|
||||
@@ -49,8 +48,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
$scope.actionResultBad = true;
|
||||
$scope.serverStatusCouldNotConnect = true;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.restartorStopLoading = true;
|
||||
$scope.actionResult = true;
|
||||
@@ -109,8 +107,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
$scope.actionResultBad = true;
|
||||
$scope.serverStatusCouldNotConnect = true;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.restartorStopLoading = true;
|
||||
$scope.actionResult = true;
|
||||
@@ -174,8 +171,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
});
|
||||
$scope.lsSerial = response.data.lsSerial;
|
||||
$scope.lsexpiration = response.data.lsexpiration;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -229,8 +225,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
text: 'License successfully Updated',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -292,8 +287,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
|
||||
$scope.logsData = response.data.logsdata;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.logFileLoading = true;
|
||||
$scope.logsFeteched = true;
|
||||
@@ -347,8 +341,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
|
||||
$scope.logsData = response.data.logsdata;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.logFileLoading = true;
|
||||
$scope.logsFeteched = true;
|
||||
@@ -409,8 +402,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.olsStart = false;
|
||||
$scope.olsStop = true;
|
||||
$scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.olsStatus = "Stopped";
|
||||
$scope.olsStats = false;
|
||||
$scope.olsStart = true;
|
||||
@@ -421,8 +413,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.dockerStatus = "Running";
|
||||
$scope.dockerStart = false;
|
||||
$scope.dockerStop = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.dockerStatus = "Stopped";
|
||||
$scope.dockerStart = true;
|
||||
$scope.dockerStop = false;
|
||||
@@ -435,8 +426,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.sqlStart = false;
|
||||
$scope.sqlStop = true;
|
||||
$scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.sqlStatus = "Stopped";
|
||||
$scope.sqlStats = false;
|
||||
$scope.sqlStart = true;
|
||||
@@ -451,8 +441,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.dnsStart = false;
|
||||
$scope.dnsStop = true;
|
||||
$scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.dnsStatus = "Stopped";
|
||||
$scope.dnsStats = false;
|
||||
$scope.dnsStart = true;
|
||||
@@ -467,8 +456,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.ftpStart = false;
|
||||
$scope.ftpStop = true;
|
||||
$scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.ftpStatus = "Stopped";
|
||||
$scope.ftpStats = false;
|
||||
$scope.ftpStart = true;
|
||||
@@ -487,6 +475,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getServiceStatus();
|
||||
|
||||
$scope.serviceAction = function (serviceName, action) {
|
||||
@@ -524,8 +513,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.actionLoader = false;
|
||||
$scope.btnDisable = false;
|
||||
}, 3000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
getServiceStatus();
|
||||
$scope.ActionSuccessfull = false;
|
||||
@@ -583,8 +571,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.installBoxGen = false;
|
||||
getRequestStatus();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -626,8 +613,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Notifications
|
||||
$scope.cyberPanelLoading = true;
|
||||
$timeout.cancel();
|
||||
@@ -720,8 +706,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
$scope.zombieProcesses = response.data.zombieProcesses;
|
||||
|
||||
$timeout($scope.topProcessesStatus, 3000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -771,8 +756,113 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
text: 'Process successfully killed.',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
///
|
||||
|
||||
|
||||
app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
|
||||
$scope.fetchPackages = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
page: $scope.currentPage,
|
||||
recordsToShow: $scope.recordsToShow
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackages";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.allPackages = JSON.parse(response.data.packages);
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.fetchedPackages = response.data.fetchedPackages;
|
||||
$scope.totalPackages = response.data.totalPackages;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.killProcess = function (pid) {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
url = "/serverstatus/killProcess";
|
||||
|
||||
var data = {
|
||||
pid: pid
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Process successfully killed.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
|
||||
@@ -113,7 +113,7 @@ app.controller('createUserCtr', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.password = randomPassword(12);
|
||||
$scope.password = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -342,7 +342,7 @@ app.controller('modifyUser', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.password = randomPassword(12);
|
||||
$scope.password = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":"2.0","build":0}
|
||||
{"version":"2.0","build":1}
|
||||
Reference in New Issue
Block a user