mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
add remoteidx
This commit is contained in:
parent
a74ee69da5
commit
002876a07b
@ -87,7 +87,8 @@ CREATE TABLE remote (
|
||||
sshopts json NOT NULL,
|
||||
remoteopts json NOT NULL,
|
||||
lastconnectts bigint NOT NULL,
|
||||
archived boolean NOT NULL
|
||||
archived boolean NOT NULL,
|
||||
remoteidx int NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE cmd (
|
||||
|
@ -82,7 +82,8 @@ CREATE TABLE remote (
|
||||
sshopts json NOT NULL,
|
||||
remoteopts json NOT NULL,
|
||||
lastconnectts bigint NOT NULL,
|
||||
archived boolean NOT NULL
|
||||
archived boolean NOT NULL,
|
||||
remoteidx int NOT NULL
|
||||
);
|
||||
CREATE TABLE cmd (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
|
@ -81,6 +81,7 @@ type RemoteRuntimeState struct {
|
||||
DefaultState *sstore.RemoteState `json:"defaultstate"`
|
||||
ConnectMode string `json:"connectmode"`
|
||||
Archived bool `json:"archived"`
|
||||
RemoteIdx int64 `json:"remoteidx"`
|
||||
}
|
||||
|
||||
func logf(rem *sstore.RemoteType, fmtStr string, args ...interface{}) {
|
||||
@ -324,6 +325,7 @@ func (msh *MShellProc) GetRemoteRuntimeState() RemoteRuntimeState {
|
||||
Status: msh.Status,
|
||||
ConnectMode: msh.Remote.ConnectMode,
|
||||
Archived: msh.Remote.Archived,
|
||||
RemoteIdx: msh.Remote.RemoteIdx,
|
||||
}
|
||||
if msh.Err != nil {
|
||||
state.ErrorStr = msh.Err.Error()
|
||||
|
@ -30,7 +30,7 @@ func NumSessions(ctx context.Context) (int, error) {
|
||||
func GetAllRemotes(ctx context.Context) ([]*RemoteType, error) {
|
||||
var rtn []*RemoteType
|
||||
err := WithTx(ctx, func(tx *TxWrap) error {
|
||||
query := `SELECT * FROM remote`
|
||||
query := `SELECT * FROM remote ORDER BY remoteidx`
|
||||
marr := tx.SelectMaps(query)
|
||||
for _, m := range marr {
|
||||
rtn = append(rtn, RemoteFromMap(m))
|
||||
@ -121,6 +121,9 @@ func UpsertRemote(ctx context.Context, r *RemoteType) error {
|
||||
if tx.Exists(query, r.RemoteCanonicalName) {
|
||||
return fmt.Errorf("remote has duplicate canonicalname '%s', cannot create", r.RemoteCanonicalName)
|
||||
}
|
||||
query = `SELECT max(remoteidx) FROM remote`
|
||||
maxRemoteIdx := tx.GetInt(query)
|
||||
r.RemoteIdx = int64(maxRemoteIdx + 1)
|
||||
query = `INSERT INTO remote
|
||||
( remoteid, physicalid, remotetype, remotealias, remotecanonicalname, remotesudo, remoteuser, remotehost, connectmode, initpk, sshopts, remoteopts, lastconnectts, archived) VALUES
|
||||
(:remoteid,:physicalid,:remotetype,:remotealias,:remotecanonicalname,:remotesudo,:remoteuser,:remotehost,:connectmode,:initpk,:sshopts,:remoteopts,:lastconnectts,:archived)`
|
||||
|
@ -431,6 +431,7 @@ type RemoteType struct {
|
||||
RemoteOpts *RemoteOptsType `json:"remoteopts"`
|
||||
LastConnectTs int64 `json:"lastconnectts"`
|
||||
Archived bool `json:"archived"`
|
||||
RemoteIdx int64 `json:"remoteidx"`
|
||||
}
|
||||
|
||||
func (r *RemoteType) GetName() string {
|
||||
@ -471,6 +472,7 @@ func (r *RemoteType) ToMap() map[string]interface{} {
|
||||
rtn["remoteopts"] = quickJson(r.RemoteOpts)
|
||||
rtn["lastconnectts"] = r.LastConnectTs
|
||||
rtn["archived"] = r.Archived
|
||||
rtn["remoteidx"] = r.RemoteIdx
|
||||
return rtn
|
||||
}
|
||||
|
||||
@ -493,6 +495,7 @@ func RemoteFromMap(m map[string]interface{}) *RemoteType {
|
||||
quickSetJson(&r.RemoteOpts, m, "remoteopts")
|
||||
quickSetInt64(&r.LastConnectTs, m, "lastconnectts")
|
||||
quickSetBool(&r.Archived, m, "archived")
|
||||
quickSetInt64(&r.RemoteIdx, m, "remoteidx")
|
||||
return &r
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user