mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 23:36:11 +01:00
show packs on packages manager
This commit is contained in:
@@ -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,111 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
text: 'Process successfully killed.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
} 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,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div ng-controller="litespeedStatus" class="container">
|
||||
<div ng-controller="listOSPackages" class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Package Manager" %}</h2>
|
||||
@@ -22,53 +22,77 @@
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
<ul class="nav-responsive nav nav-tabs">
|
||||
<li class="dropdown pull-right tabdrop"><a class="dropdown-toggle"
|
||||
data-toggle="dropdown" href="#"
|
||||
aria-expanded="false"><i
|
||||
class="glyph-icon icon-align-justify"></i> <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu" style="display: none;">
|
||||
<li><a href="#tab5" data-toggle="tab">Section 5</a></li>
|
||||
<li><a href="#tab6" data-toggle="tab">Section 6</a></li>
|
||||
<li><a href="#tab7" data-toggle="tab">Section 7</a></li>
|
||||
<li><a href="#tab8" data-toggle="tab">Section 8</a></li>
|
||||
<li><a href="#tab9" data-toggle="tab">Section 9</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class=""><a href="#tab1" data-toggle="tab">Section 1</a></li>
|
||||
<li class=""><a href="#tab2" data-toggle="tab">Section 2</a></li>
|
||||
<li class=""><a href="#tab3" data-toggle="tab">Section 3</a></li>
|
||||
<li class="active"><a href="#tab4" data-toggle="tab">Section 4</a></li>
|
||||
|
||||
|
||||
<li class="active"><a href="#tab4" data-toggle="tab">Updates</a></li>
|
||||
<li><a ng-click="fetchPackages()" href="#tab6" data-toggle="tab">All Packages</a></li>
|
||||
<li><a href="#tab7" data-toggle="tab">Settings</a></li>
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane" id="tab1">
|
||||
<p>I'm in Section 1.</p>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab2">
|
||||
<p>Howdy, I'm in Section 2.</p>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab3">
|
||||
<p>Howdy, I'm in Section 3.</p>
|
||||
</div>
|
||||
<div class="tab-pane active" id="tab4">
|
||||
<p>Howdy, I'm in Section 4.</p>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab5">
|
||||
<p>Howdy, I'm in Section 5.</p>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab6">
|
||||
<p>Howdy, I'm in Section 6.</p>
|
||||
<div class="col-sm-10"
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input placeholder="Search..."
|
||||
ng-model="packSearch" name="packSearch" type="text"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="form-group">
|
||||
<select ng-model="recordsToShow" ng-change="fetchPackages()"
|
||||
class="form-control" id="example-select">
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table" style="margin: 0px; padding: 0px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Package" %}</th>
|
||||
<th>{% trans "Description" %}</th>
|
||||
<th>{% trans "Status" %}</th>
|
||||
<th>{% trans "Version" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="record in allPackages | filter:packSearch">
|
||||
<td ng-bind="record.package"></td>
|
||||
<td ng-bind="record.description"></td>
|
||||
<td ng-bind="record.status"></td>
|
||||
<td ng-bind="record.version"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 2%" class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<select ng-model="currentPage" class="form-control"
|
||||
ng-change="fetchPackages()">
|
||||
<option ng-repeat="page in pagination">{$ $index + 1 $}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab7">
|
||||
<p>Howdy, I'm in Section 7.</p>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab8">
|
||||
<p>Howdy, I'm in Section 8.</p>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab9">
|
||||
<p>Howdy, I'm in Section 9.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,5 +19,6 @@ urlpatterns = [
|
||||
url(r'^topProcessesStatus$', views.topProcessesStatus, name='topProcessesStatus'),
|
||||
url(r'^killProcess$', views.killProcess, name='killProcess'),
|
||||
url(r'^packageManager$', views.packageManager, name='packageManager'),
|
||||
url(r'^fetchPackages$', views.fetchPackages, name='fetchPackages'),
|
||||
|
||||
]
|
||||
@@ -6,7 +6,7 @@ from django.http import HttpResponse
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from loginSystem.views import loadLoginPage
|
||||
import json
|
||||
import subprocess
|
||||
import subprocess, shlex
|
||||
import psutil
|
||||
import socket
|
||||
from plogical.acl import ACLManager
|
||||
@@ -672,4 +672,65 @@ def packageManager(request):
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[packageManager]")
|
||||
return redirect(loadLoginPage)
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchPackages(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = json.loads(request.body)
|
||||
page = int(data['page'])
|
||||
recordsToShow = int(data['recordsToShow'])
|
||||
|
||||
packageInformation = '/home/cyberpanel/OSPackages'
|
||||
f = open(packageInformation, "w")
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
command = 'dpkg-query -f \'{"status":"${db:Status-Abbrev}","package":"${binary:Package}","version":"${Version}","description":"${binary:Summary}"}\n\' -W'
|
||||
subprocess.call(shlex.split(command), stdout=f)
|
||||
|
||||
packages = ProcessUtilities.outputExecutioner('cat %s' % (packageInformation)).split('\n')
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
|
||||
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
|
||||
pagination = S3Backups.getPagination(len(packages), recordsToShow)
|
||||
endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow)
|
||||
finalPackages = packages[finalPageNumber:endPageNumber]
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
|
||||
|
||||
for items in finalPackages:
|
||||
logging.CyberCPLogFileWriter.writeToFile(items)
|
||||
try:
|
||||
if checker == 0:
|
||||
json_data = json_data + items
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + items
|
||||
except:
|
||||
logging.CyberCPLogFileWriter.writeToFile(items)
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -3613,7 +3613,6 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile('hello world 2')
|
||||
|
||||
## Security check
|
||||
|
||||
|
||||
Reference in New Issue
Block a user