mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fixes
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
2287332f8b
commit
2894f31adb
@ -3,6 +3,12 @@ import { ClusterId, clusterStore } from "./cluster-store";
|
||||
import { tracker } from "./tracker";
|
||||
|
||||
export const clusterIpc = {
|
||||
init: createIpcChannel({
|
||||
channel: "cluster:init",
|
||||
handle: async (clusterId: ClusterId) => {
|
||||
return clusterStore.getById(clusterId)?.pushState();
|
||||
},
|
||||
}),
|
||||
activate: createIpcChannel({
|
||||
channel: "cluster:activate",
|
||||
handle: async (clusterId: ClusterId = clusterStore.activeClusterId) => {
|
||||
|
||||
@ -64,7 +64,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.on("cluster:state", (event, clusterState: ClusterState) => {
|
||||
this.applyWithoutSync(() => {
|
||||
logger.info(`[CLUSTER-STORE]: received state update for cluster=${clusterState.id}`, clusterState);
|
||||
logger.debug(`[CLUSTER-STORE]: received state update for cluster=${clusterState.id}`, clusterState);
|
||||
const cluster = this.getById(clusterState.id);
|
||||
if (cluster) cluster.updateModel(clusterState)
|
||||
})
|
||||
|
||||
@ -42,7 +42,7 @@ export class ClusterManager {
|
||||
}
|
||||
|
||||
getClusterForRequest(req: http.IncomingMessage): Cluster {
|
||||
logger.info(`getClusterForRequest(): ${req.headers.host}${req.url}`)
|
||||
logger.debug(`getClusterForRequest(): ${req.headers.host}${req.url}`)
|
||||
const clusterId = req.headers.host.split(".")[0]
|
||||
return this.getCluster(clusterId)
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import type { ClusterId, ClusterModel, ClusterPreferences } from "../common/clus
|
||||
import type { IMetricsReqParams } from "../renderer/api/endpoints/metrics.api";
|
||||
import type { WorkspaceId } from "../common/workspace-store";
|
||||
import type { FeatureStatusMap } from "./feature"
|
||||
import { action, computed, observable, reaction, toJS, when } from "mobx";
|
||||
import { action, observable, reaction, toJS, when } from "mobx";
|
||||
import { apiKubePrefix } from "../common/vars";
|
||||
import { broadcastIpc } from "../common/ipc";
|
||||
import { ContextHandler } from "./context-handler"
|
||||
@ -217,6 +217,7 @@ export class Cluster implements ClusterModel {
|
||||
return request(apiUrl, {
|
||||
json: true,
|
||||
timeout: 5000,
|
||||
...options,
|
||||
headers: {
|
||||
Host: `${this.id}.${new URL(this.kubeProxyUrl).host}`, // required in ClusterManager.getClusterForRequest()
|
||||
...(options.headers || {}),
|
||||
@ -228,6 +229,7 @@ export class Cluster implements ClusterModel {
|
||||
const prometheusPrefix = this.preferences.prometheus?.prefix || "";
|
||||
const metricsPath = `/api/v1/namespaces/${prometheusPath}/proxy${prometheusPrefix}/api/v1/query_range`;
|
||||
return this.k8sRequest(metricsPath, {
|
||||
timeout: 0,
|
||||
resolveWithFullResponse: false,
|
||||
json: true,
|
||||
qs: queryParams,
|
||||
|
||||
@ -44,21 +44,21 @@ export class ClusterStatus extends React.Component<Props> {
|
||||
error: res.error,
|
||||
});
|
||||
})
|
||||
// await this.refreshClusterState();
|
||||
await this.refreshCluster();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
ipcRenderer.removeAllListeners(`kube-auth:${this.clusterId}`);
|
||||
}
|
||||
|
||||
async refreshClusterState() {
|
||||
refreshCluster = async () => {
|
||||
await clusterIpc.activate.invokeFromRenderer(this.clusterId);
|
||||
}
|
||||
|
||||
reconnect = async () => {
|
||||
this.authOutput = [{ data: "Reconnecting..." }];
|
||||
this.isReconnecting = true;
|
||||
await this.refreshClusterState();
|
||||
await this.refreshCluster();
|
||||
this.isReconnecting = false;
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import { ClusterId, clusterStore } from "../../../common/cluster-store";
|
||||
import { getMatchedClusterId } from "./cluster-view.route";
|
||||
import { ClusterStatus } from "./cluster-status";
|
||||
import logger from "../../../main/logger";
|
||||
import { clusterIpc } from "../../../common/cluster-ipc";
|
||||
|
||||
@observer
|
||||
export class ClusterView extends React.Component {
|
||||
@ -24,7 +25,7 @@ export class ClusterView extends React.Component {
|
||||
autorun(() => {
|
||||
if (this.cluster) {
|
||||
this.initView(this.cluster.id)
|
||||
this.activateView(this.cluster.id)
|
||||
this.attachView(this.cluster.id)
|
||||
}
|
||||
})
|
||||
])
|
||||
@ -39,12 +40,11 @@ export class ClusterView extends React.Component {
|
||||
webview.setAttribute("src", `//${clusterId}.${location.host}`)
|
||||
webview.setAttribute("nodeintegration", "true")
|
||||
webview.setAttribute("enableremotemodule", "true")
|
||||
// webview.addEventListener("did-start-loading", () => {
|
||||
// webview.openDevTools();
|
||||
// });
|
||||
webview.addEventListener("did-finish-load", () => {
|
||||
// webview.openDevTools()
|
||||
webview.classList.add("loaded");
|
||||
ClusterView.isLoaded.set(clusterId, true)
|
||||
clusterIpc.init.invokeFromRenderer(clusterId); // push-state to webview
|
||||
ClusterView.isLoaded.set(clusterId, true);
|
||||
});
|
||||
webview.addEventListener("did-fail-load", (event) => {
|
||||
logger.error("failed to load lens-webview", event)
|
||||
@ -53,12 +53,10 @@ export class ClusterView extends React.Component {
|
||||
ClusterView.views.set(clusterId, webview);
|
||||
}
|
||||
|
||||
activateView = async (clusterId: ClusterId) => {
|
||||
const cluster = clusterStore.getById(clusterId);
|
||||
attachView = async (clusterId: ClusterId) => {
|
||||
const view = ClusterView.views.get(clusterId);
|
||||
const isLoaded = ClusterView.isLoaded.has(clusterId);
|
||||
const isLoaded = ClusterView.views.has(clusterId);
|
||||
if (view && isLoaded && this.placeholder) {
|
||||
cluster.pushState(); // fixme
|
||||
this.placeholder.replaceWith(view);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user