mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Lens app source code (#119)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Cody Belcher <cody.t.belcher@gmail.com>
This commit is contained in:
1 parent
492ea272d1
commit
d057cb17c6
797 files changed
+73714
-215
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import groupBy from "lodash/groupBy";
|
||||
import compact from "lodash/compact";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { eventApi, KubeEvent } from "../../api/endpoints/events.api";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import { Pod } from "../../api/endpoints/pods.api";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@autobind()
|
||||
export class EventStore extends KubeObjectStore<KubeEvent> {
|
||||
api = eventApi
|
||||
limit = 1000
|
||||
|
||||
protected bindWatchEventsUpdater() {
|
||||
return super.bindWatchEventsUpdater(5000);
|
||||
}
|
||||
|
||||
protected sortItems(items: KubeEvent[]) {
|
||||
return super.sortItems(items, [
|
||||
event => event.metadata.creationTimestamp
|
||||
], "desc")
|
||||
}
|
||||
|
||||
getEventsByObject(obj: KubeObject): KubeEvent[] {
|
||||
return this.items.filter(evt => {
|
||||
return obj.getId() == evt.involvedObject.uid;
|
||||
});
|
||||
}
|
||||
|
||||
getWarnings() {
|
||||
const warnings = this.items.filter(event => event.type == "Warning");
|
||||
const groupsByInvolvedObject = groupBy(warnings, warning => warning.involvedObject.uid);
|
||||
const eventsWithError = Object.values(groupsByInvolvedObject).map(events => {
|
||||
const recent = events[0];
|
||||
const { kind, uid } = recent.involvedObject;
|
||||
if (kind == Pod.kind) { // Wipe out running pods
|
||||
const pod = podsStore.items.find(pod => pod.getId() == uid);
|
||||
if (!pod || (!pod.hasIssues() && pod.spec.priority < 500000)) return;
|
||||
}
|
||||
return recent;
|
||||
});
|
||||
return compact(eventsWithError);
|
||||
}
|
||||
}
|
||||
|
||||
export const eventStore = new EventStore();
|
||||
apiManager.registerStore(eventApi, eventStore);
|
||||
Reference in new issue
Block a user