Skip to content
Permalink
Browse files
bug fix: topProcessesStatus
  • Loading branch information
usmannasir committed May 2, 2020
1 parent 874720f commit c1f560001881a4337aee110c2c652604b31eb972
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 53 deletions.
@@ -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 @@ <h2>{% trans "Package Manager" %}</h2>
<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 @@ <h2>{% trans "Package Manager" %}</h2>
<option>10</option>
<option>50</option>
<option>100</option>
<option>500</option>
</select>
</div>
</div>
@@ -579,17 +579,45 @@ def topProcessesStatus(request):
data['Softirqs'] = loadNow[13] + '%'

## Memory
data['totalMemory'] = str(int(float(memory[3]) / 1024)) + 'MB'
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
data['buffCache'] = str(int(float(memory[9]) / 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'
data['swapBuffCache'] = str(int(float(swap[8]) / 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,19 +732,20 @@ 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)))
import re
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)

6 static/databases/databases.js 100755 → 100644
@@ -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 () {
@@ -493,4 +493,4 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) {
}
setupPHPMYAdminSession();

});
});
@@ -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,11 +451,11 @@ app.controller('listFTPAccounts', function ($scope, $http) {

$scope.generatePassword = function () {
$scope.generatedPasswordView = false;
$scope.ftpPassword = randomPassword(12);
$scope.ftpPassword = randomPassword(16);
};

$scope.usePassword = function () {
$scope.generatedPasswordView = true;
};

});
});
@@ -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 () {
@@ -1291,4 +1291,4 @@ app.controller('listEmails', function ($scope, $http) {
});


/* Java script code for List Emails Ends here */
/* Java script code for List Emails Ends here */

0 comments on commit c1f5600

Please sign in to comment.