commands return CommandRtnType promise. smaller font size for settings

This commit is contained in:
sawka 2023-04-04 13:25:05 -07:00
parent 4d813aa07a
commit a46de10f42
5 changed files with 53 additions and 15 deletions

View File

@ -1016,9 +1016,7 @@ class ScreenWindowView extends React.Component<{screen : Screen}, {}> {
if (wvElem != null) {
let width = wvElem.offsetWidth;
let height = wvElem.offsetHeight;
mobx.action(() => {
this.setSize(width, height);
})();
this.setSize(width, height);
this.rszObs = new ResizeObserver(this.handleResize.bind(this));
this.rszObs.observe(wvElem);
}

View File

@ -5,7 +5,7 @@ import {debounce} from "throttle-debounce";
import {handleJsonFetchResponse, base64ToArray, genMergeData, genMergeDataMap, genMergeSimpleData, boundInt, isModKeyPress} from "./util";
import {TermWrap} from "./term";
import {v4 as uuidv4} from "uuid";
import type {SessionDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenOptsType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize, RemoteInputPacketType, FeStateType, ContextMenuOpts, RendererContext, RendererModel, PtyDataType, BookmarkType, ClientDataType, HistoryViewDataType, AlertMessageType, HistorySearchParams, FocusTypeStrs, ScreenLinesType, HistoryTypeStrs, RendererPluginType, WindowSize, ClientMigrationInfo, WebShareOpts, TermContextUnion, RemoteEditType, RemoteViewType} from "./types";
import type {SessionDataType, LineType, RemoteType, HistoryItem, RemoteInstanceType, RemotePtrType, CmdDataType, FeCmdPacketType, TermOptsType, RemoteStateType, ScreenDataType, ScreenOptsType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, UIContextType, HistoryInfoType, HistoryQueryOpts, FeInputPacketType, TermWinSize, RemoteInputPacketType, FeStateType, ContextMenuOpts, RendererContext, RendererModel, PtyDataType, BookmarkType, ClientDataType, HistoryViewDataType, AlertMessageType, HistorySearchParams, FocusTypeStrs, ScreenLinesType, HistoryTypeStrs, RendererPluginType, WindowSize, ClientMigrationInfo, WebShareOpts, TermContextUnion, RemoteEditType, RemoteViewType, CommandRtnType} from "./types";
import {WSControl} from "./ws";
import {measureText, getMonoFontSize, windowWidthToCols, windowHeightToRows, termWidthFromCols, termHeightFromRows} from "./textmeasure";
import dayjs from "dayjs";
@ -1786,8 +1786,8 @@ class HistoryViewModel {
_deleteSelected() : void {
let lineIds = Array.from(this.selectedItems.keys());
let prtn = GlobalCommandRunner.historyPurgeLines(lineIds);
prtn.then((result : boolean) => {
if (!result) {
prtn.then((result : CommandRtnType) => {
if (!result.success) {
GlobalModel.showAlert({message: "Error removing history lines."});
return;
}
@ -3081,7 +3081,7 @@ class Model {
});
}
submitCommandPacket(cmdPk : FeCmdPacketType, interactive : boolean) : Promise<boolean> {
submitCommandPacket(cmdPk : FeCmdPacketType, interactive : boolean) : Promise<CommandRtnType> {
if (this.debugCmds > 0) {
console.log("[cmd]", cmdPacketString(cmdPk));
if (this.debugCmds > 1) {
@ -3100,15 +3100,19 @@ class Model {
GlobalModel.inputModel.clearInfoMsg(true);
}
})();
return true;
return {success: true};
}).catch((err) => {
this.errorHandler("calling run-command", err, true);
return false;
let errMessage = "error running command";
if (err != null && !isBlank(err.message)) {
errMessage = err.message;
}
return {success: false, error: errMessage};
});
return prtn;
}
submitCommand(metaCmd : string, metaSubCmd : string, args : string[], kwargs : Record<string, string>, interactive : boolean) : Promise<boolean> {
submitCommand(metaCmd : string, metaSubCmd : string, args : string[], kwargs : Record<string, string>, interactive : boolean) : Promise<CommandRtnType> {
let pk : FeCmdPacketType = {
type: "fecmd",
metacmd: metaCmd,
@ -3122,7 +3126,7 @@ class Model {
return this.submitCommandPacket(pk, interactive);
}
submitRawCommand(cmdStr : string, addToHistory : boolean, interactive : boolean) : Promise<boolean> {
submitRawCommand(cmdStr : string, addToHistory : boolean, interactive : boolean) : Promise<CommandRtnType> {
let pk : FeCmdPacketType = {
type: "fecmd",
metacmd: "eval",
@ -3303,7 +3307,7 @@ class CommandRunner {
GlobalModel.submitCommand("history", null, null, kwargs, true);
}
historyPurgeLines(lines : string[]) : Promise<boolean> {
historyPurgeLines(lines : string[]) : Promise<CommandRtnType> {
let prtn = GlobalModel.submitCommand("history", "purge", lines, {"nohist": "1"}, false);
return prtn;
}

View File

@ -212,7 +212,7 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId
</div>
<div className="settings-field">
<div className="settings-label">
Web Shared
Web Sharing
</div>
<div className="settings-input">
<Toggle checked={this.tempWebShared.get()} onChange={this.handleChangeWebShare}/>
@ -231,6 +231,27 @@ class ScreenSettingsModal extends React.Component<{sessionId : string, screenId
</div>
</div>
<If condition={this.tempWebShared.get() && false}>
<div className="settings-field sub-field">
<div className="settings-label">
Share Link
</div>
<div className="settings-input">
<div className="button is-prompt-green is-outlined is-small" onClick={this.copyShareLink}>
<span>open in browser</span>
<span className="icon">
<i className="fa-sharp fa-solid fa-up-right-from-square"/>
</span>
</div>
<div className="button is-prompt-green is-outlined is-small ml-4" onClick={this.copyShareLink}>
<span>copy link</span>
<span className="icon">
<i className="fa-sharp fa-solid fa-copy"/>
</span>
</div>
</div>
</div>
</If>
</div>
<footer>
<div onClick={this.closeModal} className="button is-prompt-cancel is-outlined is-small">Cancel</div>

View File

@ -142,7 +142,7 @@ body::-webkit-scrollbar {
padding: 2px 8px 2px 4px;
z-index: 11;
font-size: 12px;
border-bottom-right-radius: 5px;
border-radius: 0 0 5px 5px;
opacity: 0.8;
display: flex;
flex-direction: column;
@ -3164,6 +3164,16 @@ input[type=checkbox] {
display: flex;
flex-direction: row;
align-items: center;
font-size: 14px;
&.settings-field.sub-field {
.settings-label {
font-weight: normal;
font-size: 13px;
text-align: right;
padding-right: 20px;
}
}
.settings-label {
font-weight: bold;

View File

@ -586,6 +586,11 @@ type RendererContainerType = {
unloadRenderer : (cmdId : string) => void,
};
type CommandRtnType = {
success : boolean,
error? : string,
};
type LineHeightChangeCallbackType = (lineNum : number, newHeight : number, oldHeight : number) => void;
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDataType, ScreenDataType, ScreenOptsType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType, FeStateType, ContextMenuOpts, RendererContext, WindowSize, RendererModel, PtyDataType, BookmarkType, ClientDataType, PlaybookType, PlaybookEntryType, HistoryViewDataType, RenderModeType, AlertMessageType, HistorySearchParams, ScreenLinesType, FocusTypeStrs, HistoryTypeStrs, RendererOpts, RendererPluginType, SimpleBlobRendererComponent, RendererModelContainerApi, RendererModelInitializeParams, RendererOptsUpdate, ClientMigrationInfo, WebShareOpts, RemoteStatusTypeStrs, WebFullScreen, WebScreen, WebLine, WebCmd, RemoteTermContext, TermContextUnion, WebRemote, PtyDataUpdate, WebShareWSMessage, LineHeightChangeCallbackType, LineFactoryProps, LineInterface, RendererContainerType, RemoteViewType};
export type {SessionDataType, LineType, RemoteType, RemoteStateType, RemoteInstanceType, HistoryItem, CmdRemoteStateType, FeCmdPacketType, TermOptsType, CmdStartPacketType, CmdDataType, ScreenDataType, ScreenOptsType, PtyDataUpdateType, ModelUpdateType, UpdateMessage, InfoType, CmdLineUpdateType, RemotePtrType, UIContextType, HistoryInfoType, HistoryQueryOpts, WatchScreenPacketType, TermWinSize, FeInputPacketType, RemoteInputPacketType, RemoteEditType, FeStateType, ContextMenuOpts, RendererContext, WindowSize, RendererModel, PtyDataType, BookmarkType, ClientDataType, PlaybookType, PlaybookEntryType, HistoryViewDataType, RenderModeType, AlertMessageType, HistorySearchParams, ScreenLinesType, FocusTypeStrs, HistoryTypeStrs, RendererOpts, RendererPluginType, SimpleBlobRendererComponent, RendererModelContainerApi, RendererModelInitializeParams, RendererOptsUpdate, ClientMigrationInfo, WebShareOpts, RemoteStatusTypeStrs, WebFullScreen, WebScreen, WebLine, WebCmd, RemoteTermContext, TermContextUnion, WebRemote, PtyDataUpdate, WebShareWSMessage, LineHeightChangeCallbackType, LineFactoryProps, LineInterface, RendererContainerType, RemoteViewType, CommandRtnType};