mirror of https://github.com/portainer/portainer
refactor(docker/containers): remove EndpointProvider from container service [EE-6180] (#10392)
parent
b80fcb0467
commit
8e1417b4e9
|
@ -3,14 +3,13 @@ import { genericHandler, logsHandler } from './response/handlers';
|
||||||
angular.module('portainer.docker').factory('Container', [
|
angular.module('portainer.docker').factory('Container', [
|
||||||
'$resource',
|
'$resource',
|
||||||
'API_ENDPOINT_ENDPOINTS',
|
'API_ENDPOINT_ENDPOINTS',
|
||||||
'EndpointProvider',
|
function ContainerFactory($resource, API_ENDPOINT_ENDPOINTS) {
|
||||||
function ContainerFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
|
|
||||||
'use strict';
|
'use strict';
|
||||||
return $resource(
|
return $resource(
|
||||||
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/containers/:id/:action',
|
API_ENDPOINT_ENDPOINTS + '/:environmentId/docker/containers/:id/:action',
|
||||||
{
|
{
|
||||||
name: '@name',
|
name: '@name',
|
||||||
endpointId: EndpointProvider.endpointID,
|
environmentId: '@environmentId',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
query: {
|
query: {
|
||||||
|
|
|
@ -16,25 +16,25 @@ import { formatLogs } from '../helpers/logHelper';
|
||||||
angular.module('portainer.docker').factory('ContainerService', ContainerServiceFactory);
|
angular.module('portainer.docker').factory('ContainerService', ContainerServiceFactory);
|
||||||
|
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
function ContainerServiceFactory($q, Container, $timeout) {
|
||||||
const service = {
|
const service = {
|
||||||
killContainer: withEndpointId(killContainer),
|
killContainer,
|
||||||
pauseContainer: withEndpointId(pauseContainer),
|
pauseContainer,
|
||||||
renameContainer: withEndpointId(renameContainer),
|
renameContainer,
|
||||||
restartContainer: withEndpointId(restartContainer),
|
restartContainer,
|
||||||
resumeContainer: withEndpointId(resumeContainer),
|
resumeContainer,
|
||||||
startContainer: withEndpointId(startContainer),
|
startContainer,
|
||||||
stopContainer: withEndpointId(stopContainer),
|
stopContainer,
|
||||||
recreateContainer: withEndpointId(recreateContainer),
|
recreateContainer,
|
||||||
remove: withEndpointId(removeContainer),
|
remove: removeContainer,
|
||||||
updateRestartPolicy,
|
updateRestartPolicy,
|
||||||
updateLimits,
|
updateLimits,
|
||||||
};
|
};
|
||||||
|
|
||||||
service.container = function (id) {
|
service.container = function (environmentId, id) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
Container.get({ id: id })
|
Container.get({ environmentId, id })
|
||||||
.$promise.then(function success(data) {
|
.$promise.then(function success(data) {
|
||||||
var container = new ContainerDetailsViewModel(data);
|
var container = new ContainerDetailsViewModel(data);
|
||||||
deferred.resolve(container);
|
deferred.resolve(container);
|
||||||
|
@ -46,9 +46,9 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.containers = function (all, filters) {
|
service.containers = function (environmentId, all, filters) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
Container.query({ all: all, filters: filters })
|
Container.query({ environmentId, all, filters })
|
||||||
.$promise.then(function success(data) {
|
.$promise.then(function success(data) {
|
||||||
var containers = data.map(function (item) {
|
var containers = data.map(function (item) {
|
||||||
return new ContainerViewModel(item);
|
return new ContainerViewModel(item);
|
||||||
|
@ -62,11 +62,11 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.resizeTTY = function (id, width, height, timeout) {
|
service.resizeTTY = function (environmentId, id, width, height, timeout) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
Container.resize({}, { id: id, height: height, width: width })
|
Container.resize({}, { environmentId, id, width, height })
|
||||||
.$promise.then(function success(data) {
|
.$promise.then(function success(data) {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
deferred.reject({ msg: 'Unable to resize tty of container ' + id, err: data.message });
|
deferred.reject({ msg: 'Unable to resize tty of container ' + id, err: data.message });
|
||||||
|
@ -82,13 +82,13 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
function updateRestartPolicy(id, restartPolicy, maximumRetryCounts) {
|
function updateRestartPolicy(environmentId, id, restartPolicy, maximumRetryCounts) {
|
||||||
return Container.update({ id: id }, { RestartPolicy: { Name: restartPolicy, MaximumRetryCount: maximumRetryCounts } }).$promise;
|
return Container.update({ environmentId, id }, { RestartPolicy: { Name: restartPolicy, MaximumRetryCount: maximumRetryCounts } }).$promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLimits(id, config) {
|
function updateLimits(environmentId, id, config) {
|
||||||
return Container.update(
|
return Container.update(
|
||||||
{ id: id },
|
{ environmentId, id },
|
||||||
{
|
{
|
||||||
// MemorySwap: must be set
|
// MemorySwap: must be set
|
||||||
// -1: non limits, 0: treated as unset(cause update error).
|
// -1: non limits, 0: treated as unset(cause update error).
|
||||||
|
@ -100,9 +100,9 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
).$promise;
|
).$promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
service.createContainer = function (configuration) {
|
service.createContainer = function (environmentId, configuration) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
Container.create(configuration)
|
Container.create({ environmentId }, configuration)
|
||||||
.$promise.then(function success(data) {
|
.$promise.then(function success(data) {
|
||||||
deferred.resolve(data);
|
deferred.resolve(data);
|
||||||
})
|
})
|
||||||
|
@ -112,14 +112,14 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.createAndStartContainer = function (configuration) {
|
service.createAndStartContainer = function (environmentId, configuration) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var container;
|
var container;
|
||||||
service
|
service
|
||||||
.createContainer(configuration)
|
.createContainer(environmentId, configuration)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
container = data;
|
container = data;
|
||||||
return service.startContainer(container.Id);
|
return service.startContainer(environmentId, container.Id);
|
||||||
})
|
})
|
||||||
.then(function success() {
|
.then(function success() {
|
||||||
deferred.resolve(container);
|
deferred.resolve(container);
|
||||||
|
@ -130,10 +130,10 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.createExec = function (execConfig) {
|
service.createExec = function (environmentId, execConfig) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
Container.exec({}, execConfig)
|
Container.exec({ environmentId }, execConfig)
|
||||||
.$promise.then(function success(data) {
|
.$promise.then(function success(data) {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
deferred.reject({ msg: data.message, err: data.message });
|
deferred.reject({ msg: data.message, err: data.message });
|
||||||
|
@ -148,7 +148,7 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.logs = function (id, stdout, stderr, timestamps, since, tail, stripHeaders) {
|
service.logs = function (environmentId, id, stdout, stderr, timestamps, since, tail, stripHeaders) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
var parameters = {
|
var parameters = {
|
||||||
|
@ -160,7 +160,7 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
tail: tail || 'all',
|
tail: tail || 'all',
|
||||||
};
|
};
|
||||||
|
|
||||||
Container.logs(parameters)
|
Container.logs(environmentId, parameters)
|
||||||
.$promise.then(function success(data) {
|
.$promise.then(function success(data) {
|
||||||
var logs = formatLogs(data.logs, { stripHeaders, withTimestamps: !!timestamps });
|
var logs = formatLogs(data.logs, { stripHeaders, withTimestamps: !!timestamps });
|
||||||
deferred.resolve(logs);
|
deferred.resolve(logs);
|
||||||
|
@ -172,10 +172,10 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.containerStats = function (id) {
|
service.containerStats = function (environmentId, id) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
Container.stats({ id: id })
|
Container.stats({ environmentId, id })
|
||||||
.$promise.then(function success(data) {
|
.$promise.then(function success(data) {
|
||||||
var containerStats = new ContainerStatsViewModel(data);
|
var containerStats = new ContainerStatsViewModel(data);
|
||||||
deferred.resolve(containerStats);
|
deferred.resolve(containerStats);
|
||||||
|
@ -187,25 +187,17 @@ function ContainerServiceFactory($q, Container, $timeout, EndpointProvider) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.containerTop = function (id) {
|
service.containerTop = function (environmentId, id) {
|
||||||
return Container.top({ id: id }).$promise;
|
return Container.top({ environmentId, id }).$promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.inspect = function (id) {
|
service.inspect = function (environmentId, id) {
|
||||||
return Container.inspect({ id: id }).$promise;
|
return Container.inspect({ environmentId, id }).$promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.prune = function (filters) {
|
service.prune = function (environmentId, filters) {
|
||||||
return Container.prune({ filters: filters }).$promise;
|
return Container.prune({ environmentId, filters }).$promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
function withEndpointId(func) {
|
|
||||||
return function (...args) {
|
|
||||||
const endpointId = EndpointProvider.endpointID();
|
|
||||||
|
|
||||||
return func(endpointId, ...args);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@ angular.module('portainer.docker').factory('ImageService', [
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.images = function (withUsage) {
|
service.images = function ({ environmentId, withUsage } = {}) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
$q.all({
|
$q.all({
|
||||||
containers: withUsage ? ContainerService.containers(1) : [],
|
containers: withUsage ? ContainerService.containers(environmentId, 1) : [],
|
||||||
images: Image.query({}).$promise,
|
images: Image.query({}).$promise,
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
'LocalStorage',
|
'LocalStorage',
|
||||||
'CONSOLE_COMMANDS_LABEL_PREFIX',
|
'CONSOLE_COMMANDS_LABEL_PREFIX',
|
||||||
'SidebarService',
|
'SidebarService',
|
||||||
|
'endpoint',
|
||||||
function (
|
function (
|
||||||
$scope,
|
$scope,
|
||||||
$state,
|
$state,
|
||||||
|
@ -27,7 +28,8 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
HttpRequestHelper,
|
HttpRequestHelper,
|
||||||
LocalStorage,
|
LocalStorage,
|
||||||
CONSOLE_COMMANDS_LABEL_PREFIX,
|
CONSOLE_COMMANDS_LABEL_PREFIX,
|
||||||
SidebarService
|
SidebarService,
|
||||||
|
endpoint
|
||||||
) {
|
) {
|
||||||
var socket, term;
|
var socket, term;
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
|
|
||||||
let attachId = $transition$.params().id;
|
let attachId = $transition$.params().id;
|
||||||
|
|
||||||
ContainerService.container(attachId)
|
ContainerService.container(endpoint.Id, attachId)
|
||||||
.then((details) => {
|
.then((details) => {
|
||||||
if (!details.State.Running) {
|
if (!details.State.Running) {
|
||||||
Notifications.error('Failure', details, 'Container ' + attachId + ' is not running!');
|
Notifications.error('Failure', details, 'Container ' + attachId + ' is not running!');
|
||||||
|
@ -79,7 +81,7 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
.map((k) => k + '=' + params[k])
|
.map((k) => k + '=' + params[k])
|
||||||
.join('&');
|
.join('&');
|
||||||
|
|
||||||
initTerm(url, ContainerService.resizeTTY.bind(this, attachId));
|
initTerm(url, ContainerService.resizeTTY.bind(this, endpoint.Id, attachId));
|
||||||
})
|
})
|
||||||
.catch(function error(err) {
|
.catch(function error(err) {
|
||||||
Notifications.error('Error', err, 'Unable to retrieve container details');
|
Notifications.error('Error', err, 'Unable to retrieve container details');
|
||||||
|
@ -104,7 +106,7 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
Cmd: commandStringToArray(command),
|
Cmd: commandStringToArray(command),
|
||||||
};
|
};
|
||||||
|
|
||||||
ContainerService.createExec(execConfig)
|
ContainerService.createExec(endpoint.Id, execConfig)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
const params = {
|
const params = {
|
||||||
endpointId: $state.params.endpointId,
|
endpointId: $state.params.endpointId,
|
||||||
|
@ -217,7 +219,7 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
|
|
||||||
$scope.initView = function () {
|
$scope.initView = function () {
|
||||||
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
||||||
return ContainerService.container($transition$.params().id)
|
return ContainerService.container(endpoint.Id, $transition$.params().id)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var container = data;
|
var container = data;
|
||||||
$scope.container = container;
|
$scope.container = container;
|
||||||
|
|
|
@ -528,7 +528,7 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
||||||
function removeNewContainer() {
|
function removeNewContainer() {
|
||||||
return findCurrentContainer().then(function onContainerLoaded(container) {
|
return findCurrentContainer().then(function onContainerLoaded(container) {
|
||||||
if (container && (!oldContainer || container.Id !== oldContainer.Id)) {
|
if (container && (!oldContainer || container.Id !== oldContainer.Id)) {
|
||||||
return ContainerService.remove(container, true);
|
return ContainerService.remove(endpoint.Id, container, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
||||||
if (!oldContainer) {
|
if (!oldContainer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return ContainerService.renameContainer(oldContainer.Id, oldContainer.Names[0]);
|
return ContainerService.renameContainer(endpoint.Id, oldContainer.Id, oldContainer.Names[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmCreateContainer(container) {
|
function confirmCreateContainer(container) {
|
||||||
|
@ -573,11 +573,11 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
||||||
if (oldContainer.State !== 'running') {
|
if (oldContainer.State !== 'running') {
|
||||||
return $q.when();
|
return $q.when();
|
||||||
}
|
}
|
||||||
return ContainerService.stopContainer(oldContainer.Id);
|
return ContainerService.stopContainer(endpoint.Id, oldContainer.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renameContainer() {
|
function renameContainer() {
|
||||||
return ContainerService.renameContainer(oldContainer.Id, oldContainer.Names[0] + '-old');
|
return ContainerService.renameContainer(endpoint.Id, oldContainer.Id, oldContainer.Names[0] + '-old');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pullImageIfNeeded() {
|
function pullImageIfNeeded() {
|
||||||
|
@ -587,7 +587,7 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
||||||
function createNewContainer() {
|
function createNewContainer() {
|
||||||
return $async(async () => {
|
return $async(async () => {
|
||||||
const config = prepareConfiguration();
|
const config = prepareConfiguration();
|
||||||
return await ContainerService.createAndStartContainer(config);
|
return await ContainerService.createAndStartContainer(endpoint.Id, config);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ angular.module('portainer.docker').controller('CreateContainerController', [
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerService.remove(oldContainer, true).then(notifyOnRemoval).catch(notifyOnRemoveError);
|
ContainerService.remove(endpoint.Id, oldContainer, true).then(notifyOnRemoval).catch(notifyOnRemoveError);
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ angular.module('portainer.docker').controller('ContainerController', [
|
||||||
HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
|
HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
|
||||||
$scope.nodeName = nodeName;
|
$scope.nodeName = nodeName;
|
||||||
|
|
||||||
ContainerService.container($transition$.params().id)
|
ContainerService.container(endpoint.Id, $transition$.params().id)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var container = data;
|
var container = data;
|
||||||
$scope.container = container;
|
$scope.container = container;
|
||||||
|
@ -158,7 +158,7 @@ angular.module('portainer.docker').controller('ContainerController', [
|
||||||
};
|
};
|
||||||
|
|
||||||
function executeContainerAction(id, action, successMessage, errorMessage) {
|
function executeContainerAction(id, action, successMessage, errorMessage) {
|
||||||
action(id)
|
action(endpoint.Id, id)
|
||||||
.then(function success() {
|
.then(function success() {
|
||||||
Notifications.success(successMessage, id);
|
Notifications.success(successMessage, id);
|
||||||
update();
|
update();
|
||||||
|
@ -210,7 +210,7 @@ angular.module('portainer.docker').controller('ContainerController', [
|
||||||
$scope.container.edit = false;
|
$scope.container.edit = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ContainerService.renameContainer($transition$.params().id, container.newContainerName)
|
ContainerService.renameContainer(endpoint.Id, $transition$.params().id, container.newContainerName)
|
||||||
.then(function success() {
|
.then(function success() {
|
||||||
container.Name = container.newContainerName;
|
container.Name = container.newContainerName;
|
||||||
Notifications.success('Container successfully renamed', container.Name);
|
Notifications.success('Container successfully renamed', container.Name);
|
||||||
|
@ -292,7 +292,7 @@ angular.module('portainer.docker').controller('ContainerController', [
|
||||||
};
|
};
|
||||||
|
|
||||||
function removeContainer(cleanAssociatedVolumes) {
|
function removeContainer(cleanAssociatedVolumes) {
|
||||||
ContainerService.remove($scope.container, cleanAssociatedVolumes)
|
ContainerService.remove(endpoint.Id, $scope.container.Id, cleanAssociatedVolumes)
|
||||||
.then(function success() {
|
.then(function success() {
|
||||||
Notifications.success('Success', 'Container successfully removed');
|
Notifications.success('Success', 'Container successfully removed');
|
||||||
$state.go('docker.containers', {}, { reload: true });
|
$state.go('docker.containers', {}, { reload: true });
|
||||||
|
@ -306,7 +306,7 @@ angular.module('portainer.docker').controller('ContainerController', [
|
||||||
var container = $scope.container;
|
var container = $scope.container;
|
||||||
$scope.state.recreateContainerInProgress = true;
|
$scope.state.recreateContainerInProgress = true;
|
||||||
|
|
||||||
return ContainerService.recreateContainer(container.Id, pullImage).then(notifyAndChangeView).catch(notifyOnError);
|
return ContainerService.recreateContainer(endpoint.Id, container.Id, pullImage).then(notifyAndChangeView).catch(notifyOnError);
|
||||||
|
|
||||||
function notifyAndChangeView() {
|
function notifyAndChangeView() {
|
||||||
Notifications.success('Success', 'Container successfully re-created');
|
Notifications.success('Success', 'Container successfully re-created');
|
||||||
|
@ -333,7 +333,7 @@ angular.module('portainer.docker').controller('ContainerController', [
|
||||||
function updateRestartPolicy(restartPolicy, maximumRetryCount) {
|
function updateRestartPolicy(restartPolicy, maximumRetryCount) {
|
||||||
maximumRetryCount = restartPolicy === 'on-failure' ? maximumRetryCount : undefined;
|
maximumRetryCount = restartPolicy === 'on-failure' ? maximumRetryCount : undefined;
|
||||||
|
|
||||||
return ContainerService.updateRestartPolicy($scope.container.Id, restartPolicy, maximumRetryCount).then(onUpdateSuccess).catch(notifyOnError);
|
return ContainerService.updateRestartPolicy(endpoint.Id, $scope.container.Id, restartPolicy, maximumRetryCount).then(onUpdateSuccess).catch(notifyOnError);
|
||||||
|
|
||||||
function onUpdateSuccess() {
|
function onUpdateSuccess() {
|
||||||
$scope.container.HostConfig.RestartPolicy = {
|
$scope.container.HostConfig.RestartPolicy = {
|
||||||
|
|
|
@ -4,7 +4,8 @@ angular.module('portainer.docker').controller('ContainerInspectController', [
|
||||||
'Notifications',
|
'Notifications',
|
||||||
'ContainerService',
|
'ContainerService',
|
||||||
'HttpRequestHelper',
|
'HttpRequestHelper',
|
||||||
function ($scope, $transition$, Notifications, ContainerService, HttpRequestHelper) {
|
'endpoint',
|
||||||
|
function ($scope, $transition$, Notifications, ContainerService, HttpRequestHelper, endpoint) {
|
||||||
$scope.state = {
|
$scope.state = {
|
||||||
DisplayTextView: false,
|
DisplayTextView: false,
|
||||||
};
|
};
|
||||||
|
@ -12,7 +13,7 @@ angular.module('portainer.docker').controller('ContainerInspectController', [
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
||||||
ContainerService.inspect($transition$.params().id)
|
ContainerService.inspect(endpoint.Id, $transition$.params().id)
|
||||||
.then(function success(d) {
|
.then(function success(d) {
|
||||||
$scope.containerInfo = d;
|
$scope.containerInfo = d;
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,8 @@ angular.module('portainer.docker').controller('ContainerLogsController', [
|
||||||
'ContainerService',
|
'ContainerService',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
'HttpRequestHelper',
|
'HttpRequestHelper',
|
||||||
function ($scope, $transition$, $interval, ContainerService, Notifications, HttpRequestHelper) {
|
'endpoint',
|
||||||
|
function ($scope, $transition$, $interval, ContainerService, Notifications, HttpRequestHelper, endpoint) {
|
||||||
$scope.state = {
|
$scope.state = {
|
||||||
refreshRate: 3,
|
refreshRate: 3,
|
||||||
lineCount: 100,
|
lineCount: 100,
|
||||||
|
@ -39,6 +40,7 @@ angular.module('portainer.docker').controller('ContainerLogsController', [
|
||||||
var refreshRate = $scope.state.refreshRate;
|
var refreshRate = $scope.state.refreshRate;
|
||||||
$scope.repeater = $interval(function () {
|
$scope.repeater = $interval(function () {
|
||||||
ContainerService.logs(
|
ContainerService.logs(
|
||||||
|
endpoint.Id,
|
||||||
$transition$.params().id,
|
$transition$.params().id,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
@ -58,7 +60,16 @@ angular.module('portainer.docker').controller('ContainerLogsController', [
|
||||||
}
|
}
|
||||||
|
|
||||||
function startLogPolling(skipHeaders) {
|
function startLogPolling(skipHeaders) {
|
||||||
ContainerService.logs($transition$.params().id, 1, 1, $scope.state.displayTimestamps ? 1 : 0, moment($scope.state.sinceTimestamp).unix(), $scope.state.lineCount, skipHeaders)
|
ContainerService.logs(
|
||||||
|
endpoint.Id,
|
||||||
|
$transition$.params().id,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
$scope.state.displayTimestamps ? 1 : 0,
|
||||||
|
moment($scope.state.sinceTimestamp).unix(),
|
||||||
|
$scope.state.lineCount,
|
||||||
|
skipHeaders
|
||||||
|
)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
$scope.logs = data;
|
$scope.logs = data;
|
||||||
setUpdateRepeater(skipHeaders);
|
setUpdateRepeater(skipHeaders);
|
||||||
|
@ -71,7 +82,7 @@ angular.module('portainer.docker').controller('ContainerLogsController', [
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
||||||
ContainerService.container($transition$.params().id)
|
ContainerService.container(endpoint.Id, $transition$.params().id)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var container = data;
|
var container = data;
|
||||||
$scope.container = container;
|
$scope.container = container;
|
||||||
|
|
|
@ -10,7 +10,8 @@ angular.module('portainer.docker').controller('ContainerStatsController', [
|
||||||
'ChartService',
|
'ChartService',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
'HttpRequestHelper',
|
'HttpRequestHelper',
|
||||||
function ($q, $scope, $transition$, $document, $interval, ContainerService, ChartService, Notifications, HttpRequestHelper) {
|
'endpoint',
|
||||||
|
function ($q, $scope, $transition$, $document, $interval, ContainerService, ChartService, Notifications, HttpRequestHelper, endpoint) {
|
||||||
$scope.state = {
|
$scope.state = {
|
||||||
refreshRate: '5',
|
refreshRate: '5',
|
||||||
networkStatsUnavailable: false,
|
networkStatsUnavailable: false,
|
||||||
|
@ -95,8 +96,8 @@ angular.module('portainer.docker').controller('ContainerStatsController', [
|
||||||
|
|
||||||
function startChartUpdate(networkChart, cpuChart, memoryChart, ioChart) {
|
function startChartUpdate(networkChart, cpuChart, memoryChart, ioChart) {
|
||||||
$q.all({
|
$q.all({
|
||||||
stats: ContainerService.containerStats($transition$.params().id),
|
stats: ContainerService.containerStats(endpoint.Id, $transition$.params().id),
|
||||||
top: ContainerService.containerTop($transition$.params().id),
|
top: ContainerService.containerTop(endpoint.Id, $transition$.params().id),
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var stats = data.stats;
|
var stats = data.stats;
|
||||||
|
@ -123,8 +124,8 @@ angular.module('portainer.docker').controller('ContainerStatsController', [
|
||||||
var refreshRate = $scope.state.refreshRate;
|
var refreshRate = $scope.state.refreshRate;
|
||||||
$scope.repeater = $interval(function () {
|
$scope.repeater = $interval(function () {
|
||||||
$q.all({
|
$q.all({
|
||||||
stats: ContainerService.containerStats($transition$.params().id),
|
stats: ContainerService.containerStats(endpoint.Id, $transition$.params().id),
|
||||||
top: ContainerService.containerTop($transition$.params().id),
|
top: ContainerService.containerTop(endpoint.Id, $transition$.params().id),
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var stats = data.stats;
|
var stats = data.stats;
|
||||||
|
@ -163,7 +164,7 @@ angular.module('portainer.docker').controller('ContainerStatsController', [
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
|
||||||
ContainerService.container($transition$.params().id)
|
ContainerService.container(endpoint.Id, $transition$.params().id)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
$scope.container = data;
|
$scope.container = data;
|
||||||
})
|
})
|
||||||
|
|
|
@ -79,8 +79,8 @@ angular.module('portainer.docker').controller('DashboardController', [
|
||||||
$scope.showStacks = await shouldShowStacks();
|
$scope.showStacks = await shouldShowStacks();
|
||||||
$scope.showEnvUrl = endpoint.Type !== PortainerEndpointTypes.EdgeAgentOnDockerEnvironment && endpoint.Type !== PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment;
|
$scope.showEnvUrl = endpoint.Type !== PortainerEndpointTypes.EdgeAgentOnDockerEnvironment && endpoint.Type !== PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment;
|
||||||
$q.all({
|
$q.all({
|
||||||
containers: ContainerService.containers(1),
|
containers: ContainerService.containers(endpoint.Id, 1),
|
||||||
images: ImageService.images(false),
|
images: ImageService.images(),
|
||||||
volumes: VolumeService.volumes(),
|
volumes: VolumeService.volumes(),
|
||||||
networks: NetworkService.networks(true, true, true),
|
networks: NetworkService.networks(true, true, true),
|
||||||
services: endpointMode.provider === 'DOCKER_SWARM_MODE' && endpointMode.role === 'MANAGER' ? ServiceService.services() : [],
|
services: endpointMode.provider === 'DOCKER_SWARM_MODE' && endpointMode.role === 'MANAGER' ? ServiceService.services() : [],
|
||||||
|
|
|
@ -4,9 +4,8 @@ angular.module('portainer.docker').controller('HostViewController', [
|
||||||
'Notifications',
|
'Notifications',
|
||||||
'StateManager',
|
'StateManager',
|
||||||
'AgentService',
|
'AgentService',
|
||||||
'ContainerService',
|
|
||||||
'Authentication',
|
'Authentication',
|
||||||
function HostViewController($q, SystemService, Notifications, StateManager, AgentService, ContainerService, Authentication) {
|
function HostViewController($q, SystemService, Notifications, StateManager, AgentService, Authentication) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
this.$onInit = initView;
|
this.$onInit = initView;
|
||||||
|
@ -32,12 +31,10 @@ angular.module('portainer.docker').controller('HostViewController', [
|
||||||
$q.all({
|
$q.all({
|
||||||
version: SystemService.version(),
|
version: SystemService.version(),
|
||||||
info: SystemService.info(),
|
info: SystemService.info(),
|
||||||
jobs: ctrl.state.isAdmin ? ContainerService.containers(true, { label: ['io.portainer.job.endpoint'] }) : [],
|
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
ctrl.engineDetails = buildEngineDetails(data);
|
ctrl.engineDetails = buildEngineDetails(data);
|
||||||
ctrl.hostDetails = buildHostDetails(data.info);
|
ctrl.hostDetails = buildHostDetails(data.info);
|
||||||
ctrl.jobs = data.jobs;
|
|
||||||
|
|
||||||
if (ctrl.state.isAgent && agentApiVersion > 1 && ctrl.state.enableHostManagementFeatures) {
|
if (ctrl.state.isAgent && agentApiVersion > 1 && ctrl.state.enableHostManagementFeatures) {
|
||||||
return AgentService.hostInfo(ctrl.endpoint.Id).then(function onHostInfoLoad(agentHostInfo) {
|
return AgentService.hostInfo(ctrl.endpoint.Id).then(function onHostInfoLoad(agentHostInfo) {
|
||||||
|
|
|
@ -4,9 +4,8 @@ angular.module('portainer.docker').controller('NodeDetailsViewController', [
|
||||||
'NodeService',
|
'NodeService',
|
||||||
'StateManager',
|
'StateManager',
|
||||||
'AgentService',
|
'AgentService',
|
||||||
'ContainerService',
|
|
||||||
'Authentication',
|
'Authentication',
|
||||||
function NodeDetailsViewController($q, $stateParams, NodeService, StateManager, AgentService, ContainerService, Authentication) {
|
function NodeDetailsViewController($q, $stateParams, NodeService, StateManager, AgentService, Authentication) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
ctrl.$onInit = initView;
|
ctrl.$onInit = initView;
|
||||||
|
@ -22,19 +21,15 @@ angular.module('portainer.docker').controller('NodeDetailsViewController', [
|
||||||
ctrl.state.isAdmin = Authentication.isAdmin();
|
ctrl.state.isAdmin = Authentication.isAdmin();
|
||||||
ctrl.state.enableHostManagementFeatures = ctrl.endpoint.SecuritySettings.enableHostManagementFeatures;
|
ctrl.state.enableHostManagementFeatures = ctrl.endpoint.SecuritySettings.enableHostManagementFeatures;
|
||||||
|
|
||||||
var fetchJobs = ctrl.state.isAdmin && ctrl.state.isAgent;
|
|
||||||
|
|
||||||
var nodeId = $stateParams.id;
|
var nodeId = $stateParams.id;
|
||||||
$q.all({
|
$q.all({
|
||||||
node: NodeService.node(nodeId),
|
node: NodeService.node(nodeId),
|
||||||
jobs: fetchJobs ? ContainerService.containers(true, { label: ['io.portainer.job.endpoint'] }) : [],
|
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
var node = data.node;
|
var node = data.node;
|
||||||
ctrl.originalNode = node;
|
ctrl.originalNode = node;
|
||||||
ctrl.hostDetails = buildHostDetails(node);
|
ctrl.hostDetails = buildHostDetails(node);
|
||||||
ctrl.engineDetails = buildEngineDetails(node);
|
ctrl.engineDetails = buildEngineDetails(node);
|
||||||
ctrl.nodeDetails = buildNodeDetails(node);
|
ctrl.nodeDetails = buildNodeDetails(node);
|
||||||
ctrl.jobs = data.jobs;
|
|
||||||
if (ctrl.state.isAgent) {
|
if (ctrl.state.isAgent) {
|
||||||
var agentApiVersion = applicationState.endpoint.agentApiVersion;
|
var agentApiVersion = applicationState.endpoint.agentApiVersion;
|
||||||
ctrl.state.agentApiVersion = agentApiVersion;
|
ctrl.state.agentApiVersion = agentApiVersion;
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
devices="$ctrl.devices"
|
devices="$ctrl.devices"
|
||||||
refresh-url="docker.nodes.node"
|
refresh-url="docker.nodes.node"
|
||||||
browse-url="docker.nodes.node.browse"
|
browse-url="docker.nodes.node.browse"
|
||||||
is-job-enabled="$ctrl.state.isAdmin && $ctrl.state.isAgent"
|
|
||||||
host-features-enabled="$ctrl.state.enableHostManagementFeatures"
|
host-features-enabled="$ctrl.state.enableHostManagementFeatures"
|
||||||
job-url="docker.nodes.node.job"
|
|
||||||
jobs="$ctrl.jobs"
|
|
||||||
>
|
>
|
||||||
<swarm-node-details-panel details="$ctrl.nodeDetails" original-node="$ctrl.originalNode"></swarm-node-details-panel>
|
<swarm-node-details-panel details="$ctrl.nodeDetails" original-node="$ctrl.originalNode"></swarm-node-details-panel>
|
||||||
</host-overview>
|
</host-overview>
|
||||||
|
|
|
@ -736,7 +736,7 @@ angular.module('portainer.docker').controller('ServiceController', [
|
||||||
return $q.all({
|
return $q.all({
|
||||||
volumes: VolumeService.volumes(),
|
volumes: VolumeService.volumes(),
|
||||||
tasks: TaskService.tasks({ service: [service.Name] }),
|
tasks: TaskService.tasks({ service: [service.Name] }),
|
||||||
containers: agentProxy ? ContainerService.containers() : [],
|
containers: agentProxy ? ContainerService.containers(endpoint.Id) : [],
|
||||||
nodes: NodeService.nodes(),
|
nodes: NodeService.nodes(),
|
||||||
secrets: apiVersion >= 1.25 ? SecretService.secrets() : [],
|
secrets: apiVersion >= 1.25 ? SecretService.secrets() : [],
|
||||||
configs: apiVersion >= 1.3 ? ConfigService.configs(endpoint.Id) : [],
|
configs: apiVersion >= 1.3 ? ConfigService.configs(endpoint.Id) : [],
|
||||||
|
|
|
@ -20,7 +20,7 @@ angular.module('portainer.docker').controller('ServicesController', [
|
||||||
.all({
|
.all({
|
||||||
services: ServiceService.services(),
|
services: ServiceService.services(),
|
||||||
tasks: TaskService.tasks(),
|
tasks: TaskService.tasks(),
|
||||||
containers: agentProxy ? ContainerService.containers(1) : [],
|
containers: agentProxy ? ContainerService.containers(endpoint.Id, 1) : [],
|
||||||
nodes: NodeService.nodes(),
|
nodes: NodeService.nodes(),
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
|
|
|
@ -9,7 +9,8 @@ angular.module('portainer.docker').controller('VolumeController', [
|
||||||
'ContainerService',
|
'ContainerService',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
'HttpRequestHelper',
|
'HttpRequestHelper',
|
||||||
function ($scope, $state, $transition$, VolumeService, ContainerService, Notifications, HttpRequestHelper) {
|
'endpoint',
|
||||||
|
function ($scope, $state, $transition$, VolumeService, ContainerService, Notifications, HttpRequestHelper, endpoint) {
|
||||||
$scope.resourceType = ResourceControlType.Volume;
|
$scope.resourceType = ResourceControlType.Volume;
|
||||||
|
|
||||||
$scope.onUpdateResourceControlSuccess = function () {
|
$scope.onUpdateResourceControlSuccess = function () {
|
||||||
|
@ -46,7 +47,7 @@ angular.module('portainer.docker').controller('VolumeController', [
|
||||||
$scope.volume = volume;
|
$scope.volume = volume;
|
||||||
var containerFilter = { volume: [volume.Id] };
|
var containerFilter = { volume: [volume.Id] };
|
||||||
|
|
||||||
return ContainerService.containers(1, containerFilter);
|
return ContainerService.containers(endpoint.Id, 1, containerFilter);
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var dataContainers = $scope.isCioDriver ? data.containers : data;
|
var dataContainers = $scope.isCioDriver ? data.containers : data;
|
||||||
|
|
|
@ -126,10 +126,10 @@ angular.module('portainer.app').factory('StackService', [
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.externalComposeStacks = function () {
|
service.externalComposeStacks = function (environmentId) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
ContainerService.containers(1)
|
ContainerService.containers(environmentId, 1)
|
||||||
.then(function success(containers) {
|
.then(function success(containers) {
|
||||||
deferred.resolve(StackHelper.getExternalStacksFromContainers(containers));
|
deferred.resolve(StackHelper.getExternalStacksFromContainers(containers));
|
||||||
})
|
})
|
||||||
|
@ -160,7 +160,7 @@ angular.module('portainer.app').factory('StackService', [
|
||||||
|
|
||||||
$q.all({
|
$q.all({
|
||||||
stacks: Stack.query({ filters: filters }).$promise,
|
stacks: Stack.query({ filters: filters }).$promise,
|
||||||
externalStacks: includeExternalStacks ? service.externalComposeStacks() : [],
|
externalStacks: includeExternalStacks ? service.externalComposeStacks(endpointId) : [],
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var stacks = data.stacks.map(function (item) {
|
var stacks = data.stacks.map(function (item) {
|
||||||
|
|
|
@ -345,7 +345,7 @@ angular
|
||||||
|
|
||||||
$scope.composeSyntaxMaxVersion = endpoint.ComposeSyntaxMaxVersion;
|
$scope.composeSyntaxMaxVersion = endpoint.ComposeSyntaxMaxVersion;
|
||||||
try {
|
try {
|
||||||
const containers = await ContainerService.containers(true);
|
const containers = await ContainerService.containers(endpoint.Id, true);
|
||||||
$scope.containerNames = ContainerHelper.getContainerNames(containers);
|
$scope.containerNames = ContainerHelper.getContainerNames(containers);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Notifications.error('Failure', err, 'Unable to retrieve Containers');
|
Notifications.error('Failure', err, 'Unable to retrieve Containers');
|
||||||
|
|
|
@ -332,7 +332,7 @@ angular.module('portainer.app').controller('StackController', [
|
||||||
$q.all({
|
$q.all({
|
||||||
stack: StackService.stack(id),
|
stack: StackService.stack(id),
|
||||||
groups: GroupService.groups(),
|
groups: GroupService.groups(),
|
||||||
containers: ContainerService.containers(true),
|
containers: ContainerService.containers(endpoint.Id, true),
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var stack = data.stack;
|
var stack = data.stack;
|
||||||
|
@ -386,7 +386,7 @@ angular.module('portainer.app').controller('StackController', [
|
||||||
return $q.all({
|
return $q.all({
|
||||||
services: ServiceService.services(stackFilter),
|
services: ServiceService.services(stackFilter),
|
||||||
tasks: TaskService.tasks(stackFilter),
|
tasks: TaskService.tasks(stackFilter),
|
||||||
containers: agentProxy ? ContainerService.containers(1) : [],
|
containers: agentProxy ? ContainerService.containers(endpoint.Id, 1) : [],
|
||||||
nodes: NodeService.nodes(),
|
nodes: NodeService.nodes(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ angular.module('portainer.app').controller('StackController', [
|
||||||
};
|
};
|
||||||
|
|
||||||
return $q.all({
|
return $q.all({
|
||||||
containers: ContainerService.containers(1, stackFilter),
|
containers: ContainerService.containers(endpoint.Id, 1, stackFilter),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ angular.module('portainer.app').controller('TemplatesController', [
|
||||||
return ImageService.pullImage(template.RegistryModel, true);
|
return ImageService.pullImage(template.RegistryModel, true);
|
||||||
})
|
})
|
||||||
.then(function success() {
|
.then(function success() {
|
||||||
return ContainerService.createAndStartContainer(templateConfiguration);
|
return ContainerService.createAndStartContainer(endpoint.Id, templateConfiguration);
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
const resourceControl = data.Portainer.ResourceControl;
|
const resourceControl = data.Portainer.ResourceControl;
|
||||||
|
|
Loading…
Reference in New Issue