mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Load all pods in node details
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
91ccaf2ca9
commit
28b84f4cf8
@ -31,6 +31,10 @@ import type { GetActiveClusterEntity } from "../../api/catalog/entity/get-active
|
||||
import getActiveClusterEntityInjectable from "../../api/catalog/entity/get-active-cluster-entity.injectable";
|
||||
import type { ClusterMetricData, RequestClusterMetricsByNodeNames } from "../../../common/k8s-api/endpoints/metrics.api/request-cluster-metrics-by-node-names.injectable";
|
||||
import requestClusterMetricsByNodeNamesInjectable from "../../../common/k8s-api/endpoints/metrics.api/request-cluster-metrics-by-node-names.injectable";
|
||||
import type { ShowNotification } from "../notifications/notifications";
|
||||
import type { NamespaceStore } from "../+namespaces/store";
|
||||
import namespaceStoreInjectable from "../+namespaces/store.injectable";
|
||||
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
|
||||
|
||||
export interface NodeDetailsProps extends KubeObjectDetailsProps<Node> {
|
||||
}
|
||||
@ -40,6 +44,8 @@ interface Dependencies {
|
||||
podStore: PodStore;
|
||||
getActiveClusterEntity: GetActiveClusterEntity;
|
||||
requestClusterMetricsByNodeNames: RequestClusterMetricsByNodeNames;
|
||||
namespaceStore: NamespaceStore;
|
||||
showErrorNotification: ShowNotification;
|
||||
}
|
||||
|
||||
@observer
|
||||
@ -55,6 +61,7 @@ class NonInjectedNodeDetails extends React.Component<NodeDetailsProps & Dependen
|
||||
disposeOnUnmount(this, [
|
||||
reaction(() => this.props.object.getName(), () => {
|
||||
this.metrics = null;
|
||||
this.loadAllPods();
|
||||
}),
|
||||
|
||||
this.props.subscribeStores([
|
||||
@ -63,6 +70,14 @@ class NonInjectedNodeDetails extends React.Component<NodeDetailsProps & Dependen
|
||||
]);
|
||||
}
|
||||
|
||||
loadAllPods() {
|
||||
this.props.podStore.loadAll({
|
||||
namespaces: [...this.props.namespaceStore.getItems().map(ns => ns.getName())],
|
||||
onLoadFailure: error =>
|
||||
this.props.showErrorNotification(`Can not load Pods. ${String(error)}`)
|
||||
});
|
||||
}
|
||||
|
||||
loadMetrics = async () => {
|
||||
const { object: node, requestClusterMetricsByNodeNames } = this.props;
|
||||
|
||||
@ -196,8 +211,10 @@ export const NodeDetails = withInjectables<Dependencies, NodeDetailsProps>(NonIn
|
||||
...props,
|
||||
subscribeStores: di.inject(subscribeStoresInjectable),
|
||||
podStore: di.inject(podStoreInjectable),
|
||||
namespaceStore: di.inject(namespaceStoreInjectable),
|
||||
getActiveClusterEntity: di.inject(getActiveClusterEntityInjectable),
|
||||
requestClusterMetricsByNodeNames: di.inject(requestClusterMetricsByNodeNamesInjectable),
|
||||
showErrorNotification: di.inject(showErrorNotificationInjectable)
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@ -21,10 +21,6 @@ import { Spinner } from "../spinner";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import type { PodStore } from "./store";
|
||||
import podStoreInjectable from "./store.injectable";
|
||||
import namespaceStoreInjectable from "../+namespaces/store.injectable";
|
||||
import type { NamespaceStore } from "../+namespaces/store";
|
||||
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
|
||||
import type { ShowNotification } from "../notifications/notifications";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
@ -43,8 +39,6 @@ export interface PodDetailsListProps {
|
||||
interface Dependencies {
|
||||
getDetailsUrl: GetDetailsUrl;
|
||||
podStore: PodStore;
|
||||
namespaceStore: NamespaceStore;
|
||||
showErrorNotification: ShowNotification;
|
||||
}
|
||||
|
||||
@observer
|
||||
@ -58,14 +52,6 @@ export class NonInjectedPodDetailsList extends React.Component<PodDetailsListPro
|
||||
disposeOnUnmount(this, [
|
||||
reaction(() => this.props.pods[0]?.getNs(), () => this.metricsWatcher.restart(true)),
|
||||
]);
|
||||
|
||||
this.props.podStore.loadAll({
|
||||
namespaces: [
|
||||
...this.props.namespaceStore.getItems().map(ns => ns.getName())
|
||||
],
|
||||
onLoadFailure: error =>
|
||||
this.props.showErrorNotification(`Can not load Pods. ${String(error)}`)
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@ -222,7 +208,5 @@ export const PodDetailsList = withInjectables<Dependencies, PodDetailsListProps>
|
||||
...props,
|
||||
getDetailsUrl: di.inject(getDetailsUrlInjectable),
|
||||
podStore: di.inject(podStoreInjectable),
|
||||
namespaceStore: di.inject(namespaceStoreInjectable),
|
||||
showErrorNotification: di.inject(showErrorNotificationInjectable)
|
||||
}),
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user