You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/kubernetes/services/eventService.js

35 lines
953 B

import _ from 'lodash-es';
import angular from 'angular';
import PortainerError from 'Portainer/error';
import KubernetesEventConverter from 'Kubernetes/converters/event';
class KubernetesEventService {
/* @ngInject */
constructor($async, KubernetesEvents) {
this.$async = $async;
this.KubernetesEvents = KubernetesEvents;
this.getAllAsync = this.getAllAsync.bind(this);
}
/**
* GET
*/
async getAllAsync(namespace) {
try {
const data = await this.KubernetesEvents(namespace).get().$promise;
const res = _.map(data.items, (item) => KubernetesEventConverter.apiToEvent(item));
return res;
} catch (err) {
throw new PortainerError('Unable to retrieve events', err);
}
}
get(namespace) {
return this.$async(this.getAllAsync, namespace);
}
}
export default KubernetesEventService;
angular.module('portainer.kubernetes').service('KubernetesEventService', KubernetesEventService);