1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-30 10:49:40 +02:00

refactor(endpoints): remove endpointProvider from views [EE-1136] (#5359)

[EE-1136]
This commit is contained in:
Chaim Lev-Ari 2021-12-14 09:34:54 +02:00 committed by GitHub
parent 7088da5157
commit eb9f6c77f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 408 additions and 429 deletions

View file

@ -1,6 +1,8 @@
import angular from 'angular';
import _ from 'lodash';
import { isOfflineEndpoint } from '@/portainer/helpers/endpointHelper';
angular.module('portainer.docker').controller('DashboardController', [
'$scope',
'$q',
@ -12,9 +14,7 @@ angular.module('portainer.docker').controller('DashboardController', [
'SystemService',
'ServiceService',
'StackService',
'EndpointService',
'Notifications',
'EndpointProvider',
'StateManager',
'TagService',
'endpoint',
@ -29,9 +29,7 @@ angular.module('portainer.docker').controller('DashboardController', [
SystemService,
ServiceService,
StackService,
EndpointService,
Notifications,
EndpointProvider,
StateManager,
TagService,
endpoint
@ -45,8 +43,7 @@ angular.module('portainer.docker').controller('DashboardController', [
async function initView() {
const endpointMode = $scope.applicationState.endpoint.mode;
const endpointId = EndpointProvider.endpointID();
$scope.endpointId = endpointId;
$scope.endpoint = endpoint;
$scope.showStacks = await shouldShowStacks();
@ -56,9 +53,8 @@ angular.module('portainer.docker').controller('DashboardController', [
volumes: VolumeService.volumes(),
networks: NetworkService.networks(true, true, true),
services: endpointMode.provider === 'DOCKER_SWARM_MODE' && endpointMode.role === 'MANAGER' ? ServiceService.services() : [],
stacks: StackService.stacks(true, endpointMode.provider === 'DOCKER_SWARM_MODE' && endpointMode.role === 'MANAGER', endpointId),
stacks: StackService.stacks(true, endpointMode.provider === 'DOCKER_SWARM_MODE' && endpointMode.role === 'MANAGER', endpoint.Id),
info: SystemService.info(),
endpoint: EndpointService.endpoint(endpointId),
tags: TagService.tags(),
})
.then(function success(data) {
@ -69,11 +65,10 @@ angular.module('portainer.docker').controller('DashboardController', [
$scope.serviceCount = data.services.length;
$scope.stackCount = data.stacks.length;
$scope.info = data.info;
$scope.endpoint = data.endpoint;
$scope.endpointTags = $scope.endpoint.TagIds.length
$scope.endpointTags = endpoint.TagIds.length
? _.join(
_.filter(
_.map($scope.endpoint.TagIds, (id) => {
_.map(endpoint.TagIds, (id) => {
const tag = data.tags.find((tag) => tag.Id === id);
return tag ? tag.Name : '';
}),
@ -82,7 +77,7 @@ angular.module('portainer.docker').controller('DashboardController', [
', '
)
: '-';
$scope.offlineMode = EndpointProvider.offlineMode();
$scope.offlineMode = isOfflineEndpoint(endpoint);
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to load dashboard data');