mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
33 lines
1013 B
TypeScript
33 lines
1013 B
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { sum } from "lodash";
|
|
import { computed, makeObservable } from "mobx";
|
|
|
|
import type { Node, NodeApi } from "../../../common/k8s-api/endpoints";
|
|
import type { KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
|
import { autoBind } from "../../utils";
|
|
|
|
export class NodeStore extends KubeObjectStore<Node, NodeApi> {
|
|
constructor(api: NodeApi, opts?: KubeObjectStoreOptions) {
|
|
super(api, opts);
|
|
|
|
makeObservable(this);
|
|
autoBind(this);
|
|
}
|
|
|
|
@computed get masterNodes() {
|
|
return this.items.filter(node => node.isMasterNode());
|
|
}
|
|
|
|
@computed get workerNodes() {
|
|
return this.items.filter(node => !node.isMasterNode());
|
|
}
|
|
|
|
getWarningsCount(): number {
|
|
return sum(this.items.map((node) => node.getWarningConditions().length));
|
|
}
|
|
}
|