mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
updates for remotestate and data structure changes
This commit is contained in:
parent
06c3a240b1
commit
9f94da43d1
28
src/main.tsx
28
src/main.tsx
@ -9,7 +9,7 @@ import dayjs from "dayjs";
|
|||||||
import {If, For, When, Otherwise, Choose} from "tsx-control-statements/components";
|
import {If, For, When, Otherwise, Choose} from "tsx-control-statements/components";
|
||||||
import cn from "classnames";
|
import cn from "classnames";
|
||||||
import {TermWrap} from "./term";
|
import {TermWrap} from "./term";
|
||||||
import type {SessionDataType, LineType, CmdDataType, RemoteType, RemoteStateType, RemoteInstanceType, RemotePtrType, HistoryItem, HistoryQueryOpts, RemoteEditType} from "./types";
|
import type {SessionDataType, LineType, CmdDataType, RemoteType, RemoteStateType, RemoteInstanceType, RemotePtrType, HistoryItem, HistoryQueryOpts, RemoteEditType, FeStateType} from "./types";
|
||||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||||
import {GlobalModel, GlobalCommandRunner, Session, Cmd, Window, Screen, ScreenWindow, riToRPtr, widthToCols, termWidthFromCols, termHeightFromRows, termRowsFromHeight} from "./model";
|
import {GlobalModel, GlobalCommandRunner, Session, Cmd, Window, Screen, ScreenWindow, riToRPtr, widthToCols, termWidthFromCols, termHeightFromRows, termRowsFromHeight} from "./model";
|
||||||
import {isModKeyPress} from "./util";
|
import {isModKeyPress} from "./util";
|
||||||
@ -103,7 +103,7 @@ function replaceHomePath(path : string, homeDir : string) : string {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCwdStr(remote : RemoteType, state : RemoteStateType) : string {
|
function getCwdStr(remote : RemoteType, state : FeStateType) : string {
|
||||||
if ((state == null || state.cwd == null) && remote != null) {
|
if ((state == null || state.cwd == null) && remote != null) {
|
||||||
return "~";
|
return "~";
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ function getCwdStr(remote : RemoteType, state : RemoteStateType) : string {
|
|||||||
cwd = state.cwd;
|
cwd = state.cwd;
|
||||||
}
|
}
|
||||||
if (remote && remote.remotevars.home) {
|
if (remote && remote.remotevars.home) {
|
||||||
cwd = replaceHomePath(cwd, remote.remotevars.home)
|
cwd = replaceHomePath(cwd, remote.remotevars.cwd)
|
||||||
}
|
}
|
||||||
return cwd;
|
return cwd;
|
||||||
}
|
}
|
||||||
@ -185,14 +185,14 @@ class LineText extends React.Component<{sw : ScreenWindow, line : LineType}, {}>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@mobxReact.observer
|
@mobxReact.observer
|
||||||
class Prompt extends React.Component<{rptr : RemotePtrType, rstate : RemoteStateType}, {}> {
|
class Prompt extends React.Component<{rptr : RemotePtrType, festate : FeStateType}, {}> {
|
||||||
render() {
|
render() {
|
||||||
let remote : RemoteType = null;
|
let remote : RemoteType = null;
|
||||||
if (this.props.rptr && !isBlank(this.props.rptr.remoteid)) {
|
if (this.props.rptr && !isBlank(this.props.rptr.remoteid)) {
|
||||||
remote = GlobalModel.getRemote(this.props.rptr.remoteid);
|
remote = GlobalModel.getRemote(this.props.rptr.remoteid);
|
||||||
}
|
}
|
||||||
let remoteStr = getRemoteStr(this.props.rptr);
|
let remoteStr = getRemoteStr(this.props.rptr);
|
||||||
let cwd = getCwdStr(remote, this.props.rstate);
|
let cwd = getCwdStr(remote, this.props.festate);
|
||||||
let isRoot = false;
|
let isRoot = false;
|
||||||
if (remote && remote.remotevars) {
|
if (remote && remote.remotevars) {
|
||||||
if (remote.remotevars["sudo"] || remote.remotevars["bestuser"] == "root") {
|
if (remote.remotevars["sudo"] || remote.remotevars["bestuser"] == "root") {
|
||||||
@ -344,10 +344,10 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let remoteStr = getRemoteStr(cmd.remote);
|
let remoteStr = getRemoteStr(cmd.remote);
|
||||||
let cwd = getCwdStr(remote, cmd.getRemoteState());
|
let cwd = getCwdStr(remote, cmd.getRemoteFeState());
|
||||||
return (
|
return (
|
||||||
<div className="metapart-mono cmdtext">
|
<div className="metapart-mono cmdtext">
|
||||||
<Prompt rptr={cmd.remote} rstate={cmd.getRemoteState()}/> {cmd.getSingleLineCmdText()}
|
<Prompt rptr={cmd.remote} festate={cmd.getRemoteFeState()}/> {cmd.getSingleLineCmdText()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1730,10 +1730,10 @@ class CmdInput extends React.Component<{}, {}> {
|
|||||||
rptr = win.curRemote.get();
|
rptr = win.curRemote.get();
|
||||||
}
|
}
|
||||||
let remote : RemoteType = null;
|
let remote : RemoteType = null;
|
||||||
let remoteState : RemoteStateType = null;
|
let remoteState : FeStateType = null;
|
||||||
if (ri != null) {
|
if (ri != null) {
|
||||||
remote = GlobalModel.getRemote(ri.remoteid);
|
remote = GlobalModel.getRemote(ri.remoteid);
|
||||||
remoteState = ri.state;
|
remoteState = ri.festate;
|
||||||
}
|
}
|
||||||
let remoteStr = getRemoteStr(rptr);
|
let remoteStr = getRemoteStr(rptr);
|
||||||
let cwdStr = getCwdStr(remote, remoteState);
|
let cwdStr = getCwdStr(remote, remoteState);
|
||||||
@ -1762,7 +1762,7 @@ class CmdInput extends React.Component<{}, {}> {
|
|||||||
<InfoMsg key="infomsg"/>
|
<InfoMsg key="infomsg"/>
|
||||||
<div key="prompt" className="cmd-input-context">
|
<div key="prompt" className="cmd-input-context">
|
||||||
<div className="has-text-white">
|
<div className="has-text-white">
|
||||||
<Prompt rptr={rptr} rstate={remoteState}/>
|
<Prompt rptr={rptr} festate={remoteState}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div key="input" className={cn("cmd-input-field field has-addons", (inputMode != null ? "inputmode-" + inputMode : null))}>
|
<div key="input" className={cn("cmd-input-field field has-addons", (inputMode != null ? "inputmode-" + inputMode : null))}>
|
||||||
@ -2475,7 +2475,7 @@ class MainSideBar extends React.Component<{}, {}> {
|
|||||||
</div>
|
</div>
|
||||||
</If>
|
</If>
|
||||||
<p className="menu-label">
|
<p className="menu-label">
|
||||||
<a onClick={() => this.clickRemotes()}>Remotes</a>
|
<a onClick={() => this.clickRemotes()}>Connections</a>
|
||||||
</p>
|
</p>
|
||||||
<ul className="menu-list remotes-menu-list">
|
<ul className="menu-list remotes-menu-list">
|
||||||
<For each="remote" of={remotes}>
|
<For each="remote" of={remotes}>
|
||||||
@ -2485,7 +2485,7 @@ class MainSideBar extends React.Component<{}, {}> {
|
|||||||
</a></li>
|
</a></li>
|
||||||
</For>
|
</For>
|
||||||
<li key="add-remote" className="add-remote">
|
<li key="add-remote" className="add-remote">
|
||||||
<a onClick={() => this.handleAddRemote()}><i className="fa fa-plus"/> Add Remote</a>
|
<a onClick={() => this.handleAddRemote()}><i className="fa fa-plus"/> Add Connection</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div className="bottom-spacer"></div>
|
<div className="bottom-spacer"></div>
|
||||||
@ -2551,7 +2551,7 @@ class DisconnectedModal extends React.Component<{}, {}> {
|
|||||||
<div className="modal-background"></div>
|
<div className="modal-background"></div>
|
||||||
<div className="modal-content message">
|
<div className="modal-content message">
|
||||||
<div className="message-header">
|
<div className="message-header">
|
||||||
<p>ScriptHaus Client Disconnected</p>
|
<p>Prompt Client Disconnected</p>
|
||||||
</div>
|
</div>
|
||||||
<If condition={this.showLog.get()}>
|
<If condition={this.showLog.get()}>
|
||||||
<div className="message-content">
|
<div className="message-content">
|
||||||
@ -2600,7 +2600,7 @@ class Main extends React.Component<{}, {}> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<h1 className="title scripthaus-logo-small">
|
<h1 className="title prompt-logo-small">
|
||||||
<div className="title-cursor">█</div>
|
<div className="title-cursor">█</div>
|
||||||
prompt>
|
prompt>
|
||||||
</h1>
|
</h1>
|
||||||
|
13
src/model.ts
13
src/model.ts
@ -5,7 +5,7 @@ import {debounce} from "throttle-debounce";
|
|||||||
import {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData, boundInt, isModKeyPress} from "./util";
|
import {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeSimpleData, boundInt, isModKeyPress} from "./util";
|
||||||
import {TermWrap} from "./term";
|
import {TermWrap} from "./term";
|
||||||
import {v4 as uuidv4} from "uuid";
|
import {v4 as uuidv4} from "uuid";
|
||||||
import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize, RemoteInputPacketType} from "./types";
|
import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenWindowType, ScreenOptsType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize, RemoteInputPacketType, FeStateType} from "./types";
|
||||||
import {WSControl} from "./ws";
|
import {WSControl} from "./ws";
|
||||||
|
|
||||||
var GlobalUser = "sawka";
|
var GlobalUser = "sawka";
|
||||||
@ -165,8 +165,8 @@ class Cmd {
|
|||||||
return this.data.get().cmdstr;
|
return this.data.get().cmdstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRemoteState() : RemoteStateType {
|
getRemoteFeState() : FeStateType {
|
||||||
return this.data.get().remotestate;
|
return this.data.get().festate;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSingleLineCmdText() {
|
getSingleLineCmdText() {
|
||||||
@ -820,8 +820,7 @@ class Session {
|
|||||||
let remote = GlobalModel.getRemote(rptr.remoteid);
|
let remote = GlobalModel.getRemote(rptr.remoteid);
|
||||||
if (remote != null) {
|
if (remote != null) {
|
||||||
return {riid: "", sessionid: this.sessionId, windowid: windowId,
|
return {riid: "", sessionid: this.sessionId, windowid: windowId,
|
||||||
remoteownerid: rptr.ownerid, remoteid: rptr.remoteid, name: rptr.name,
|
remoteownerid: rptr.ownerid, remoteid: rptr.remoteid, name: rptr.name, festate: remote.defaultfestate};
|
||||||
state: remote.defaultstate};
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1611,8 +1610,8 @@ class Model {
|
|||||||
screenid : null,
|
screenid : null,
|
||||||
windowid : null,
|
windowid : null,
|
||||||
remote : null,
|
remote : null,
|
||||||
termopts : {},
|
|
||||||
winsize: null,
|
winsize: null,
|
||||||
|
linenum: null,
|
||||||
};
|
};
|
||||||
let session = this.getActiveSession();
|
let session = this.getActiveSession();
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
@ -1627,8 +1626,8 @@ class Model {
|
|||||||
}
|
}
|
||||||
let sw = screen.getActiveSW();
|
let sw = screen.getActiveSW();
|
||||||
if (sw != null) {
|
if (sw != null) {
|
||||||
rtn.termopts.cols = sw.lastCols;
|
|
||||||
rtn.winsize = {rows: sw.lastRows, cols: sw.lastCols};
|
rtn.winsize = {rows: sw.lastRows, cols: sw.lastCols};
|
||||||
|
rtn.linenum = sw.selectedLine.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ html, body, #main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.title.scripthaus-logo-small {
|
.title.prompt-logo-small {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
|
27
src/types.ts
27
src/types.ts
@ -87,7 +87,7 @@ type RemoteType = {
|
|||||||
errorstr : string,
|
errorstr : string,
|
||||||
installstatus : string,
|
installstatus : string,
|
||||||
installerrorstr : string,
|
installerrorstr : string,
|
||||||
defaultstate : RemoteStateType,
|
defaultfestate : FeStateType,
|
||||||
connectmode : string,
|
connectmode : string,
|
||||||
autoinstall : boolean,
|
autoinstall : boolean,
|
||||||
remoteidx : number,
|
remoteidx : number,
|
||||||
@ -112,11 +112,15 @@ type RemoteInstanceType = {
|
|||||||
windowid : string,
|
windowid : string,
|
||||||
remoteownerid : string,
|
remoteownerid : string,
|
||||||
remoteid : string,
|
remoteid : string,
|
||||||
state : RemoteStateType,
|
festate : FeStateType,
|
||||||
|
|
||||||
remove? : boolean,
|
remove? : boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FeStateType = {
|
||||||
|
cwd : string,
|
||||||
|
};
|
||||||
|
|
||||||
type RemotePtrType = {
|
type RemotePtrType = {
|
||||||
ownerid : string,
|
ownerid : string,
|
||||||
remoteid : string,
|
remoteid : string,
|
||||||
@ -158,20 +162,13 @@ type CmdRemoteStateType = {
|
|||||||
cwd : string,
|
cwd : string,
|
||||||
};
|
};
|
||||||
|
|
||||||
type UIContextTermOptsType = {
|
|
||||||
rows? : number,
|
|
||||||
cols? : number,
|
|
||||||
term? : string,
|
|
||||||
maxptysize? : number,
|
|
||||||
};
|
|
||||||
|
|
||||||
type UIContextType = {
|
type UIContextType = {
|
||||||
sessionid : string,
|
sessionid : string,
|
||||||
screenid : string,
|
screenid : string,
|
||||||
windowid : string,
|
windowid : string,
|
||||||
remote : RemotePtrType,
|
remote : RemotePtrType,
|
||||||
termopts : UIContextTermOptsType,
|
|
||||||
winsize : TermWinSize,
|
winsize : TermWinSize,
|
||||||
|
linenum : number,
|
||||||
};
|
};
|
||||||
|
|
||||||
type FeCmdPacketType = {
|
type FeCmdPacketType = {
|
||||||
@ -228,10 +225,8 @@ type CmdStartPacketType = {
|
|||||||
mshellpid : number,
|
mshellpid : number,
|
||||||
};
|
};
|
||||||
|
|
||||||
type CmdDonePacketType = {
|
type CmdDoneInfoType = {
|
||||||
type : string,
|
|
||||||
ts : number,
|
ts : number,
|
||||||
ck : string,
|
|
||||||
exitcode : number,
|
exitcode : number,
|
||||||
durationms : number,
|
durationms : number,
|
||||||
};
|
};
|
||||||
@ -241,12 +236,12 @@ type CmdDataType = {
|
|||||||
cmdid : string,
|
cmdid : string,
|
||||||
remote : RemotePtrType,
|
remote : RemotePtrType,
|
||||||
cmdstr : string,
|
cmdstr : string,
|
||||||
remotestate : RemoteStateType,
|
festate : FeStateType,
|
||||||
termopts : TermOptsType,
|
termopts : TermOptsType,
|
||||||
origtermopts : TermOptsType,
|
origtermopts : TermOptsType,
|
||||||
status : string,
|
status : string,
|
||||||
startpk : CmdStartPacketType,
|
startpk : CmdStartPacketType,
|
||||||
donepk : CmdDonePacketType,
|
doneinfo : CmdDoneInfoType,
|
||||||
runout : any[],
|
runout : any[],
|
||||||
rtnstate : boolean,
|
rtnstate : boolean,
|
||||||
remove? : boolean,
|
remove? : boolean,
|
||||||
@ -324,4 +319,4 @@ type HistoryQueryOpts = {
|
|||||||
|
|
||||||
type UpdateMessage = PtyDataUpdateType | ModelUpdateType;
|
type UpdateMessage = PtyDataUpdateType | ModelUpdateType;
|
||||||
|
|
||||||
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDonePacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType};
|
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, WindowDataType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDataType, ScreenDataType, ScreenOptsType, ScreenWindowType, LayoutType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType, FeStateType};
|
||||||
|
Loading…
Reference in New Issue
Block a user