mirror of
https://github.com/portainer/portainer.git
synced 2025-07-26 00:39:41 +02:00
Added pause/unpause to containers,
Auto-update /container and /containers views after performing an action, Display spinner when container actions are being performed, Unified style
This commit is contained in:
parent
9dccf95152
commit
8652285227
5 changed files with 151 additions and 81 deletions
|
@ -155,34 +155,83 @@ function SettingsController($scope, System, Docker, Settings, Messages) {
|
|||
function ContainerController($scope, $routeParams, $location, Container, Messages, ViewSpinner) {
|
||||
$scope.changes = [];
|
||||
|
||||
var update = function() {
|
||||
Container.get({id: $routeParams.id}, function(d) {
|
||||
$scope.container = d;
|
||||
ViewSpinner.stop();
|
||||
}, function(e) {
|
||||
if (e.status === 404) {
|
||||
$('.detail').hide();
|
||||
Messages.error("Not found", "Container not found.");
|
||||
} else {
|
||||
Messages.error("Failure", e.data);
|
||||
}
|
||||
ViewSpinner.stop();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.start = function(){
|
||||
ViewSpinner.spin();
|
||||
Container.start({id: $routeParams.id}, function(d) {
|
||||
update();
|
||||
Messages.send("Container started", $routeParams.id);
|
||||
}, function(e) {
|
||||
update();
|
||||
Messages.error("Failure", "Container failed to start." + e.data);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.stop = function() {
|
||||
ViewSpinner.spin();
|
||||
Container.stop({id: $routeParams.id}, function(d) {
|
||||
update();
|
||||
Messages.send("Container stopped", $routeParams.id);
|
||||
}, function(e) {
|
||||
update();
|
||||
Messages.error("Failure", "Container failed to stop." + e.data);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.kill = function() {
|
||||
ViewSpinner.spin();
|
||||
Container.kill({id: $routeParams.id}, function(d) {
|
||||
update();
|
||||
Messages.send("Container killed", $routeParams.id);
|
||||
}, function(e) {
|
||||
update();
|
||||
Messages.error("Failure", "Container failed to die." + e.data);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.pause = function() {
|
||||
ViewSpinner.spin();
|
||||
Container.pause({id: $routeParams.id}, function(d) {
|
||||
update();
|
||||
Messages.send("Container paused", $routeParams.id);
|
||||
}, function(e) {
|
||||
update();
|
||||
Messages.error("Failure", "Container failed to pause." + e.data);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.unpause = function() {
|
||||
ViewSpinner.spin();
|
||||
Container.unpause({id: $routeParams.id}, function(d) {
|
||||
update();
|
||||
Messages.send("Container unpaused", $routeParams.id);
|
||||
}, function(e) {
|
||||
update();
|
||||
Messages.error("Failure", "Container failed to unpause." + e.data);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.remove = function() {
|
||||
ViewSpinner.spin();
|
||||
Container.remove({id: $routeParams.id}, function(d) {
|
||||
update();
|
||||
Messages.send("Container removed", $routeParams.id);
|
||||
}, function(e){
|
||||
update();
|
||||
Messages.error("Failure", "Container failed to remove." + e.data);
|
||||
});
|
||||
};
|
||||
|
@ -192,23 +241,15 @@ function ContainerController($scope, $routeParams, $location, Container, Message
|
|||
};
|
||||
|
||||
$scope.getChanges = function() {
|
||||
ViewSpinner.spin();
|
||||
Container.changes({id: $routeParams.id}, function(d) {
|
||||
$scope.changes = d;
|
||||
ViewSpinner.stop();
|
||||
});
|
||||
};
|
||||
|
||||
Container.get({id: $routeParams.id}, function(d) {
|
||||
$scope.container = d;
|
||||
}, function(e) {
|
||||
if (e.status === 404) {
|
||||
$('.detail').hide();
|
||||
Messages.error("Not found", "Container not found.");
|
||||
} else {
|
||||
Messages.error("Failure", e.data);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.getChanges();
|
||||
update();
|
||||
$scope.getChanges();
|
||||
}
|
||||
|
||||
// Controller for the list of containers
|
||||
|
@ -220,8 +261,8 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner
|
|||
var update = function(data) {
|
||||
ViewSpinner.spin();
|
||||
Container.query(data, function(d) {
|
||||
$scope.containers = d.map(function(item) {
|
||||
return new ContainerViewModel(item); });
|
||||
$scope.containers = d.map(function(item) {
|
||||
return new ContainerViewModel(item); });
|
||||
ViewSpinner.stop();
|
||||
});
|
||||
};
|
||||
|
@ -233,22 +274,25 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner
|
|||
counter = counter -1;
|
||||
if (counter === 0) {
|
||||
ViewSpinner.stop();
|
||||
update({all: Settings.displayAll ? 1 : 0});
|
||||
}
|
||||
};
|
||||
angular.forEach(items, function(c) {
|
||||
if (c.Checked) {
|
||||
counter = counter + 1;
|
||||
action({id: c.Id}, function(d) {
|
||||
angular.forEach(items, function(c) {
|
||||
if (c.Checked) {
|
||||
counter = counter + 1;
|
||||
action({id: c.Id}, function(d) {
|
||||
Messages.send("Container " + msg, c.Id);
|
||||
var index = $scope.containers.indexOf(c);
|
||||
$scope.containers.splice(index, 1);
|
||||
complete();
|
||||
}, function(e) {
|
||||
}, function(e) {
|
||||
Messages.error("Failure", e.data);
|
||||
complete();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (counter === 0) {
|
||||
ViewSpinner.stop();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.toggleSelectAll = function() {
|
||||
|
@ -274,6 +318,14 @@ function ContainersController($scope, Container, Settings, Messages, ViewSpinner
|
|||
batch($scope.containers, Container.kill, "Killed");
|
||||
};
|
||||
|
||||
$scope.pauseAction = function() {
|
||||
batch($scope.containers, Container.pause, "Paused");
|
||||
};
|
||||
|
||||
$scope.unpauseAction = function() {
|
||||
batch($scope.containers, Container.unpause, "Unpaused");
|
||||
};
|
||||
|
||||
$scope.removeAction = function() {
|
||||
batch($scope.containers, Container.remove, "Removed");
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue