mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 13:56:01 +01:00
change how packages are fetched on ubuntu;
This commit is contained in:
@@ -789,7 +789,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
|
||||
$scope.fetchPackages = function () {
|
||||
$scope.fetchPackages = function (type = 'installed') {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var config = {
|
||||
@@ -800,7 +800,8 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
var data = {
|
||||
page: $scope.currentPage,
|
||||
recordsToShow: $scope.recordsToShow
|
||||
recordsToShow: $scope.recordsToShow,
|
||||
type: type
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackages";
|
||||
@@ -833,6 +834,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
|
||||
};
|
||||
$scope.fetchPackages('upgrade');
|
||||
|
||||
$scope.killProcess = function (pid) {
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
<ul class="nav-responsive nav nav-tabs">
|
||||
<li class="active"><a href="#tab4" data-toggle="tab">Updates</a></li>
|
||||
<li class="active"><a ng-click="fetchPackages('upgrade')" 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"
|
||||
@@ -30,7 +30,72 @@
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab4">
|
||||
<p>Howdy, I'm in Section 4.</p>
|
||||
<a style="float: left ; margin-bottom: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure" href="#"
|
||||
title=""><span>Total Upgradeable 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..."
|
||||
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('upgrade')"
|
||||
class="form-control" id="example-select">
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
<option>500</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 "Version" %}</th>
|
||||
<th>{% trans "Upgrade" %}</th>
|
||||
<th>{% trans "Actions" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="record in allPackages | filter:packSearch">
|
||||
<td ng-bind="record.package"></td>
|
||||
<td ng-bind="record.version"></td>
|
||||
<td ng-bind="record.upgrade"></td>
|
||||
<td><a style="float: left ; margin-bottom: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="#"
|
||||
title=""><span>Upgrade</span></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 2%" class="row">
|
||||
<div style="margin-top: 2%" 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('upgrade')">
|
||||
<option ng-repeat="page in pagination">{$ $index + 1 $}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab6">
|
||||
<a style="float: left ; margin-bottom: 2%"
|
||||
@@ -63,17 +128,20 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Package" %}</th>
|
||||
<th>{% trans "Description" %}</th>
|
||||
<th>{% trans "Status" %}</th>
|
||||
<th>{% trans "Version" %}</th>
|
||||
<th>{% trans "Upgrade" %}</th>
|
||||
<th>{% trans "Actions" %}</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>
|
||||
<td ng-bind="record.upgrade"></td>
|
||||
<td><a style="float: left ; margin-bottom: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="#"
|
||||
title=""><span>Upgrade</span></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -728,18 +728,25 @@ def fetchPackages(request):
|
||||
data = json.loads(request.body)
|
||||
page = int(str(data['page']).rstrip('\n'))
|
||||
recordsToShow = int(data['recordsToShow'])
|
||||
|
||||
packageInformation = '/home/cyberpanel/OSPackages'
|
||||
f = open(packageInformation, "w")
|
||||
type = data['type']
|
||||
|
||||
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)
|
||||
command = 'apt list --installed'
|
||||
packages = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
packages = packages[4:]
|
||||
|
||||
packages = ProcessUtilities.outputExecutioner('cat %s' % (packageInformation)).split('\n')
|
||||
upgradePackages = []
|
||||
|
||||
# if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
|
||||
if type == 'upgrade':
|
||||
for pack in packages:
|
||||
if pack.find('upgradable') > -1:
|
||||
upgradePackages.append(pack)
|
||||
|
||||
packages = upgradePackages
|
||||
|
||||
|
||||
#if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
|
||||
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
|
||||
@@ -751,20 +758,30 @@ def fetchPackages(request):
|
||||
checker = 0
|
||||
counter = 0
|
||||
|
||||
# if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
|
||||
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:
|
||||
nowSplitted = items.split('now')
|
||||
|
||||
upgrade = 'Not Needed'
|
||||
|
||||
if nowSplitted[1].split(' ')[3].find('upgradable') > -1:
|
||||
upgrade = nowSplitted[1].split(' ')[3]
|
||||
|
||||
dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade}
|
||||
|
||||
counter = counter + 1
|
||||
if checker == 0:
|
||||
json_data = json_data + items
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + items
|
||||
except:
|
||||
logging.CyberCPLogFileWriter.writeToFile(items)
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:773]' % (str(msg)))
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
|
||||
@@ -789,7 +789,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
|
||||
$scope.fetchPackages = function () {
|
||||
$scope.fetchPackages = function (type = 'installed') {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var config = {
|
||||
@@ -800,7 +800,8 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
var data = {
|
||||
page: $scope.currentPage,
|
||||
recordsToShow: $scope.recordsToShow
|
||||
recordsToShow: $scope.recordsToShow,
|
||||
type: type
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackages";
|
||||
@@ -833,6 +834,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
|
||||
};
|
||||
$scope.fetchPackages('upgrade');
|
||||
|
||||
$scope.killProcess = function (pid) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user