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

fix: terminal was broken at some point during refactoring

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-07-21 11:28:36 +03:00
parent 2658a0ac74
commit 1510091cd2
5 changed files with 15 additions and 11 deletions

View File

@ -109,7 +109,7 @@ export class Cluster implements ClusterModel {
this.disposers.push(
() => clearInterval(refreshStatusTimer),
() => clearInterval(refreshEventsTimer),
reaction(() => this.getState(), this.pushState, {
reaction(this.getState, this.pushState, {
fireImmediately: true
})
);
@ -319,8 +319,8 @@ export class Cluster implements ClusterModel {
})
}
// serializable cluster-info for push-notifications
getState(): ClusterState {
// serializable cluster-state (mostly used for push-notifications)
getState = (): ClusterState => {
const state: ClusterState = {
...this.toJSON(),
initialized: this.initialized,

View File

@ -3,7 +3,7 @@ import http from "http";
import httpProxy from "http-proxy";
import url from "url";
import * as WebSocket from "ws"
import * as nodeShell from "./node-shell-session"
import { openShell } from "./node-shell-session";
import { Router } from "./router"
import { ClusterManager } from "./cluster-manager"
import { ContextHandler } from "./context-handler";
@ -96,10 +96,10 @@ export class LensProxy {
protected createWsListener(): WebSocket.Server {
const ws = new WebSocket.Server({ noServer: true })
return ws.on("connection", (async (socket: WebSocket, req: http.IncomingMessage) => {
return ws.on("connection", ((socket: WebSocket, req: http.IncomingMessage) => {
const cluster = this.clusterManager.getClusterForRequest(req);
const nodeParam = url.parse(req.url, true).query["node"]?.toString();
await nodeShell.open(socket, cluster, nodeParam);
openShell(socket, cluster, nodeParam);
}));
}

View File

@ -133,9 +133,13 @@ export class NodeShellSession extends ShellSession {
}
}
export async function open(socket: WebSocket, cluster: Cluster, nodeName?: string): Promise<ShellSession> {
export async function openShell(socket: WebSocket, cluster: Cluster, nodeName?: string): Promise<ShellSession> {
let shell: ShellSession;
if (nodeName) {
return new NodeShellSession(socket, cluster, nodeName)
shell = new NodeShellSession(socket, cluster, nodeName)
} else {
shell = new ShellSession(socket, cluster);
}
return new ShellSession(socket, cluster);
shell.open()
return shell;
}

View File

@ -11,8 +11,6 @@ import { helmCli } from "./helm/helm-cli"
import { isWindows } from "../common/vars";
import { tracker } from "../common/tracker";
// fixme: terminal doesn't work in ui
export class ShellSession extends EventEmitter {
static shellEnvs: Map<string, any> = new Map()

View File

@ -3,6 +3,8 @@ import { observable, when } from "mobx";
import { autobind, interval } from "./utils";
import { apiBase } from "./api";
// todo: use user-store.ts as isomorphic-store with config/settings for ui
@autobind()
export class ConfigStore {
protected updater = interval(60, this.load);