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 cn from "classnames";
|
||||
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 {GlobalModel, GlobalCommandRunner, Session, Cmd, Window, Screen, ScreenWindow, riToRPtr, widthToCols, termWidthFromCols, termHeightFromRows, termRowsFromHeight} from "./model";
|
||||
import {isModKeyPress} from "./util";
|
||||
@ -103,7 +103,7 @@ function replaceHomePath(path : string, homeDir : string) : string {
|
||||
return path;
|
||||
}
|
||||
|
||||
function getCwdStr(remote : RemoteType, state : RemoteStateType) : string {
|
||||
function getCwdStr(remote : RemoteType, state : FeStateType) : string {
|
||||
if ((state == null || state.cwd == null) && remote != null) {
|
||||
return "~";
|
||||
}
|
||||
@ -112,7 +112,7 @@ function getCwdStr(remote : RemoteType, state : RemoteStateType) : string {
|
||||
cwd = state.cwd;
|
||||
}
|
||||
if (remote && remote.remotevars.home) {
|
||||
cwd = replaceHomePath(cwd, remote.remotevars.home)
|
||||
cwd = replaceHomePath(cwd, remote.remotevars.cwd)
|
||||
}
|
||||
return cwd;
|
||||
}
|
||||
@ -185,14 +185,14 @@ class LineText extends React.Component<{sw : ScreenWindow, line : LineType}, {}>
|
||||
}
|
||||
|
||||
@mobxReact.observer
|
||||
class Prompt extends React.Component<{rptr : RemotePtrType, rstate : RemoteStateType}, {}> {
|
||||
class Prompt extends React.Component<{rptr : RemotePtrType, festate : FeStateType}, {}> {
|
||||
render() {
|
||||
let remote : RemoteType = null;
|
||||
if (this.props.rptr && !isBlank(this.props.rptr.remoteid)) {
|
||||
remote = GlobalModel.getRemote(this.props.rptr.remoteid);
|
||||
}
|
||||
let remoteStr = getRemoteStr(this.props.rptr);
|
||||
let cwd = getCwdStr(remote, this.props.rstate);
|
||||
let cwd = getCwdStr(remote, this.props.festate);
|
||||
let isRoot = false;
|
||||
if (remote && remote.remotevars) {
|
||||
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 cwd = getCwdStr(remote, cmd.getRemoteState());
|
||||
let cwd = getCwdStr(remote, cmd.getRemoteFeState());
|
||||
return (
|
||||
<div className="metapart-mono cmdtext">
|
||||
<Prompt rptr={cmd.remote} rstate={cmd.getRemoteState()}/> {cmd.getSingleLineCmdText()}
|
||||
<Prompt rptr={cmd.remote} festate={cmd.getRemoteFeState()}/> {cmd.getSingleLineCmdText()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -1730,10 +1730,10 @@ class CmdInput extends React.Component<{}, {}> {
|
||||
rptr = win.curRemote.get();
|
||||
}
|
||||
let remote : RemoteType = null;
|
||||
let remoteState : RemoteStateType = null;
|
||||
let remoteState : FeStateType = null;
|
||||
if (ri != null) {
|
||||
remote = GlobalModel.getRemote(ri.remoteid);
|
||||
remoteState = ri.state;
|
||||
remoteState = ri.festate;
|
||||
}
|
||||
let remoteStr = getRemoteStr(rptr);
|
||||
let cwdStr = getCwdStr(remote, remoteState);
|
||||
@ -1762,7 +1762,7 @@ class CmdInput extends React.Component<{}, {}> {
|
||||
<InfoMsg key="infomsg"/>
|
||||
<div key="prompt" className="cmd-input-context">
|
||||
<div className="has-text-white">
|
||||
<Prompt rptr={rptr} rstate={remoteState}/>
|
||||
<Prompt rptr={rptr} festate={remoteState}/>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</If>
|
||||
<p className="menu-label">
|
||||
<a onClick={() => this.clickRemotes()}>Remotes</a>
|
||||
<a onClick={() => this.clickRemotes()}>Connections</a>
|
||||
</p>
|
||||
<ul className="menu-list remotes-menu-list">
|
||||
<For each="remote" of={remotes}>
|
||||
@ -2485,7 +2485,7 @@ class MainSideBar extends React.Component<{}, {}> {
|
||||
</a></li>
|
||||
</For>
|
||||
<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>
|
||||
</ul>
|
||||
<div className="bottom-spacer"></div>
|
||||
@ -2551,7 +2551,7 @@ class DisconnectedModal extends React.Component<{}, {}> {
|
||||
<div className="modal-background"></div>
|
||||
<div className="modal-content message">
|
||||
<div className="message-header">
|
||||
<p>ScriptHaus Client Disconnected</p>
|
||||
<p>Prompt Client Disconnected</p>
|
||||
</div>
|
||||
<If condition={this.showLog.get()}>
|
||||
<div className="message-content">
|
||||
@ -2600,7 +2600,7 @@ class Main extends React.Component<{}, {}> {
|
||||
render() {
|
||||
return (
|
||||
<div id="main">
|
||||
<h1 className="title scripthaus-logo-small">
|
||||
<h1 className="title prompt-logo-small">
|
||||
<div className="title-cursor">█</div>
|
||||
prompt>
|
||||
</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 {TermWrap} from "./term";
|
||||
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";
|
||||
|
||||
var GlobalUser = "sawka";
|
||||
@ -165,8 +165,8 @@ class Cmd {
|
||||
return this.data.get().cmdstr;
|
||||
}
|
||||
|
||||
getRemoteState() : RemoteStateType {
|
||||
return this.data.get().remotestate;
|
||||
getRemoteFeState() : FeStateType {
|
||||
return this.data.get().festate;
|
||||
}
|
||||
|
||||
getSingleLineCmdText() {
|
||||
@ -820,8 +820,7 @@ class Session {
|
||||
let remote = GlobalModel.getRemote(rptr.remoteid);
|
||||
if (remote != null) {
|
||||
return {riid: "", sessionid: this.sessionId, windowid: windowId,
|
||||
remoteownerid: rptr.ownerid, remoteid: rptr.remoteid, name: rptr.name,
|
||||
state: remote.defaultstate};
|
||||
remoteownerid: rptr.ownerid, remoteid: rptr.remoteid, name: rptr.name, festate: remote.defaultfestate};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1611,8 +1610,8 @@ class Model {
|
||||
screenid : null,
|
||||
windowid : null,
|
||||
remote : null,
|
||||
termopts : {},
|
||||
winsize: null,
|
||||
linenum: null,
|
||||
};
|
||||
let session = this.getActiveSession();
|
||||
if (session != null) {
|
||||
@ -1627,8 +1626,8 @@ class Model {
|
||||
}
|
||||
let sw = screen.getActiveSW();
|
||||
if (sw != null) {
|
||||
rtn.termopts.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-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
|
27
src/types.ts
27
src/types.ts
@ -87,7 +87,7 @@ type RemoteType = {
|
||||
errorstr : string,
|
||||
installstatus : string,
|
||||
installerrorstr : string,
|
||||
defaultstate : RemoteStateType,
|
||||
defaultfestate : FeStateType,
|
||||
connectmode : string,
|
||||
autoinstall : boolean,
|
||||
remoteidx : number,
|
||||
@ -112,11 +112,15 @@ type RemoteInstanceType = {
|
||||
windowid : string,
|
||||
remoteownerid : string,
|
||||
remoteid : string,
|
||||
state : RemoteStateType,
|
||||
festate : FeStateType,
|
||||
|
||||
remove? : boolean,
|
||||
}
|
||||
|
||||
type FeStateType = {
|
||||
cwd : string,
|
||||
};
|
||||
|
||||
type RemotePtrType = {
|
||||
ownerid : string,
|
||||
remoteid : string,
|
||||
@ -158,20 +162,13 @@ type CmdRemoteStateType = {
|
||||
cwd : string,
|
||||
};
|
||||
|
||||
type UIContextTermOptsType = {
|
||||
rows? : number,
|
||||
cols? : number,
|
||||
term? : string,
|
||||
maxptysize? : number,
|
||||
};
|
||||
|
||||
type UIContextType = {
|
||||
sessionid : string,
|
||||
screenid : string,
|
||||
windowid : string,
|
||||
remote : RemotePtrType,
|
||||
termopts : UIContextTermOptsType,
|
||||
winsize : TermWinSize,
|
||||
linenum : number,
|
||||
};
|
||||
|
||||
type FeCmdPacketType = {
|
||||
@ -228,10 +225,8 @@ type CmdStartPacketType = {
|
||||
mshellpid : number,
|
||||
};
|
||||
|
||||
type CmdDonePacketType = {
|
||||
type : string,
|
||||
type CmdDoneInfoType = {
|
||||
ts : number,
|
||||
ck : string,
|
||||
exitcode : number,
|
||||
durationms : number,
|
||||
};
|
||||
@ -241,12 +236,12 @@ type CmdDataType = {
|
||||
cmdid : string,
|
||||
remote : RemotePtrType,
|
||||
cmdstr : string,
|
||||
remotestate : RemoteStateType,
|
||||
festate : FeStateType,
|
||||
termopts : TermOptsType,
|
||||
origtermopts : TermOptsType,
|
||||
status : string,
|
||||
startpk : CmdStartPacketType,
|
||||
donepk : CmdDonePacketType,
|
||||
doneinfo : CmdDoneInfoType,
|
||||
runout : any[],
|
||||
rtnstate : boolean,
|
||||
remove? : boolean,
|
||||
@ -324,4 +319,4 @@ type HistoryQueryOpts = {
|
||||
|
||||
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