2018-02-01 12:27:52 +00:00
|
|
|
angular.module('portainer.docker')
|
2018-06-11 13:13:19 +00:00
|
|
|
.controller('ServicesController', ['$q', '$scope', 'ServiceService', 'ServiceHelper', 'Notifications', 'TaskService', 'TaskHelper', 'NodeService', 'ContainerService',
|
|
|
|
function ($q, $scope, ServiceService, ServiceHelper, Notifications, TaskService, TaskHelper, NodeService, ContainerService) {
|
2018-02-21 09:55:51 +00:00
|
|
|
|
2019-07-22 10:54:59 +00:00
|
|
|
$scope.getServices = getServices;
|
|
|
|
function getServices() {
|
2018-06-11 13:13:19 +00:00
|
|
|
var agentProxy = $scope.applicationState.endpoint.mode.agentProxy;
|
2017-01-24 01:28:40 +00:00
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
$q.all({
|
|
|
|
services: ServiceService.services(),
|
|
|
|
tasks: TaskService.tasks(),
|
|
|
|
containers: agentProxy ? ContainerService.containers(1) : [],
|
|
|
|
nodes: NodeService.nodes()
|
2017-12-06 11:04:02 +00:00
|
|
|
})
|
2018-06-11 13:13:19 +00:00
|
|
|
.then(function success(data) {
|
|
|
|
var services = data.services;
|
|
|
|
var tasks = data.tasks;
|
|
|
|
|
|
|
|
if (agentProxy) {
|
|
|
|
var containers = data.containers;
|
|
|
|
for (var j = 0; j < tasks.length; j++) {
|
|
|
|
var task = tasks[j];
|
|
|
|
TaskHelper.associateContainerToTask(task, containers);
|
2018-01-08 21:06:56 +00:00
|
|
|
}
|
2017-03-30 09:22:59 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
for (var i = 0; i < services.length; i++) {
|
|
|
|
var service = services[i];
|
|
|
|
ServiceHelper.associateTasksToService(service, tasks);
|
|
|
|
}
|
2017-03-12 16:24:15 +00:00
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
$scope.nodes = data.nodes;
|
|
|
|
$scope.tasks = tasks;
|
|
|
|
$scope.services = services;
|
2017-03-12 17:24:41 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2016-10-08 01:59:58 +00:00
|
|
|
$scope.services = [];
|
2017-05-23 18:56:10 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve services');
|
2016-09-23 04:54:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-22 10:54:59 +00:00
|
|
|
function initView() {
|
|
|
|
getServices();
|
|
|
|
}
|
|
|
|
|
2017-05-23 18:56:10 +00:00
|
|
|
initView();
|
2016-09-23 04:54:58 +00:00
|
|
|
}]);
|