mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-06 16:36:48 +02:00
Docker Manager: fix container update flow and UI sync
Align updateContainer with the panel (name vs containerName), pull new images before removing the old container, and sync the Containers model after a successful update. getContainerList now shows live Config.Image so tags match Docker. Add notification-center progress for updates, guard overlapping requests, and return new_image on success.
This commit is contained in:
@@ -974,6 +974,15 @@ app.controller('listContainers', function ($scope, $http) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($scope.dockerUpdateInProgress) {
|
||||
new PNotify({
|
||||
title: 'Update in progress',
|
||||
text: 'Wait until the current update finishes before starting another.',
|
||||
type: 'warning'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// If no new image specified, use current image
|
||||
if (!$scope.newImage) {
|
||||
$scope.newImage = $scope.currentImage;
|
||||
@@ -1000,9 +1009,18 @@ app.controller('listContainers', function ($scope, $http) {
|
||||
history: false
|
||||
}
|
||||
})).get().on('pnotify.confirm', function () {
|
||||
var dockerUpdateNotificationId = null;
|
||||
$scope.dockerUpdateInProgress = true;
|
||||
$('#imageLoading').show();
|
||||
$("#updateContainer").modal("hide");
|
||||
|
||||
if (typeof window.cpDockerUpdateNotifyStart === 'function') {
|
||||
dockerUpdateNotificationId = window.cpDockerUpdateNotifyStart(
|
||||
$scope.updateContainerName,
|
||||
$scope.newImage + ':' + $scope.newTag
|
||||
);
|
||||
}
|
||||
|
||||
url = "/docker/updateContainer";
|
||||
var data = {
|
||||
name: $scope.updateContainerName,
|
||||
@@ -1020,15 +1038,27 @@ app.controller('listContainers', function ($scope, $http) {
|
||||
|
||||
function ListInitialData(response) {
|
||||
console.log(response);
|
||||
$scope.dockerUpdateInProgress = false;
|
||||
$('#imageLoading').hide();
|
||||
|
||||
if (response.data.updateContainerStatus === 1) {
|
||||
var ok = response.data && response.data.updateContainerStatus === 1;
|
||||
var imgLabel = ok
|
||||
? (response.data.new_image || response.data.message || 'Updated')
|
||||
: (response.data && response.data.error_message ? response.data.error_message : 'Update failed');
|
||||
|
||||
if (typeof window.cpDockerUpdateNotifyEnd === 'function' && dockerUpdateNotificationId) {
|
||||
window.cpDockerUpdateNotifyEnd(dockerUpdateNotificationId, ok, imgLabel);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
new PNotify({
|
||||
title: 'Container Updated Successfully',
|
||||
text: `Container updated to ${response.data.new_image}`,
|
||||
text: 'Container updated to ' + (response.data.new_image || response.data.message || 'new image'),
|
||||
type: 'success'
|
||||
});
|
||||
location.reload();
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 2200);
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Update Failed',
|
||||
@@ -1039,7 +1069,11 @@ app.controller('listContainers', function ($scope, $http) {
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.dockerUpdateInProgress = false;
|
||||
$('#imageLoading').hide();
|
||||
if (typeof window.cpDockerUpdateNotifyEnd === 'function' && dockerUpdateNotificationId) {
|
||||
window.cpDockerUpdateNotifyEnd(dockerUpdateNotificationId, false, 'Could not connect to server');
|
||||
}
|
||||
new PNotify({
|
||||
title: 'Update Failed',
|
||||
text: 'Could not connect to server',
|
||||
|
||||
Reference in New Issue
Block a user