diff --git a/serverStatus/static/serverStatus/serverStatus.js b/serverStatus/static/serverStatus/serverStatus.js
index 40689c2f7..8a89159d6 100755
--- a/serverStatus/static/serverStatus/serverStatus.js
+++ b/serverStatus/static/serverStatus/serverStatus.js
@@ -788,10 +788,11 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
$scope.currentPage = 1;
$scope.recordsToShow = 10;
+ var globalType;
$scope.fetchPackages = function (type = 'installed') {
$scope.cyberpanelLoading = false;
-
+ globalType = type;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
@@ -961,4 +962,51 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
}
+ $scope.lockStatus = function (lockPackage, type) {
+ $scope.cyberpanelLoading = false;
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {
+ package: lockPackage,
+ type: type,
+ };
+
+ dataurl = "/serverstatus/lockStatus";
+
+ $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
+
+ function ListInitialData(response) {
+ $scope.cyberpanelLoading = true;
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success!',
+ text: 'Status updated.',
+ type: 'success'
+ });
+ $scope.fetchPackages(globalType);
+ } 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'
+ });
+ }
+
+
+ };
+
});
\ No newline at end of file
diff --git a/serverStatus/templates/serverStatus/packageManager.html b/serverStatus/templates/serverStatus/packageManager.html
index 7cea53791..2ea788726 100755
--- a/serverStatus/templates/serverStatus/packageManager.html
+++ b/serverStatus/templates/serverStatus/packageManager.html
@@ -114,6 +114,7 @@
{% trans "Package" %} |
{% trans "Version" %} |
{% trans "Upgrade" %} |
+ {% trans "Lock" %} |
{% trans "Actions" %} |
@@ -122,6 +123,10 @@
|
|
|
+
+
+
+ |
Update
-
@@ -277,6 +281,7 @@
{% trans "Package" %} |
{% trans "Version" %} |
{% trans "Upgrade" %} |
+ {% trans "Lock" %} |
{% trans "Actions" %} |
@@ -285,10 +290,60 @@
|
|
|
-
+
+
+ |
+
+ Upgrade |
+ title=""> Details
+
+ |
diff --git a/serverStatus/urls.py b/serverStatus/urls.py
index 91242fc0b..86fd8638d 100755
--- a/serverStatus/urls.py
+++ b/serverStatus/urls.py
@@ -22,5 +22,6 @@ urlpatterns = [
url(r'^fetchPackages$', views.fetchPackages, name='fetchPackages'),
url(r'^fetchPackageDetails$', views.fetchPackageDetails, name='fetchPackageDetails'),
url(r'^updatePackage$', views.updatePackage, name='updatePackage'),
+ url(r'^lockStatus$', views.lockStatus, name='lockStatus'),
]
\ No newline at end of file
diff --git a/serverStatus/views.py b/serverStatus/views.py
index 77744e94e..14ea17504 100755
--- a/serverStatus/views.py
+++ b/serverStatus/views.py
@@ -731,6 +731,10 @@ def fetchPackages(request):
type = data['type']
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
+
+ command = 'apt-mark showhold'
+ locked = ProcessUtilities.outputExecutioner(command).split('\n')
+
command = 'apt list --installed'
packages = ProcessUtilities.outputExecutioner(command).split('\n')
packages = packages[4:]
@@ -772,7 +776,12 @@ def fetchPackages(request):
current = nowSplitted[1].split(' ')
upgrade = '%s %s %s' % (current[3], current[4], current[5])
- dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade}
+ if nowSplitted[0].split('/')[0] in locked:
+ lock = 1
+ else:
+ lock = 0
+
+ dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock}
counter = counter + 1
if checker == 0:
@@ -856,6 +865,39 @@ def updatePackage(request):
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)
+
+def lockStatus(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ data = json.loads(request.body)
+ package = data['package']
+ type = data['type']
+
+ if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
+
+ if type == 0:
+ command = 'apt-mark unhold %s' % (package)
+ ProcessUtilities.executioner(command)
+ else:
+ command = 'apt-mark hold %s' % (package)
+ ProcessUtilities.executioner(command)
+
+ data_ret = {'status': 1}
+ 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)