1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 21:35:23 +02:00

refactor(app): details widget migration [EE-5352] (#8886)

This commit is contained in:
Ali 2023-05-29 15:06:14 +12:00 committed by GitHub
parent fdd79cece8
commit af77e33993
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 2046 additions and 1079 deletions

View file

@ -4,7 +4,6 @@ import PortainerError from 'Portainer/error';
import { KubernetesApplication, KubernetesApplicationDeploymentTypes, KubernetesApplicationTypes } from 'Kubernetes/models/application/models';
import KubernetesApplicationHelper from 'Kubernetes/helpers/application';
import KubernetesApplicationRollbackHelper from 'Kubernetes/helpers/application/rollback';
import KubernetesApplicationConverter from 'Kubernetes/converters/application';
import { KubernetesDeployment } from 'Kubernetes/models/deployment/models';
import { KubernetesStatefulSet } from 'Kubernetes/models/stateful-set/models';
@ -29,7 +28,6 @@ class KubernetesApplicationService {
KubernetesPersistentVolumeClaimService,
KubernetesNamespaceService,
KubernetesPodService,
KubernetesHistoryService,
KubernetesHorizontalPodAutoScalerService,
KubernetesIngressService
) {
@ -43,7 +41,6 @@ class KubernetesApplicationService {
this.KubernetesPersistentVolumeClaimService = KubernetesPersistentVolumeClaimService;
this.KubernetesNamespaceService = KubernetesNamespaceService;
this.KubernetesPodService = KubernetesPodService;
this.KubernetesHistoryService = KubernetesHistoryService;
this.KubernetesHorizontalPodAutoScalerService = KubernetesHorizontalPodAutoScalerService;
this.KubernetesIngressService = KubernetesIngressService;
@ -52,7 +49,6 @@ class KubernetesApplicationService {
this.createAsync = this.createAsync.bind(this);
this.patchAsync = this.patchAsync.bind(this);
this.patchPartialAsync = this.patchPartialAsync.bind(this);
this.rollbackAsync = this.rollbackAsync.bind(this);
this.deleteAsync = this.deleteAsync.bind(this);
}
/* #endregion */
@ -123,8 +119,6 @@ class KubernetesApplicationService {
application.AutoScaler = scaler;
application.Ingresses = ingresses;
await this.KubernetesHistoryService.get(application);
if (service.Yaml) {
application.Yaml += '---\n' + service.Yaml;
}
@ -428,18 +422,6 @@ class KubernetesApplicationService {
return this.$async(this.deleteAsync, application);
}
/* #endregion */
/* #region ROLLBACK */
async rollbackAsync(application, targetRevision) {
const payload = KubernetesApplicationRollbackHelper.getPatchPayload(application, targetRevision);
const apiService = this._getApplicationApiService(application);
await apiService.rollback(application.ResourcePool, application.Name, payload);
}
rollback(application, targetRevision) {
return this.$async(this.rollbackAsync, application, targetRevision);
}
/* #endregion */
}
export default KubernetesApplicationService;

View file

@ -13,7 +13,6 @@ class KubernetesDaemonSetService {
this.getAllAsync = this.getAllAsync.bind(this);
this.createAsync = this.createAsync.bind(this);
this.patchAsync = this.patchAsync.bind(this);
this.rollbackAsync = this.rollbackAsync.bind(this);
this.deleteAsync = this.deleteAsync.bind(this);
}
@ -110,23 +109,6 @@ class KubernetesDaemonSetService {
delete(daemonSet) {
return this.$async(this.deleteAsync, daemonSet);
}
/**
* ROLLBACK
*/
async rollbackAsync(namespace, name, payload) {
try {
const params = new KubernetesCommonParams();
params.id = name;
await this.KubernetesDaemonSets(namespace).rollback(params, payload).$promise;
} catch (err) {
throw new PortainerError('Unable to rollback daemonset', err);
}
}
rollback(namespace, name, payload) {
return this.$async(this.rollbackAsync, namespace, name, payload);
}
}
export default KubernetesDaemonSetService;

View file

@ -13,7 +13,6 @@ class KubernetesDeploymentService {
this.getAllAsync = this.getAllAsync.bind(this);
this.createAsync = this.createAsync.bind(this);
this.patchAsync = this.patchAsync.bind(this);
this.rollbackAsync = this.rollbackAsync.bind(this);
this.deleteAsync = this.deleteAsync.bind(this);
}
@ -110,23 +109,6 @@ class KubernetesDeploymentService {
delete(deployment) {
return this.$async(this.deleteAsync, deployment);
}
/**
* ROLLBACK
*/
async rollbackAsync(namespace, name, payload) {
try {
const params = new KubernetesCommonParams();
params.id = name;
await this.KubernetesDeployments(namespace).rollback(params, payload).$promise;
} catch (err) {
throw new PortainerError('Unable to rollback deployment', err);
}
}
rollback(namespace, name, payload) {
return this.$async(this.rollbackAsync, namespace, name, payload);
}
}
export default KubernetesDeploymentService;

View file

@ -1,58 +0,0 @@
import angular from 'angular';
import PortainerError from 'Portainer/error';
import KubernetesHistoryHelper from 'Kubernetes/helpers/history';
import { KubernetesApplicationTypes } from 'Kubernetes/models/application/models';
class KubernetesHistoryService {
/* @ngInject */
constructor($async, KubernetesReplicaSetService, KubernetesControllerRevisionService) {
this.$async = $async;
this.KubernetesReplicaSetService = KubernetesReplicaSetService;
this.KubernetesControllerRevisionService = KubernetesControllerRevisionService;
this.getAsync = this.getAsync.bind(this);
}
/**
* GET
*/
async getAsync(application) {
try {
const namespace = application.ResourcePool;
let rawRevisions;
switch (application.ApplicationType) {
case KubernetesApplicationTypes.DEPLOYMENT:
rawRevisions = await this.KubernetesReplicaSetService.get(namespace);
break;
case KubernetesApplicationTypes.DAEMONSET:
rawRevisions = await this.KubernetesControllerRevisionService.get(namespace);
break;
case KubernetesApplicationTypes.STATEFULSET:
rawRevisions = await this.KubernetesControllerRevisionService.get(namespace);
break;
case KubernetesApplicationTypes.POD:
rawRevisions = [];
break;
default:
throw new PortainerError('Unable to determine which association to use for history');
}
if (rawRevisions.length) {
const [currentRevision, revisionsList] = KubernetesHistoryHelper.getRevisions(rawRevisions, application);
application.CurrentRevision = currentRevision;
application.Revisions = revisionsList;
}
return application;
} catch (err) {
throw new PortainerError('', err);
}
}
get(application) {
return this.$async(this.getAsync, application);
}
}
export default KubernetesHistoryService;
angular.module('portainer.kubernetes').service('KubernetesHistoryService', KubernetesHistoryService);

View file

@ -1,31 +0,0 @@
import angular from 'angular';
import PortainerError from 'Portainer/error';
class KubernetesReplicaSetService {
/* @ngInject */
constructor($async, KubernetesReplicaSets) {
this.$async = $async;
this.KubernetesReplicaSets = KubernetesReplicaSets;
this.getAllAsync = this.getAllAsync.bind(this);
}
/**
* GET
*/
async getAllAsync(namespace) {
try {
const data = await this.KubernetesReplicaSets(namespace).get().$promise;
return data.items;
} catch (err) {
throw new PortainerError('Unable to retrieve ReplicaSets', err);
}
}
get(namespace) {
return this.$async(this.getAllAsync, namespace);
}
}
export default KubernetesReplicaSetService;
angular.module('portainer.kubernetes').service('KubernetesReplicaSetService', KubernetesReplicaSetService);

View file

@ -14,7 +14,6 @@ class KubernetesStatefulSetService {
this.getAllAsync = this.getAllAsync.bind(this);
this.createAsync = this.createAsync.bind(this);
this.patchAsync = this.patchAsync.bind(this);
this.rollbackAsync = this.rollbackAsync.bind(this);
this.deleteAsync = this.deleteAsync.bind(this);
}
@ -122,23 +121,6 @@ class KubernetesStatefulSetService {
delete(statefulSet) {
return this.$async(this.deleteAsync, statefulSet);
}
/**
* ROLLBACK
*/
async rollbackAsync(namespace, name, payload) {
try {
const params = new KubernetesCommonParams();
params.id = name;
await this.KubernetesStatefulSets(namespace).rollback(params, payload).$promise;
} catch (err) {
throw new PortainerError('Unable to rollback statefulSet', err);
}
}
rollback(namespace, name, payload) {
return this.$async(this.rollbackAsync, namespace, name, payload);
}
}
export default KubernetesStatefulSetService;