mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-15 17:56:12 +01:00
restart fun and stop function added
This commit is contained in:
@@ -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'),
|
||||
]
|
||||
@@ -497,3 +497,41 @@ def recreateappcontainer(request):
|
||||
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)
|
||||
@@ -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"
|
||||
|
||||
@@ -279,12 +279,12 @@
|
||||
class="fa fa-play btn-icon"></i> Start
|
||||
</button>
|
||||
<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>
|
||||
Restart
|
||||
</button>
|
||||
<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
|
||||
</button>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user