1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00
portainer/app/kubernetes/services/stackService.js
Marcelo Rydel fbcf67bc1e
filter empty stacks in dropdown (#5771)
filter empty stacks in dropdown (#5771)
2021-09-30 09:32:38 -03:00

28 lines
785 B
JavaScript

import _ from 'lodash-es';
import angular from 'angular';
class KubernetesStackService {
/* @ngInject */
constructor($async, KubernetesApplicationService) {
this.$async = $async;
this.KubernetesApplicationService = KubernetesApplicationService;
this.getAllAsync = this.getAllAsync.bind(this);
}
/**
* GET
*/
async getAllAsync(namespace) {
const applications = await this.KubernetesApplicationService.get(namespace);
const stacks = _.map(applications, (item) => item.StackName);
return _.uniq(_.without(stacks, '-', ''));
}
get(namespace) {
return this.$async(this.getAllAsync, namespace);
}
}
export default KubernetesStackService;
angular.module('portainer.kubernetes').service('KubernetesStackService', KubernetesStackService);