diff --git a/dockerManager/urls.py b/dockerManager/urls.py index bd0a9fce9..2fdfb1ef4 100755 --- a/dockerManager/urls.py +++ b/dockerManager/urls.py @@ -35,4 +35,6 @@ urlpatterns = [ path('getContainerAppinfo', views.getContainerAppinfo, name='getContainerAppinfo'), path('getContainerApplog', views.getContainerApplog, name='getContainerApplog'), path('recreateappcontainer', views.recreateappcontainer, name='recreateappcontainer'), + path('RestartContainerAPP', views.RestartContainerAPP, name='RestartContainerAPP'), + path('StopContainerAPP', views.StopContainerAPP, name='StopContainerAPP'), ] \ No newline at end of file diff --git a/dockerManager/views.py b/dockerManager/views.py index f2e2e50b6..cde8f4d20 100755 --- a/dockerManager/views.py +++ b/dockerManager/views.py @@ -494,6 +494,44 @@ def recreateappcontainer(request): cm = ContainerManager() coreResult = cm.recreateappcontainer(userID, json.loads(request.body)) + return coreResult + except KeyError: + return redirect(loadLoginPage) + + +@preDockerRun +def RestartContainerAPP(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + + cm = ContainerManager() + coreResult = cm.RestartContainerAPP(userID, json.loads(request.body)) + + return coreResult + except KeyError: + return redirect(loadLoginPage) + + +@preDockerRun +def StopContainerAPP(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + + cm = ContainerManager() + coreResult = cm.StopContainerAPP(userID, json.loads(request.body)) + return coreResult except KeyError: return redirect(loadLoginPage) \ No newline at end of file diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index fe5430576..1325ab4fc 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -10587,8 +10587,6 @@ app.controller('ListDockersitecontainer', function ($scope, $http) { $scope.cyberPanelLoading = true; - - $scope.Lunchcontainer = function (containerid) { // $scope.listcontainerview = true $scope.cyberpanelLoading = false @@ -10759,7 +10757,9 @@ app.controller('ListDockersitecontainer', function ($scope, $http) { } } + $scope.refreshStatus = function () { + $('#actionLoading').show(); url = "/docker/getContainerStatus"; var data = {name: $scope.cName}; var config = { @@ -10771,6 +10771,7 @@ app.controller('ListDockersitecontainer', function ($scope, $http) { $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { + $('#actionLoading').hide(); if (response.data.containerStatus === 1) { console.log(response.data.status); $scope.status = response.data.status; @@ -10785,6 +10786,112 @@ app.controller('ListDockersitecontainer', function ($scope, $http) { } function cantLoadInitialData(response) { + $('#actionLoading').hide(); + PNotify.error({ + title: 'Unable to complete request', + text: "Problem in connecting to server" + }); + } + + }; + + $scope.restarthStatus = function () { + $('#actionLoading').show(); + url = "/docker/RestartContainerAPP"; + var data = { + name: $scope.cName, + id: $scope.cid + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $('#actionLoading').hide(); + if (response.data.status === 1) { + if (response.data.data[0] === 1) { + new PNotify({ + title: 'Success!', + text: 'Action completed', + type: 'success' + }); + $scope.Lunchcontainer($scope.cid); + } else { + new PNotify({ + title: 'Error!', + text: response.data.data[1], + type: 'error' + }); + } + } else { + new PNotify({ + title: 'Unable to complete request', + text: response.data.error_message, + type: 'error' + }); + + } + } + + function cantLoadInitialData(response) { + $('#actionLoading').hide(); + PNotify.error({ + title: 'Unable to complete request', + text: "Problem in connecting to server" + }); + } + + }; + $scope.StopContainerAPP = function () { + $('#actionLoading').show(); + url = "/docker/StopContainerAPP"; + var data = { + name: $scope.cName, + id: $scope.cid + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $('#actionLoading').hide(); + if (response.data.status === 1) { + console.log(response.data.status); + if (response.data.data[0] === 1) { + new PNotify({ + title: 'Success!', + text: 'Action completed', + type: 'success' + }); + $scope.Lunchcontainer($scope.cid); + } else { + new PNotify({ + title: 'Error!', + text: response.data.data[1], + type: 'error' + }); + } + } else { + new PNotify({ + title: 'Unable to complete request', + text: response.data.error_message, + type: 'error' + }); + + } + } + + function cantLoadInitialData(response) { + $('#actionLoading').hide(); + PNotify.error({ title: 'Unable to complete request', text: "Problem in connecting to server" diff --git a/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html b/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html index f4a2f2733..c28b88923 100644 --- a/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html +++ b/websiteFunctions/templates/websiteFunctions/DockerSiteHome.html @@ -279,12 +279,12 @@ class="fa fa-play btn-icon"> Start