mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
refactor(endpoints): remove endpointProvider from views [EE-1136] (#5359)
[EE-1136]
This commit is contained in:
parent
7088da5157
commit
eb9f6c77f4
56 changed files with 408 additions and 429 deletions
|
@ -4,5 +4,6 @@ angular.module('portainer.kubernetes').component('kubernetesApplicationConsoleVi
|
|||
controllerAs: 'ctrl',
|
||||
bindings: {
|
||||
$transition$: '<',
|
||||
endpoint: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,12 +4,11 @@ import { baseHref } from '@/portainer/helpers/pathHelper';
|
|||
|
||||
class KubernetesApplicationConsoleController {
|
||||
/* @ngInject */
|
||||
constructor($async, $state, Notifications, KubernetesApplicationService, EndpointProvider, LocalStorage) {
|
||||
constructor($async, $state, Notifications, KubernetesApplicationService, LocalStorage) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.Notifications = Notifications;
|
||||
this.KubernetesApplicationService = KubernetesApplicationService;
|
||||
this.EndpointProvider = EndpointProvider;
|
||||
this.LocalStorage = LocalStorage;
|
||||
|
||||
this.onInit = this.onInit.bind(this);
|
||||
|
@ -52,7 +51,7 @@ class KubernetesApplicationConsoleController {
|
|||
connectConsole() {
|
||||
const params = {
|
||||
token: this.LocalStorage.getJWT(),
|
||||
endpointId: this.EndpointProvider.endpointID(),
|
||||
endpointId: this.endpoint.Id,
|
||||
namespace: this.application.ResourcePool,
|
||||
podName: this.podName,
|
||||
containerName: this.containerName,
|
||||
|
|
|
@ -4,5 +4,6 @@ angular.module('portainer.kubernetes').component('kubernetesApplicationView', {
|
|||
controllerAs: 'ctrl',
|
||||
bindings: {
|
||||
$transition$: '<',
|
||||
endpoint: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -112,7 +112,7 @@ class KubernetesApplicationController {
|
|||
KubernetesStackService,
|
||||
KubernetesPodService,
|
||||
KubernetesNodeService,
|
||||
EndpointProvider,
|
||||
|
||||
StackService
|
||||
) {
|
||||
this.$async = $async;
|
||||
|
@ -131,7 +131,6 @@ class KubernetesApplicationController {
|
|||
|
||||
this.KubernetesApplicationDeploymentTypes = KubernetesApplicationDeploymentTypes;
|
||||
this.KubernetesApplicationTypes = KubernetesApplicationTypes;
|
||||
this.EndpointProvider = EndpointProvider;
|
||||
this.KubernetesDeploymentTypes = KubernetesDeploymentTypes;
|
||||
|
||||
this.ApplicationDataAccessPolicies = KubernetesApplicationDataAccessPolicies;
|
||||
|
@ -365,7 +364,7 @@ class KubernetesApplicationController {
|
|||
placementWarning: false,
|
||||
expandedNote: false,
|
||||
useIngress: false,
|
||||
useServerMetrics: this.EndpointProvider.currentEndpoint().Kubernetes.Configuration.UseServerMetrics,
|
||||
useServerMetrics: this.endpoint.Kubernetes.Configuration.UseServerMetrics,
|
||||
};
|
||||
|
||||
this.state.activeTab = this.LocalStorage.getActiveTab('application');
|
||||
|
|
|
@ -2,4 +2,7 @@ angular.module('portainer.kubernetes').component('kubernetesDashboardView', {
|
|||
templateUrl: './dashboard.html',
|
||||
controller: 'KubernetesDashboardController',
|
||||
controllerAs: 'ctrl',
|
||||
bindings: {
|
||||
endpoint: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -9,7 +9,6 @@ class KubernetesDashboardController {
|
|||
$async,
|
||||
Notifications,
|
||||
EndpointService,
|
||||
EndpointProvider,
|
||||
KubernetesResourcePoolService,
|
||||
KubernetesApplicationService,
|
||||
KubernetesConfigurationService,
|
||||
|
@ -20,7 +19,6 @@ class KubernetesDashboardController {
|
|||
this.$async = $async;
|
||||
this.Notifications = Notifications;
|
||||
this.EndpointService = EndpointService;
|
||||
this.EndpointProvider = EndpointProvider;
|
||||
this.KubernetesResourcePoolService = KubernetesResourcePoolService;
|
||||
this.KubernetesApplicationService = KubernetesApplicationService;
|
||||
this.KubernetesConfigurationService = KubernetesConfigurationService;
|
||||
|
@ -37,16 +35,13 @@ class KubernetesDashboardController {
|
|||
const isAdmin = this.Authentication.isAdmin();
|
||||
|
||||
try {
|
||||
const endpointId = this.EndpointProvider.endpointID();
|
||||
const [endpoint, pools, applications, configurations, volumes, tags] = await Promise.all([
|
||||
this.EndpointService.endpoint(endpointId),
|
||||
const [pools, applications, configurations, volumes, tags] = await Promise.all([
|
||||
this.KubernetesResourcePoolService.get(),
|
||||
this.KubernetesApplicationService.get(),
|
||||
this.KubernetesConfigurationService.get(),
|
||||
this.KubernetesVolumeService.get(),
|
||||
this.TagService.tags(),
|
||||
]);
|
||||
this.endpoint = endpoint;
|
||||
this.applications = applications;
|
||||
this.volumes = volumes;
|
||||
|
||||
|
|
|
@ -2,4 +2,7 @@ angular.module('portainer.kubernetes').component('kubernetesDeployView', {
|
|||
templateUrl: './deploy.html',
|
||||
controller: 'KubernetesDeployController',
|
||||
controllerAs: 'ctrl',
|
||||
bindings: {
|
||||
endpoint: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -8,26 +8,13 @@ import { KubernetesDeployManifestTypes, KubernetesDeployBuildMethods, Kubernetes
|
|||
import { buildOption } from '@/portainer/components/box-selector';
|
||||
class KubernetesDeployController {
|
||||
/* @ngInject */
|
||||
constructor(
|
||||
$async,
|
||||
$state,
|
||||
$window,
|
||||
Authentication,
|
||||
ModalService,
|
||||
Notifications,
|
||||
EndpointProvider,
|
||||
KubernetesResourcePoolService,
|
||||
StackService,
|
||||
WebhookHelper,
|
||||
CustomTemplateService
|
||||
) {
|
||||
constructor($async, $state, $window, Authentication, ModalService, Notifications, KubernetesResourcePoolService, StackService, WebhookHelper, CustomTemplateService) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.$window = $window;
|
||||
this.Authentication = Authentication;
|
||||
this.ModalService = ModalService;
|
||||
this.Notifications = Notifications;
|
||||
this.EndpointProvider = EndpointProvider;
|
||||
this.KubernetesResourcePoolService = KubernetesResourcePoolService;
|
||||
this.StackService = StackService;
|
||||
this.WebhookHelper = WebhookHelper;
|
||||
|
@ -73,7 +60,6 @@ class KubernetesDeployController {
|
|||
|
||||
this.ManifestDeployTypes = KubernetesDeployManifestTypes;
|
||||
this.BuildMethods = KubernetesDeployBuildMethods;
|
||||
this.endpointId = this.EndpointProvider.endpointID();
|
||||
|
||||
this.onChangeTemplateId = this.onChangeTemplateId.bind(this);
|
||||
this.deployAsync = this.deployAsync.bind(this);
|
||||
|
@ -246,7 +232,7 @@ class KubernetesDeployController {
|
|||
payload.ManifestURL = this.formValues.ManifestURL;
|
||||
}
|
||||
|
||||
await this.StackService.kubernetesDeploy(this.endpointId, method, payload);
|
||||
await this.StackService.kubernetesDeploy(this.endpoint.Id, method, payload);
|
||||
|
||||
this.Notifications.success('Manifest successfully deployed');
|
||||
this.state.isEditorDirty = false;
|
||||
|
|
|
@ -4,5 +4,6 @@ angular.module('portainer.kubernetes').component('kubernetesResourcePoolAccessVi
|
|||
controllerAs: 'ctrl',
|
||||
bindings: {
|
||||
$transition$: '<',
|
||||
endpoint: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,15 +6,13 @@ import KubernetesConfigMapHelper from 'Kubernetes/helpers/configMapHelper';
|
|||
|
||||
class KubernetesResourcePoolAccessController {
|
||||
/* @ngInject */
|
||||
constructor($async, $state, Notifications, KubernetesResourcePoolService, KubernetesConfigMapService, EndpointProvider, EndpointService, GroupService, AccessService) {
|
||||
constructor($async, $state, Notifications, KubernetesResourcePoolService, KubernetesConfigMapService, GroupService, AccessService) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.Notifications = Notifications;
|
||||
this.KubernetesResourcePoolService = KubernetesResourcePoolService;
|
||||
this.KubernetesConfigMapService = KubernetesConfigMapService;
|
||||
|
||||
this.EndpointProvider = EndpointProvider;
|
||||
this.EndpointService = EndpointService;
|
||||
this.GroupService = GroupService;
|
||||
this.AccessService = AccessService;
|
||||
|
||||
|
@ -36,6 +34,7 @@ class KubernetesResourcePoolAccessController {
|
|||
* Init
|
||||
*/
|
||||
async onInit() {
|
||||
const endpoint = this.endpoint;
|
||||
this.state = {
|
||||
actionInProgress: false,
|
||||
viewReady: false,
|
||||
|
@ -45,12 +44,9 @@ class KubernetesResourcePoolAccessController {
|
|||
multiselectOutput: [],
|
||||
};
|
||||
|
||||
this.endpointId = this.EndpointProvider.endpointID();
|
||||
|
||||
try {
|
||||
const name = this.$transition$.params().id;
|
||||
let [endpoint, pool, configMap] = await Promise.all([
|
||||
this.EndpointService.endpoint(this.endpointId),
|
||||
let [pool, configMap] = await Promise.all([
|
||||
this.KubernetesResourcePoolService.get(name),
|
||||
this.KubernetesConfigMapService.getAccess(KubernetesPortainerConfigMapNamespace, KubernetesPortainerConfigMapConfigName),
|
||||
]);
|
||||
|
|
|
@ -4,5 +4,6 @@ angular.module('portainer.kubernetes').component('kubernetesVolumesView', {
|
|||
controllerAs: 'ctrl',
|
||||
bindings: {
|
||||
$transition$: '<',
|
||||
endpoint: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -21,25 +21,13 @@ function computeSize(volumes) {
|
|||
|
||||
class KubernetesVolumesController {
|
||||
/* @ngInject */
|
||||
constructor(
|
||||
$async,
|
||||
$state,
|
||||
Notifications,
|
||||
Authentication,
|
||||
ModalService,
|
||||
LocalStorage,
|
||||
EndpointProvider,
|
||||
KubernetesStorageService,
|
||||
KubernetesVolumeService,
|
||||
KubernetesApplicationService
|
||||
) {
|
||||
constructor($async, $state, Notifications, Authentication, ModalService, LocalStorage, KubernetesStorageService, KubernetesVolumeService, KubernetesApplicationService) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.Notifications = Notifications;
|
||||
this.Authentication = Authentication;
|
||||
this.ModalService = ModalService;
|
||||
this.LocalStorage = LocalStorage;
|
||||
this.EndpointProvider = EndpointProvider;
|
||||
this.KubernetesStorageService = KubernetesStorageService;
|
||||
this.KubernetesVolumeService = KubernetesVolumeService;
|
||||
this.KubernetesApplicationService = KubernetesApplicationService;
|
||||
|
@ -87,7 +75,7 @@ class KubernetesVolumesController {
|
|||
const [volumes, applications, storages] = await Promise.all([
|
||||
this.KubernetesVolumeService.get(),
|
||||
this.KubernetesApplicationService.get(),
|
||||
this.KubernetesStorageService.get(this.state.endpointId),
|
||||
this.KubernetesStorageService.get(this.endpoint.Id),
|
||||
]);
|
||||
|
||||
this.volumes = _.map(volumes, (volume) => {
|
||||
|
@ -107,9 +95,7 @@ class KubernetesVolumesController {
|
|||
async onInit() {
|
||||
this.state = {
|
||||
viewReady: false,
|
||||
// endpointId: this.$transition$.params().endpointId, // TODO: use this when moving to endpointID in URL
|
||||
currentName: this.$state.$current.name,
|
||||
endpointId: this.EndpointProvider.endpointID(),
|
||||
activeTab: this.LocalStorage.getActiveTab('volumes'),
|
||||
isAdmin: this.Authentication.isAdmin(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue