remotes update in model update

This commit is contained in:
sawka 2022-08-31 23:15:18 -07:00
parent 3ab2023423
commit 4a2b3cc381
3 changed files with 13 additions and 5 deletions

View File

@ -1369,6 +1369,9 @@ class Model {
if ("window" in update) { if ("window" in update) {
this.updateWindow(update.window, false); this.updateWindow(update.window, false);
} }
if ("remotes" in update) {
this.updateRemote(update.remotes);
}
if (interactive && "info" in update) { if (interactive && "info" in update) {
let info : InfoType = update.info; let info : InfoType = update.info;
this.inputModel.flashInfoMsg(info, info.timeoutms); this.inputModel.flashInfoMsg(info, info.timeoutms);
@ -1384,6 +1387,10 @@ class Model {
// console.log("run-update>", Date.now(), interactive, update); // console.log("run-update>", Date.now(), interactive, update);
} }
updateRemote(remotes : RemoteType[]) : void {
genMergeSimpleData(this.remotes, remotes, (r) => r.remoteid, null);
}
getActiveSession() : Session { getActiveSession() : Session {
return this.getSessionById(this.activeSessionId.get()); return this.getSessionById(this.activeSessionId.get());
} }
@ -1610,7 +1617,7 @@ class Model {
let url = new URL("http://localhost:8080/api/get-remotes"); let url = new URL("http://localhost:8080/api/get-remotes");
fetch(url).then((resp) => handleJsonFetchResponse(url, resp)).then((data) => { fetch(url).then((resp) => handleJsonFetchResponse(url, resp)).then((data) => {
mobx.action(() => { mobx.action(() => {
this.remotes.replace(data.data || []) this.runUpdate(data.data, false);
this.remotesLoaded.set(true); this.remotesLoaded.set(true);
})(); })();
}).catch((err) => { }).catch((err) => {

View File

@ -687,15 +687,15 @@ body .xterm .xterm-viewport {
.history-line { .history-line {
white-space: pre; white-space: pre;
margin-left: 58px; // 8px per char margin-left: 58px; // 7.2px
} }
&.show-remotes .history-line { &.show-remotes .history-line {
margin-left: 174px; margin-left: 173px;
} }
&.show-remotes.show-sessions .history-line { &.show-remotes.show-sessions .history-line {
margin-left: 294px; margin-left: 295px;
} }
.history-item.history-haderror { .history-item.history-haderror {

View File

@ -79,6 +79,7 @@ type RemoteType = {
status : string, status : string,
defaultstate : RemoteStateType, defaultstate : RemoteStateType,
connectmode : string, connectmode : string,
remove? : boolean,
}; };
type RemoteStateType = { type RemoteStateType = {
@ -215,7 +216,7 @@ type ModelUpdateType = {
cmd? : CmdDataType, cmd? : CmdDataType,
info? : InfoType, info? : InfoType,
cmdline? : CmdLineUpdateType, cmdline? : CmdLineUpdateType,
remote? : RemoteType, remotes? : RemoteType[],
history? : HistoryInfoType, history? : HistoryInfoType,
}; };