From 0b0b7307ba821ea58d5973bf264370065c5f36d6 Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 30 Sep 2022 15:42:10 -0700 Subject: [PATCH] remote showall dialog --- src/main.tsx | 90 ++++++++++++++++++++++++++++++++++++++++++---------- src/model.ts | 4 +++ src/sh2.less | 52 ++++++++++++++++++++++++------ src/types.ts | 1 + 4 files changed, 121 insertions(+), 26 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index b90671d4..87f283ba 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -672,15 +672,54 @@ class TextAreaInput extends React.Component<{}, {}> { @mobxReact.observer class InfoRemoteShowAll extends React.Component<{}, {}> { + clickRow(remoteId : string) : void { + GlobalCommandRunner.showRemote(remoteId); + } + render() { let inputModel = GlobalModel.inputModel; let infoMsg = inputModel.infoMsg.get(); if (infoMsg == null || !infoMsg.remoteshowall) { return null; } + let remotes = GlobalModel.remotes ?? []; + let remote : RemoteType = null; + let idx : number = 0; + remotes = sortAndFilterRemotes(remotes); return (
- showall + + + + + + + + + + + + + this.clickRow(remote.remoteid)}> + + + + + + + + +
statusidaliasuser@hostconnectmode
+
+
+ {remote.remoteid.substr(0, 8)} + + {isBlank(remote.remotealias) ? "-" : remote.remotealias} + + {remote.remotecanonicalname} + + {remote.connectmode} +
); } @@ -856,7 +895,7 @@ class InfoRemoteShow extends React.Component<{}, {}> { class InfoRemoteEdit extends React.Component<{}, {}> { alias : mobx.IObservableValue; hostName : mobx.IObservableValue; - userName : mobx.IObservableValue; + keyStr : mobx.IObservableValue; portStr : mobx.IObservableValue; colorStr : mobx.IObservableValue; connectMode : mobx.IObservableValue; @@ -871,7 +910,7 @@ class InfoRemoteEdit extends React.Component<{}, {}> { resetForm() { this.alias = mobx.observable.box(""); this.hostName = mobx.observable.box(""); - this.userName = mobx.observable.box(""); + this.keyStr = mobx.observable.box(""); this.portStr = mobx.observable.box("22"); this.colorStr = mobx.observable.box(""); this.connectMode = mobx.observable.box("startup"); @@ -881,7 +920,7 @@ class InfoRemoteEdit extends React.Component<{}, {}> { @boundMethod doCreateRemote() { - let cname = this.userName.get() + "@" + this.hostName.get(); + let cname = this.hostName.get(); let kwargs : Record = {}; if (this.alias.get() != "") { kwargs["alias"] = this.alias.get(); @@ -895,6 +934,9 @@ class InfoRemoteEdit extends React.Component<{}, {}> { if (this.colorStr.get() != "") { kwargs["color"] = this.colorStr.get(); } + if (this.keyStr.get() != "") { + kwargs["key"] = this.keyStr.get(); + } kwargs["connectmode"] = this.connectMode.get(); if (!this.autoInstallBool.get()) { kwargs["autoinstall"] = "0"; @@ -904,7 +946,6 @@ class InfoRemoteEdit extends React.Component<{}, {}> { console.log("create remote", cname, kwargs); mobx.action(() => { GlobalCommandRunner.createRemote(cname, kwargs); - this.resetForm(); })(); } @@ -945,9 +986,9 @@ class InfoRemoteEdit extends React.Component<{}, {}> { } @boundMethod - onChangeUserName(e : any) { + onChangeKeyStr(e : any) { mobx.action(() => { - this.userName.set(e.target.value); + this.keyStr.set(e.target.value); })(); } @@ -991,6 +1032,13 @@ class InfoRemoteEdit extends React.Component<{}, {}> { })(); } + remoteCName() : string { + if (this.hostName.get() == "") { + return "[no host]"; + } + return this.hostName.get(); + } + render() { let inputModel = GlobalModel.inputModel; let infoMsg = inputModel.infoMsg.get(); @@ -1013,7 +1061,7 @@ class InfoRemoteEdit extends React.Component<{}, {}> {
- add new remote + add new remote '{this.remoteCName()}' edit remote @@ -1032,15 +1080,15 @@ class InfoRemoteEdit extends React.Component<{}, {}> {
-
hostname
+
user@host
-
username
+
ssh keyfile
- +
@@ -1049,7 +1097,7 @@ class InfoRemoteEdit extends React.Component<{}, {}> {
-
+
sudo
@@ -1082,6 +1130,16 @@ class InfoRemoteEdit extends React.Component<{}, {}> {
+ +
+ {redit.errorstr} +
+
+ +
+ {redit.infostr} +
+
[create remote] {"|"} @@ -1139,7 +1197,9 @@ class InfoMsg extends React.Component<{}, {}> {
- + + + 0}> @@ -1720,9 +1780,7 @@ class MainSideBar extends React.Component<{}, {}> { } clickRemotes() { - mobx.action(() => { - GlobalModel.remotesModalOpen.set(true); - })(); + GlobalCommandRunner.showAllRemotes(); } remoteDisplayName(remote : RemoteType) : any { diff --git a/src/model.ts b/src/model.ts index 674c55c7..ffa276e8 100644 --- a/src/model.ts +++ b/src/model.ts @@ -1868,6 +1868,10 @@ class CommandRunner { GlobalModel.submitCommand("remote", "show", null, {"nohist": "1", "remote": remoteid}, true); } + showAllRemotes() { + GlobalModel.submitCommand("remote", "showall", null, {"nohist": "1"}, true); + } + connectRemote(remoteid : string) { GlobalModel.submitCommand("remote", "connect", null, {"nohist": "1", "remote": remoteid}, true); } diff --git a/src/sh2.less b/src/sh2.less index c0b287e9..236dfe9f 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -28,6 +28,8 @@ @tab-black-text: #333; @tab-white-text: #d7d7d7; +@soft-blue: #729fcf; + .mono-font(@size: inherit, @weight: inherit) { font-family: 'JetBrains Mono', monospace; font-size: @size; @@ -510,11 +512,11 @@ html, body, #main { } &.status-running { - background-color: #729fcf; + background-color: @soft-blue; } &.status-detached { - background-color: #729fcf; + background-color: @soft-blue; .status-icon { top: 3px; right: 3px; @@ -530,7 +532,7 @@ html, body, #main { margin-top: -4px; .user { - color: lighten(#729fcf, 10%); + color: lighten(@soft-blue, 10%); font-weight: bold; margin-top: 1px; margin-right: 10px; @@ -720,7 +722,7 @@ body .xterm .xterm-viewport { left: 20px; background-color: black; .mono-font(12px, 600); - color: #729fcf; + color: @soft-blue; padding-bottom: 4px; display: flex; flex-direction: row; @@ -800,19 +802,19 @@ body .xterm .xterm-viewport { .info-msg { .mono-font(14px, 400); - color: #729fcf; + color: @soft-blue; padding-bottom: 2px; } .info-title { .mono-font(14px, 600); - color: #729fcf; + color: @soft-blue; padding-bottom: 2px; } .info-lines { .mono-font(12px); - color: #d3d7cf; + color: @term-white; white-space: pre; padding-bottom: 6px; } @@ -825,20 +827,45 @@ body .xterm .xterm-viewport { .info-comp { min-width: 200px; - color: #d3d7cf; + color: @term-white; } .metacmd-comp { - color: #8ae234; + color: @term-bright-green; } } .info-error { .mono-font(14px, 600); - color: #cc0000; + color: @term-red; padding-bottom: 2px; } + .info-remote-showall { + table.remotes-table { + th { + color: white; + font-weight: bold; + } + + th, td { + padding: 3px 8px 3px 8px; + } + + td { + cursor: pointer; + } + + td.status-cell { + text-align: center; + } + + tr:hover td { + background-color: #333; + } + } + } + .info-remote { color: #d3d7cf; .mono-font(12px); @@ -848,6 +875,11 @@ body .xterm .xterm-viewport { color: @term-cyan; } + .info-error, .info-msg { + margin-top: 5px; + padding: 5px; + } + .remote-field { display: flex; flex-direction: row; diff --git a/src/types.ts b/src/types.ts index 7431bdb1..2a7cbd2e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -284,6 +284,7 @@ type RemoteEditType = { remoteedit : boolean, remoteid? : string, errorstr? : string, + infostr? : string, }; type InfoType = {