restart fun and stop function added

This commit is contained in:
Hassan Hashmi
2023-12-29 00:18:53 +05:00
parent 854798aea1
commit 8c2a2f5de5
4 changed files with 151 additions and 4 deletions

View File

@@ -35,4 +35,6 @@ urlpatterns = [
path('getContainerAppinfo', views.getContainerAppinfo, name='getContainerAppinfo'), path('getContainerAppinfo', views.getContainerAppinfo, name='getContainerAppinfo'),
path('getContainerApplog', views.getContainerApplog, name='getContainerApplog'), path('getContainerApplog', views.getContainerApplog, name='getContainerApplog'),
path('recreateappcontainer', views.recreateappcontainer, name='recreateappcontainer'), path('recreateappcontainer', views.recreateappcontainer, name='recreateappcontainer'),
path('RestartContainerAPP', views.RestartContainerAPP, name='RestartContainerAPP'),
path('StopContainerAPP', views.StopContainerAPP, name='StopContainerAPP'),
] ]

View File

@@ -497,3 +497,41 @@ def recreateappcontainer(request):
return coreResult return coreResult
except KeyError: except KeyError:
return redirect(loadLoginPage) 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)

View File

@@ -10587,8 +10587,6 @@ app.controller('ListDockersitecontainer', function ($scope, $http) {
$scope.cyberPanelLoading = true; $scope.cyberPanelLoading = true;
$scope.Lunchcontainer = function (containerid) { $scope.Lunchcontainer = function (containerid) {
// $scope.listcontainerview = true // $scope.listcontainerview = true
$scope.cyberpanelLoading = false $scope.cyberpanelLoading = false
@@ -10759,7 +10757,9 @@ app.controller('ListDockersitecontainer', function ($scope, $http) {
} }
} }
$scope.refreshStatus = function () { $scope.refreshStatus = function () {
$('#actionLoading').show();
url = "/docker/getContainerStatus"; url = "/docker/getContainerStatus";
var data = {name: $scope.cName}; var data = {name: $scope.cName};
var config = { var config = {
@@ -10771,6 +10771,7 @@ app.controller('ListDockersitecontainer', function ($scope, $http) {
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData); $http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
function ListInitialData(response) { function ListInitialData(response) {
$('#actionLoading').hide();
if (response.data.containerStatus === 1) { if (response.data.containerStatus === 1) {
console.log(response.data.status); console.log(response.data.status);
$scope.status = response.data.status; $scope.status = response.data.status;
@@ -10785,6 +10786,112 @@ app.controller('ListDockersitecontainer', function ($scope, $http) {
} }
function cantLoadInitialData(response) { 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({ PNotify.error({
title: 'Unable to complete request', title: 'Unable to complete request',
text: "Problem in connecting to server" text: "Problem in connecting to server"

View File

@@ -279,12 +279,12 @@
class="fa fa-play btn-icon"></i> Start class="fa fa-play btn-icon"></i> Start
</button> </button>
<button ng-disabled="status!='running'" class="btn btn-primary" <button ng-disabled="status!='running'" class="btn btn-primary"
ng-click="cAction('restart')"><i ng-click="restarthStatus()"><i
class="fa fa-refresh btn-icon"></i> class="fa fa-refresh btn-icon"></i>
Restart Restart
</button> </button>
<button ng-disabled="status!='running'" class="btn btn-primary" <button ng-disabled="status!='running'" class="btn btn-primary"
ng-click="cAction('stop')"><i ng-click="StopContainerAPP()"><i
class="fa fa-stop btn-icon"></i> Stop class="fa fa-stop btn-icon"></i> Stop
</button> </button>