1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix cluster dashboard opening and state refreshing (#1006)

* Fix cluster dashboard opening and state refreshing

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-10-01 11:16:20 +03:00 committed by GitHub
parent f9b5ba6980
commit 135282da91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 6 deletions

View File

@ -14,6 +14,17 @@ export const clusterIpc = {
}, },
}), }),
setFrameId: createIpcChannel({
channel: "cluster:set-frame-id",
handle: (clusterId: ClusterId, frameId?: number) => {
const cluster = clusterStore.getById(clusterId);
if (cluster) {
if (frameId) cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates
return cluster.pushState();
}
},
}),
refresh: createIpcChannel({ refresh: createIpcChannel({
channel: "cluster:refresh", channel: "cluster:refresh",
handle: (clusterId: ClusterId) => { handle: (clusterId: ClusterId) => {

View File

@ -59,6 +59,7 @@ export class Cluster implements ClusterModel {
@observable online = false; @observable online = false;
@observable accessible = false; @observable accessible = false;
@observable ready = false; @observable ready = false;
@observable reconnecting = false;
@observable disconnected = true; @observable disconnected = true;
@observable failureReason: string; @observable failureReason: string;
@observable nodes = 0; @observable nodes = 0;
@ -110,7 +111,7 @@ export class Cluster implements ClusterModel {
protected bindEvents() { protected bindEvents() {
logger.info(`[CLUSTER]: bind events`, this.getMeta()); logger.info(`[CLUSTER]: bind events`, this.getMeta());
const refreshTimer = setInterval(() => this.online && this.refresh(), 30000); // every 30s const refreshTimer = setInterval(() => !this.disconnected && this.refresh(), 30000); // every 30s
this.eventDisposers.push( this.eventDisposers.push(
reaction(this.getState, this.pushState), reaction(this.getState, this.pushState),

View File

@ -11,7 +11,7 @@ import { App } from "./components/app";
import { LensApp } from "./lens-app"; import { LensApp } from "./lens-app";
type AppComponent = React.ComponentType & { type AppComponent = React.ComponentType & {
init?(): void; init?(): Promise<void>;
} }
export async function bootstrap(App: AppComponent) { export async function bootstrap(App: AppComponent) {

View File

@ -14,14 +14,15 @@ import { podsStore } from "../+workloads-pods/pods.store";
import { clusterStore } from "./cluster.store"; import { clusterStore } from "./cluster.store";
import { eventStore } from "../+events/event.store"; import { eventStore } from "../+events/event.store";
import { isAllowedResource } from "../../../common/rbac"; import { isAllowedResource } from "../../../common/rbac";
import { getHostedCluster } from "../../../common/cluster-store";
@observer @observer
export class Cluster extends React.Component { export class Cluster extends React.Component {
private dependentStores = [nodesStore, podsStore]; private dependentStores = [nodesStore, podsStore];
private watchers = [ private watchers = [
interval(60, () => clusterStore.getMetrics()), interval(60, () => { getHostedCluster().available && clusterStore.getMetrics()}),
interval(20, () => eventStore.loadAll()) interval(20, () => { getHostedCluster().available && eventStore.loadAll()})
]; ];
@computed get isLoaded() { @computed get isLoaded() {

View File

@ -44,8 +44,8 @@ export class App extends React.Component {
const clusterId = getHostedClusterId(); const clusterId = getHostedClusterId();
logger.info(`[APP]: Init dashboard, clusterId=${clusterId}, frameId=${frameId}`) logger.info(`[APP]: Init dashboard, clusterId=${clusterId}, frameId=${frameId}`)
await Terminal.preloadFonts() await Terminal.preloadFonts()
await clusterIpc.activate.invokeFromRenderer(clusterId, frameId); await clusterIpc.setFrameId.invokeFromRenderer(clusterId, frameId);
await getHostedCluster().whenReady; // cluster.refresh() is done at this point await getHostedCluster().whenReady; // cluster.activate() is done at this point
} }
get startURL() { get startURL() {