1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00
portainer/app/docker/views/dashboard/dashboardController.js
Chaim Lev-Ari 3c34fbd8f2
refactor(router): show endpoint id in url (#3966)
* refactor(module): provide basic endpoint id url

* fix(stacks): fix route to include endpointId

* fix(stacks): fix stacks urls

* fix(sidebar): fix urls to docker routes

* refactor(app): set endpoint id on change view

* refactor(dashboard): revert to old version

* refactor(sidebar): revert file

* feat(app): wip load endpoint on route change

* feat(home): show error

* feat(app): load endpoint route

* feat(sidebar): show endpoint per provider

* refactor(app): revert

* refactor(app): clean endpoint startup

* feat(edge): check for edge k8s

* refactor(endpoints): move all modules under endpoint route

* refactor(stacks): move stacks route to docker

* refactor(templates): move templates route to docker

* refactor(app): check endpoint when entering docker module

* fix(app): load endpoint when entering endpoints modules

* feat(azure): check endpoint

* feat(kubernetes): check endpoint

* feat(home): show loading state when loading edge

* style(app): revert small changes

* refactor(sidebar): remove refernce to endpointId

* fix(stacks): fix stacks route

* style(docker): sort routes

* feat(app): change route to home if endpoint failed

* fix(services): guard against empty snapshots

* feat(app): show error when failed to load endpoint

* feat(app): reload home route when failing

* refactor(router): replace resolvers with onEnter
2020-07-15 08:46:38 +12:00

69 lines
2.1 KiB
JavaScript

angular.module('portainer.docker').controller('DashboardController', [
'$scope',
'$q',
'ContainerService',
'ImageService',
'NetworkService',
'VolumeService',
'SystemService',
'ServiceService',
'StackService',
'EndpointService',
'Notifications',
'EndpointProvider',
'StateManager',
function (
$scope,
$q,
ContainerService,
ImageService,
NetworkService,
VolumeService,
SystemService,
ServiceService,
StackService,
EndpointService,
Notifications,
EndpointProvider,
StateManager
) {
$scope.dismissInformationPanel = function (id) {
StateManager.dismissInformationPanel(id);
};
$scope.offlineMode = false;
function initView() {
const endpointMode = $scope.applicationState.endpoint.mode;
const endpointId = EndpointProvider.endpointID();
$scope.endpointId = endpointId;
$q.all({
containers: ContainerService.containers(1),
images: ImageService.images(false),
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),
info: SystemService.info(),
endpoint: EndpointService.endpoint(endpointId),
})
.then(function success(data) {
$scope.containers = data.containers;
$scope.images = data.images;
$scope.volumeCount = data.volumes.length;
$scope.networkCount = data.networks.length;
$scope.serviceCount = data.services.length;
$scope.stackCount = data.stacks.length;
$scope.info = data.info;
$scope.endpoint = data.endpoint;
$scope.offlineMode = EndpointProvider.offlineMode();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to load dashboard data');
});
}
initView();
},
]);