mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
remove windowid
This commit is contained in:
+1
-1
@@ -546,7 +546,7 @@ func main() {
|
||||
}
|
||||
err = sstore.ReInitFocus(context.Background())
|
||||
if err != nil {
|
||||
log.Printf("[error] resetting window focus: %v\n", err)
|
||||
log.Printf("[error] resetting screen focus: %v\n", err)
|
||||
}
|
||||
|
||||
log.Printf("PCLOUD_ENDPOINT=%s\n", pcloud.GetEndpoint())
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
ALTER TABLE remote_instance RENAME COLUMN windowid TO screenid;
|
||||
ALTER TABLE line RENAME COLUMN windowid TO screenid;
|
||||
|
||||
UPDATE remote_instance
|
||||
SET screenid = (SELECT screen.screenid FROM screen WHERE screen.windowid = remote_instance.screenid)
|
||||
WHERE screenid <> ''
|
||||
;
|
||||
|
||||
UPDATE line
|
||||
SET screenid = (SELECT screen.screenid FROM screen WHERE screen.windowid = line.screenid)
|
||||
WHERE screenid <> ''
|
||||
;
|
||||
|
||||
ALTER TABLE history DROP COLUMN windowid;
|
||||
ALTER TABLE screen DROP COLUMN windowid;
|
||||
|
||||
|
||||
+62
-55
@@ -16,53 +16,12 @@ CREATE TABLE session (
|
||||
notifynum int NOT NULL,
|
||||
archived boolean NOT NULL,
|
||||
archivedts bigint NOT NULL,
|
||||
ownerid varchar(36) NOT NULL,
|
||||
sharemode varchar(12) NOT NULL,
|
||||
accesskey varchar(36) NOT NULL
|
||||
);
|
||||
CREATE TABLE window (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
curremoteownerid varchar(36) NOT NULL,
|
||||
curremoteid varchar(36) NOT NULL,
|
||||
curremotename varchar(50) NOT NULL,
|
||||
nextlinenum int NOT NULL,
|
||||
winopts json NOT NULL,
|
||||
ownerid varchar(36) NOT NULL,
|
||||
sharemode varchar(12) NOT NULL,
|
||||
shareopts json NOT NULL,
|
||||
PRIMARY KEY (sessionid, windowid)
|
||||
);
|
||||
CREATE TABLE screen (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
name varchar(50) NOT NULL,
|
||||
activewindowid varchar(36) NOT NULL,
|
||||
screenidx int NOT NULL,
|
||||
screenopts json NOT NULL,
|
||||
ownerid varchar(36) NOT NULL,
|
||||
sharemode varchar(12) NOT NULL,
|
||||
incognito boolean NOT NULL,
|
||||
archived boolean NOT NULL,
|
||||
archivedts bigint NOT NULL,
|
||||
PRIMARY KEY (sessionid, screenid)
|
||||
);
|
||||
CREATE TABLE screen_window (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
name varchar(50) NOT NULL,
|
||||
layout json NOT NULL,
|
||||
selectedline int NOT NULL,
|
||||
anchor json NOT NULL,
|
||||
focustype varchar(12) NOT NULL,
|
||||
PRIMARY KEY (sessionid, screenid, windowid)
|
||||
);
|
||||
sharemode varchar(12) NOT NULL);
|
||||
CREATE TABLE remote_instance (
|
||||
riid varchar(36) PRIMARY KEY,
|
||||
name varchar(50) NOT NULL,
|
||||
sessionid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
remoteownerid varchar(36) NOT NULL,
|
||||
remoteid varchar(36) NOT NULL,
|
||||
festate json NOT NULL,
|
||||
@@ -84,7 +43,7 @@ CREATE TABLE state_diff (
|
||||
);
|
||||
CREATE TABLE line (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
userid varchar(36) NOT NULL,
|
||||
lineid varchar(36) NOT NULL,
|
||||
ts bigint NOT NULL,
|
||||
@@ -98,7 +57,7 @@ CREATE TABLE line (
|
||||
contentheight int NOT NULL,
|
||||
star int NOT NULL,
|
||||
archived boolean NOT NULL, renderer varchar(50) NOT NULL DEFAULT '', bookmarked boolean NOT NULL DEFAULT 0, pinned boolean NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (sessionid, windowid, lineid)
|
||||
PRIMARY KEY (sessionid, screenid, lineid)
|
||||
);
|
||||
CREATE TABLE remote (
|
||||
remoteid varchar(36) PRIMARY KEY,
|
||||
@@ -145,7 +104,6 @@ CREATE TABLE history (
|
||||
userid varchar(36) NOT NULL,
|
||||
sessionid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
lineid int NOT NULL,
|
||||
remoteownerid varchar(36) NOT NULL,
|
||||
remoteid varchar(36) NOT NULL,
|
||||
@@ -156,15 +114,6 @@ CREATE TABLE history (
|
||||
ismetacmd boolean,
|
||||
incognito boolean
|
||||
);
|
||||
CREATE TABLE activity (
|
||||
day varchar(20) PRIMARY KEY,
|
||||
uploaded boolean NOT NULL,
|
||||
tdata json NOT NULL,
|
||||
tzname varchar(50) NOT NULL,
|
||||
tzoffset int NOT NULL,
|
||||
clientversion varchar(20) NOT NULL,
|
||||
clientarch varchar(20) NOT NULL
|
||||
, buildtime varchar(20) NOT NULL DEFAULT '-', osrelease varchar(20) NOT NULL DEFAULT '-');
|
||||
CREATE TABLE bookmark (
|
||||
bookmarkid varchar(36) PRIMARY KEY,
|
||||
createdts bigint NOT NULL,
|
||||
@@ -185,3 +134,61 @@ CREATE TABLE bookmark_cmd (
|
||||
cmdid varchar(36) NOT NULL,
|
||||
PRIMARY KEY (bookmarkid, sessionid, cmdid)
|
||||
);
|
||||
CREATE TABLE activity (
|
||||
day varchar(20) PRIMARY KEY,
|
||||
uploaded boolean NOT NULL,
|
||||
tdata json NOT NULL,
|
||||
tzname varchar(50) NOT NULL,
|
||||
tzoffset int NOT NULL,
|
||||
clientversion varchar(50) NOT NULL,
|
||||
clientarch varchar(50) NOT NULL
|
||||
, buildtime varchar(20) NOT NULL DEFAULT '-', osrelease varchar(20) NOT NULL DEFAULT '-');
|
||||
CREATE TABLE playbook (
|
||||
playbookid varchar(36) PRIMARY KEY,
|
||||
playbookname varchar(100) NOT NULL,
|
||||
description text NOT NULL,
|
||||
entryids json NOT NULL
|
||||
);
|
||||
CREATE TABLE playbook_entry (
|
||||
entryid varchar(36) PRIMARY KEY,
|
||||
playbookid varchar(36) NOT NULL,
|
||||
description text NOT NULL,
|
||||
alias varchar(50) NOT NULL,
|
||||
cmdstr text NOT NULL,
|
||||
createdts bigint NOT NULL,
|
||||
updatedts bigint NOT NULL
|
||||
);
|
||||
CREATE TABLE cloud_session (
|
||||
sessionid varchar(36) PRIMARY KEY,
|
||||
viewkey varchar(50) NOT NULL,
|
||||
writekey varchar(50) NOT NULL,
|
||||
enckey varchar(100) NOT NULL,
|
||||
enctype varchar(50) NOT NULL,
|
||||
vts bigint NOT NULL,
|
||||
acl json NOT NULL
|
||||
);
|
||||
CREATE TABLE cloud_update (
|
||||
updateid varchar(36) PRIMARY KEY,
|
||||
ts bigint NOT NULL,
|
||||
updatetype varchar(50) NOT NULL,
|
||||
updatekeys json NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "screen" (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
name varchar(50) NOT NULL,
|
||||
screenidx int NOT NULL,
|
||||
screenopts json NOT NULL,
|
||||
ownerid varchar(36) NOT NULL,
|
||||
sharemode varchar(12) NOT NULL,
|
||||
curremoteownerid varchar(36) NOT NULL,
|
||||
curremoteid varchar(36) NOT NULL,
|
||||
curremotename varchar(50) NOT NULL,
|
||||
nextlinenum int NOT NULL,
|
||||
selectedline int NOT NULL,
|
||||
anchor json NOT NULL,
|
||||
focustype varchar(12) NOT NULL,
|
||||
archived boolean NOT NULL,
|
||||
archivedts bigint NOT NULL,
|
||||
PRIMARY KEY (sessionid, screenid)
|
||||
);
|
||||
|
||||
+71
-74
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,6 @@ import (
|
||||
const (
|
||||
R_Session = 1
|
||||
R_Screen = 2
|
||||
R_Window = 4
|
||||
R_Remote = 8
|
||||
R_RemoteConnected = 16
|
||||
)
|
||||
@@ -25,7 +24,6 @@ const (
|
||||
type resolvedIds struct {
|
||||
SessionId string
|
||||
ScreenId string
|
||||
WindowId string
|
||||
Remote *ResolvedRemote
|
||||
}
|
||||
|
||||
@@ -203,7 +201,6 @@ func resolveUiIds(ctx context.Context, pk *scpacket.FeCommandPacketType, rtype i
|
||||
if uictx != nil {
|
||||
rtn.SessionId = uictx.SessionId
|
||||
rtn.ScreenId = uictx.ScreenId
|
||||
rtn.WindowId = uictx.WindowId
|
||||
}
|
||||
if pk.Kwargs["session"] != "" {
|
||||
sessionId, err := resolveSessionArg(pk.Kwargs["session"])
|
||||
@@ -223,15 +220,6 @@ func resolveUiIds(ctx context.Context, pk *scpacket.FeCommandPacketType, rtype i
|
||||
rtn.ScreenId = screenId
|
||||
}
|
||||
}
|
||||
if pk.Kwargs["window"] != "" {
|
||||
windowId, err := resolveWindowArg(rtn.SessionId, rtn.ScreenId, pk.Kwargs["window"])
|
||||
if err != nil {
|
||||
return rtn, err
|
||||
}
|
||||
if windowId != "" {
|
||||
rtn.WindowId = windowId
|
||||
}
|
||||
}
|
||||
var rptr *sstore.RemotePtrType
|
||||
var err error
|
||||
if pk.Kwargs["remote"] != "" {
|
||||
@@ -250,7 +238,7 @@ func resolveUiIds(ctx context.Context, pk *scpacket.FeCommandPacketType, rtype i
|
||||
if err != nil {
|
||||
return rtn, fmt.Errorf("invalid resolved remote: %v", err)
|
||||
}
|
||||
rr, err := resolveRemoteFromPtr(ctx, rptr, rtn.SessionId, rtn.WindowId)
|
||||
rr, err := resolveRemoteFromPtr(ctx, rptr, rtn.SessionId, rtn.ScreenId)
|
||||
if err != nil {
|
||||
return rtn, err
|
||||
}
|
||||
@@ -262,9 +250,6 @@ func resolveUiIds(ctx context.Context, pk *scpacket.FeCommandPacketType, rtype i
|
||||
if rtype&R_Screen > 0 && rtn.ScreenId == "" {
|
||||
return rtn, fmt.Errorf("no screen")
|
||||
}
|
||||
if rtype&R_Window > 0 && rtn.WindowId == "" {
|
||||
return rtn, fmt.Errorf("no window")
|
||||
}
|
||||
if (rtype&R_Remote > 0 || rtype&R_RemoteConnected > 0) && rtn.Remote == nil {
|
||||
return rtn, fmt.Errorf("no remote")
|
||||
}
|
||||
@@ -274,7 +259,7 @@ func resolveUiIds(ctx context.Context, pk *scpacket.FeCommandPacketType, rtype i
|
||||
if err != nil {
|
||||
return rtn, fmt.Errorf("error trying to auto-connect remote [%s]: %w", rtn.Remote.DisplayName, err)
|
||||
}
|
||||
rrNew, err := resolveRemoteFromPtr(ctx, rptr, rtn.SessionId, rtn.WindowId)
|
||||
rrNew, err := resolveRemoteFromPtr(ctx, rptr, rtn.SessionId, rtn.ScreenId)
|
||||
if err != nil {
|
||||
return rtn, err
|
||||
}
|
||||
@@ -312,8 +297,8 @@ func resolveSession(ctx context.Context, sessionArg string, curSessionArg string
|
||||
return ritem, nil
|
||||
}
|
||||
|
||||
func resolveLine(ctx context.Context, sessionId string, windowId string, lineArg string, curLineArg string) (*ResolveItem, error) {
|
||||
lines, err := sstore.GetLineResolveItems(ctx, sessionId, windowId)
|
||||
func resolveLine(ctx context.Context, sessionId string, screenId string, lineArg string, curLineArg string) (*ResolveItem, error) {
|
||||
lines, err := sstore.GetLineResolveItems(ctx, sessionId, screenId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get lines: %v", err)
|
||||
}
|
||||
@@ -402,16 +387,6 @@ func resolveSessionId(pk *scpacket.FeCommandPacketType) (string, error) {
|
||||
return sessionId, nil
|
||||
}
|
||||
|
||||
func resolveWindowArg(sessionId string, screenId string, windowArg string) (string, error) {
|
||||
if windowArg == "" {
|
||||
return "", nil
|
||||
}
|
||||
if _, err := uuid.Parse(windowArg); err != nil {
|
||||
return "", fmt.Errorf("invalid window arg specified (must be windowid) '%s'", windowArg)
|
||||
}
|
||||
return windowArg, nil
|
||||
}
|
||||
|
||||
func resolveSessionArg(sessionArg string) (string, error) {
|
||||
if sessionArg == "" {
|
||||
return "", nil
|
||||
@@ -471,7 +446,7 @@ func parseFullRemoteRef(fullRemoteRef string) (string, string, string, error) {
|
||||
return fields[0], fields[1], fields[2], nil
|
||||
}
|
||||
|
||||
func resolveRemoteFromPtr(ctx context.Context, rptr *sstore.RemotePtrType, sessionId string, windowId string) (*ResolvedRemote, error) {
|
||||
func resolveRemoteFromPtr(ctx context.Context, rptr *sstore.RemotePtrType, sessionId string, screenId string) (*ResolvedRemote, error) {
|
||||
if rptr == nil || rptr.RemoteId == "" {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -491,8 +466,8 @@ func resolveRemoteFromPtr(ctx context.Context, rptr *sstore.RemotePtrType, sessi
|
||||
StatePtr: nil,
|
||||
FeState: nil,
|
||||
}
|
||||
if sessionId != "" && windowId != "" {
|
||||
ri, err := sstore.GetRemoteInstance(ctx, sessionId, windowId, *rptr)
|
||||
if sessionId != "" && screenId != "" {
|
||||
ri, err := sstore.GetRemoteInstance(ctx, sessionId, screenId, *rptr)
|
||||
if err != nil {
|
||||
log.Printf("ERROR resolving remote state '%s': %v\n", displayName, err)
|
||||
// continue with state set to nil
|
||||
@@ -510,7 +485,7 @@ func resolveRemoteFromPtr(ctx context.Context, rptr *sstore.RemotePtrType, sessi
|
||||
}
|
||||
|
||||
// returns (remoteDisplayName, remoteptr, state, rstate, err)
|
||||
func resolveRemote(ctx context.Context, fullRemoteRef string, sessionId string, windowId string) (string, *sstore.RemotePtrType, *remote.RemoteRuntimeState, error) {
|
||||
func resolveRemote(ctx context.Context, fullRemoteRef string, sessionId string, screenId string) (string, *sstore.RemotePtrType, *remote.RemoteRuntimeState, error) {
|
||||
if fullRemoteRef == "" {
|
||||
return "", nil, nil, nil
|
||||
}
|
||||
|
||||
@@ -69,8 +69,6 @@ func SubMetaCmd(cmd string) string {
|
||||
switch cmd {
|
||||
case "s":
|
||||
return "screen"
|
||||
case "w":
|
||||
return "window"
|
||||
case "r":
|
||||
return "run"
|
||||
case "c":
|
||||
@@ -245,7 +243,7 @@ func EvalMetaCommand(ctx context.Context, origPk *scpacket.FeCommandPacketType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing metacmd, position %v", err)
|
||||
}
|
||||
envMap := make(map[string]string) // later we can add vars like session, window, screen, remote, and user
|
||||
envMap := make(map[string]string) // later we can add vars like session, screen, remote, and user
|
||||
cfg := shexec.GetParserConfig(envMap)
|
||||
// process arguments
|
||||
for idx, w := range words {
|
||||
|
||||
@@ -117,7 +117,7 @@ type MShellProc struct {
|
||||
|
||||
type RunCmdType struct {
|
||||
SessionId string
|
||||
WindowId string
|
||||
ScreenId string
|
||||
RemotePtr sstore.RemotePtrType
|
||||
RunPacket *packet.RunPacketType
|
||||
}
|
||||
@@ -1250,10 +1250,10 @@ func (msh *MShellProc) removePendingStateCmd(riName string, ck base.CommandKey)
|
||||
}
|
||||
|
||||
// returns (cmdtype, allow-updates-callback, err)
|
||||
func RunCommand(ctx context.Context, sessionId string, windowId string, remotePtr sstore.RemotePtrType, runPacket *packet.RunPacketType) (rtnCmd *sstore.CmdType, rtnCallback func(), rtnErr error) {
|
||||
func RunCommand(ctx context.Context, sessionId string, screenId string, remotePtr sstore.RemotePtrType, runPacket *packet.RunPacketType) (rtnCmd *sstore.CmdType, rtnCallback func(), rtnErr error) {
|
||||
rct := RunCmdType{
|
||||
SessionId: sessionId,
|
||||
WindowId: windowId,
|
||||
ScreenId: screenId,
|
||||
RemotePtr: remotePtr,
|
||||
RunPacket: runPacket,
|
||||
}
|
||||
@@ -1279,7 +1279,7 @@ func RunCommand(ctx context.Context, sessionId string, windowId string, remotePt
|
||||
}
|
||||
ok, existingPSC := msh.testAndSetPendingStateCmd(remotePtr.Name, newPSC)
|
||||
if !ok {
|
||||
line, _, err := sstore.GetLineCmdByCmdId(ctx, sessionId, windowId, existingPSC.GetCmdId())
|
||||
line, _, err := sstore.GetLineCmdByCmdId(ctx, sessionId, screenId, existingPSC.GetCmdId())
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("cannot run command while a stateful command is still running: %v", err)
|
||||
}
|
||||
@@ -1298,7 +1298,7 @@ func RunCommand(ctx context.Context, sessionId string, windowId string, remotePt
|
||||
}
|
||||
}()
|
||||
// get current remote-instance state
|
||||
statePtr, err := sstore.GetRemoteStatePtr(ctx, sessionId, windowId, remotePtr)
|
||||
statePtr, err := sstore.GetRemoteStatePtr(ctx, sessionId, screenId, remotePtr)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("cannot get current remote stateptr: %w", err)
|
||||
}
|
||||
@@ -1371,7 +1371,7 @@ func (msh *MShellProc) reExecSingle(rct RunCmdType) {
|
||||
// TODO fixme
|
||||
ctx, cancelFn := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancelFn()
|
||||
_, callback, _ := RunCommand(ctx, rct.SessionId, rct.WindowId, rct.RemotePtr, rct.RunPacket)
|
||||
_, callback, _ := RunCommand(ctx, rct.SessionId, rct.ScreenId, rct.RemotePtr, rct.RunPacket)
|
||||
if callback != nil {
|
||||
defer callback()
|
||||
}
|
||||
@@ -1501,7 +1501,7 @@ func (msh *MShellProc) handleCmdDonePacket(donePk *packet.CmdDonePacketType) {
|
||||
}
|
||||
screens, err := sstore.UpdateScreensWithCmdFg(context.Background(), donePk.CK.GetSessionId(), donePk.CK.GetCmdId())
|
||||
if err != nil {
|
||||
msh.WriteToPtyBuffer("*error trying to update cmd-fg screen windows: %v\n", err)
|
||||
msh.WriteToPtyBuffer("*error trying to update cmd-fg screens: %v\n", err)
|
||||
// fall-through (nothing to do)
|
||||
}
|
||||
update.Screens = screens
|
||||
@@ -1509,7 +1509,7 @@ func (msh *MShellProc) handleCmdDonePacket(donePk *packet.CmdDonePacketType) {
|
||||
var statePtr *sstore.ShellStatePtr
|
||||
if donePk.FinalState != nil && rct != nil {
|
||||
feState := sstore.FeStateFromShellState(donePk.FinalState)
|
||||
remoteInst, err := sstore.UpdateRemoteState(context.Background(), rct.SessionId, rct.WindowId, rct.RemotePtr, *feState, donePk.FinalState, nil)
|
||||
remoteInst, err := sstore.UpdateRemoteState(context.Background(), rct.SessionId, rct.ScreenId, rct.RemotePtr, *feState, donePk.FinalState, nil)
|
||||
if err != nil {
|
||||
msh.WriteToPtyBuffer("*error trying to update remotestate: %v\n", err)
|
||||
// fall-through (nothing to do)
|
||||
@@ -1524,7 +1524,7 @@ func (msh *MShellProc) handleCmdDonePacket(donePk *packet.CmdDonePacketType) {
|
||||
msh.WriteToPtyBuffer("*error trying to update remotestate: %v\n", err)
|
||||
// fall-through (nothing to do)
|
||||
} else {
|
||||
remoteInst, err := sstore.UpdateRemoteState(context.Background(), rct.SessionId, rct.WindowId, rct.RemotePtr, *feState, nil, donePk.FinalStateDiff)
|
||||
remoteInst, err := sstore.UpdateRemoteState(context.Background(), rct.SessionId, rct.ScreenId, rct.RemotePtr, *feState, nil, donePk.FinalStateDiff)
|
||||
if err != nil {
|
||||
msh.WriteToPtyBuffer("*error trying to update remotestate: %v\n", err)
|
||||
// fall-through (nothing to do)
|
||||
|
||||
@@ -52,7 +52,6 @@ func (pk *FeCommandPacketType) GetRawStr() string {
|
||||
type UIContextType struct {
|
||||
SessionId string `json:"sessionid"`
|
||||
ScreenId string `json:"screenid"`
|
||||
WindowId string `json:"windowid"`
|
||||
Remote *sstore.RemotePtrType `json:"remote,omitempty"`
|
||||
WinSize *packet.WinSize `json:"winsize,omitempty"`
|
||||
Build string `json:"build,omitempty"`
|
||||
|
||||
+118
-122
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
)
|
||||
|
||||
const MaxMigration = 9
|
||||
const MaxMigration = 10
|
||||
const MigratePrimaryScreenVersion = 9
|
||||
|
||||
func MakeMigrate() (*migrate.Migrate, error) {
|
||||
|
||||
+13
-27
@@ -34,9 +34,7 @@ const DBFileName = "prompt.db"
|
||||
const DBFileNameBackup = "backup.prompt.db"
|
||||
|
||||
const DefaultSessionName = "default"
|
||||
const DefaultWindowName = "default"
|
||||
const LocalRemoteAlias = "local"
|
||||
const DefaultScreenWindowName = "w1"
|
||||
|
||||
const DefaultCwd = "~"
|
||||
|
||||
@@ -343,7 +341,6 @@ func (h *HistoryItemType) ToMap() map[string]interface{} {
|
||||
rtn["userid"] = h.UserId
|
||||
rtn["sessionid"] = h.SessionId
|
||||
rtn["screenid"] = h.ScreenId
|
||||
rtn["windowid"] = h.WindowId
|
||||
rtn["lineid"] = h.LineId
|
||||
rtn["haderror"] = h.HadError
|
||||
rtn["cmdid"] = h.CmdId
|
||||
@@ -362,7 +359,6 @@ func (h *HistoryItemType) FromMap(m map[string]interface{}) bool {
|
||||
quickSetStr(&h.UserId, m, "userid")
|
||||
quickSetStr(&h.SessionId, m, "sessionid")
|
||||
quickSetStr(&h.ScreenId, m, "screenid")
|
||||
quickSetStr(&h.WindowId, m, "windowid")
|
||||
quickSetStr(&h.LineId, m, "lineid")
|
||||
quickSetBool(&h.HadError, m, "haderror")
|
||||
quickSetStr(&h.CmdId, m, "cmdid")
|
||||
@@ -381,15 +377,9 @@ type ScreenOptsType struct {
|
||||
PTerm string `json:"pterm,omitempty"`
|
||||
}
|
||||
|
||||
type SWKeys struct {
|
||||
SessionId string
|
||||
WindowId string
|
||||
}
|
||||
|
||||
type ScreenLinesType struct {
|
||||
SessionId string `json:"sessionid"`
|
||||
ScreenId string `json:"screenid"`
|
||||
WindowId string `json:"windowid"`
|
||||
Lines []*LineType `json:"lines" dbmap:"-"`
|
||||
Cmds []*CmdType `json:"cmds" dbmap:"-"`
|
||||
}
|
||||
@@ -399,7 +389,6 @@ func (ScreenLinesType) UseDBMap() {}
|
||||
type ScreenType struct {
|
||||
SessionId string `json:"sessionid"`
|
||||
ScreenId string `json:"screenid"`
|
||||
WindowId string `json:"windowid"`
|
||||
Name string `json:"name"`
|
||||
ScreenIdx int64 `json:"screenidx"`
|
||||
ScreenOpts ScreenOptsType `json:"screenopts"`
|
||||
@@ -422,7 +411,6 @@ func (s *ScreenType) ToMap() map[string]interface{} {
|
||||
rtn := make(map[string]interface{})
|
||||
rtn["sessionid"] = s.SessionId
|
||||
rtn["screenid"] = s.ScreenId
|
||||
rtn["windowid"] = s.WindowId
|
||||
rtn["name"] = s.Name
|
||||
rtn["screenidx"] = s.ScreenIdx
|
||||
rtn["screenopts"] = quickJson(s.ScreenOpts)
|
||||
@@ -443,7 +431,6 @@ func (s *ScreenType) ToMap() map[string]interface{} {
|
||||
func (s *ScreenType) FromMap(m map[string]interface{}) bool {
|
||||
quickSetStr(&s.SessionId, m, "sessionid")
|
||||
quickSetStr(&s.ScreenId, m, "screenid")
|
||||
quickSetStr(&s.WindowId, m, "windowid")
|
||||
quickSetStr(&s.Name, m, "name")
|
||||
quickSetInt64(&s.ScreenIdx, m, "screenidx")
|
||||
quickSetJson(&s.ScreenOpts, m, "screenopts")
|
||||
@@ -497,7 +484,6 @@ type HistoryItemType struct {
|
||||
UserId string `json:"userid"`
|
||||
SessionId string `json:"sessionid"`
|
||||
ScreenId string `json:"screenid"`
|
||||
WindowId string `json:"windowid"`
|
||||
LineId string `json:"lineid"`
|
||||
HadError bool `json:"haderror"`
|
||||
CmdId string `json:"cmdid"`
|
||||
@@ -520,7 +506,7 @@ type HistoryQueryOpts struct {
|
||||
SearchText string
|
||||
SessionId string
|
||||
RemoteId string
|
||||
WindowId string
|
||||
ScreenId string
|
||||
NoMeta bool
|
||||
RawOffset int
|
||||
FilterFn func(*HistoryItemType) bool
|
||||
@@ -568,7 +554,7 @@ type RemoteInstance struct {
|
||||
RIId string `json:"riid"`
|
||||
Name string `json:"name"`
|
||||
SessionId string `json:"sessionid"`
|
||||
WindowId string `json:"windowid"`
|
||||
ScreenId string `json:"screenid"`
|
||||
RemoteOwnerId string `json:"remoteownerid"`
|
||||
RemoteId string `json:"remoteid"`
|
||||
FeState FeStateType `json:"festate"`
|
||||
@@ -629,7 +615,7 @@ func (ri *RemoteInstance) FromMap(m map[string]interface{}) bool {
|
||||
quickSetStr(&ri.RIId, m, "riid")
|
||||
quickSetStr(&ri.Name, m, "name")
|
||||
quickSetStr(&ri.SessionId, m, "sessionid")
|
||||
quickSetStr(&ri.WindowId, m, "windowid")
|
||||
quickSetStr(&ri.ScreenId, m, "screenid")
|
||||
quickSetStr(&ri.RemoteOwnerId, m, "remoteownerid")
|
||||
quickSetStr(&ri.RemoteId, m, "remoteid")
|
||||
quickSetJson(&ri.FeState, m, "festate")
|
||||
@@ -643,7 +629,7 @@ func (ri *RemoteInstance) ToMap() map[string]interface{} {
|
||||
rtn["riid"] = ri.RIId
|
||||
rtn["name"] = ri.Name
|
||||
rtn["sessionid"] = ri.SessionId
|
||||
rtn["windowid"] = ri.WindowId
|
||||
rtn["screenid"] = ri.ScreenId
|
||||
rtn["remoteownerid"] = ri.RemoteOwnerId
|
||||
rtn["remoteid"] = ri.RemoteId
|
||||
rtn["festate"] = quickJson(ri.FeState)
|
||||
@@ -654,7 +640,7 @@ func (ri *RemoteInstance) ToMap() map[string]interface{} {
|
||||
|
||||
type LineType struct {
|
||||
SessionId string `json:"sessionid"`
|
||||
WindowId string `json:"windowid"`
|
||||
ScreenId string `json:"screenid"`
|
||||
UserId string `json:"userid"`
|
||||
LineId string `json:"lineid"`
|
||||
Ts int64 `json:"ts"`
|
||||
@@ -948,10 +934,10 @@ func (cmd *CmdType) FromMap(m map[string]interface{}) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId string, renderer string) *LineType {
|
||||
func makeNewLineCmd(sessionId string, screenId string, userId string, cmdId string, renderer string) *LineType {
|
||||
rtn := &LineType{}
|
||||
rtn.SessionId = sessionId
|
||||
rtn.WindowId = windowId
|
||||
rtn.ScreenId = screenId
|
||||
rtn.UserId = userId
|
||||
rtn.LineId = scbase.GenPromptUUID()
|
||||
rtn.Ts = time.Now().UnixMilli()
|
||||
@@ -963,10 +949,10 @@ func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId stri
|
||||
return rtn
|
||||
}
|
||||
|
||||
func makeNewLineText(sessionId string, windowId string, userId string, text string) *LineType {
|
||||
func makeNewLineText(sessionId string, screenId string, userId string, text string) *LineType {
|
||||
rtn := &LineType{}
|
||||
rtn.SessionId = sessionId
|
||||
rtn.WindowId = windowId
|
||||
rtn.ScreenId = screenId
|
||||
rtn.UserId = userId
|
||||
rtn.LineId = scbase.GenPromptUUID()
|
||||
rtn.Ts = time.Now().UnixMilli()
|
||||
@@ -977,8 +963,8 @@ func makeNewLineText(sessionId string, windowId string, userId string, text stri
|
||||
return rtn
|
||||
}
|
||||
|
||||
func AddCommentLine(ctx context.Context, sessionId string, windowId string, userId string, commentText string) (*LineType, error) {
|
||||
rtnLine := makeNewLineText(sessionId, windowId, userId, commentText)
|
||||
func AddCommentLine(ctx context.Context, sessionId string, screenId string, userId string, commentText string) (*LineType, error) {
|
||||
rtnLine := makeNewLineText(sessionId, screenId, userId, commentText)
|
||||
err := InsertLine(ctx, rtnLine, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -986,8 +972,8 @@ func AddCommentLine(ctx context.Context, sessionId string, windowId string, user
|
||||
return rtnLine, nil
|
||||
}
|
||||
|
||||
func AddCmdLine(ctx context.Context, sessionId string, windowId string, userId string, cmd *CmdType, renderer string) (*LineType, error) {
|
||||
rtnLine := makeNewLineCmd(sessionId, windowId, userId, cmd.CmdId, renderer)
|
||||
func AddCmdLine(ctx context.Context, sessionId string, screenId string, userId string, cmd *CmdType, renderer string) (*LineType, error) {
|
||||
rtnLine := makeNewLineCmd(sessionId, screenId, userId, cmd.CmdId, renderer)
|
||||
err := InsertLine(ctx, rtnLine, cmd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -111,7 +111,7 @@ type InfoMsgType struct {
|
||||
type HistoryInfoType struct {
|
||||
HistoryType string `json:"historytype"`
|
||||
SessionId string `json:"sessionid,omitempty"`
|
||||
WindowId string `json:"windowid,omitempty"`
|
||||
ScreenId string `json:"screenid,omitempty"`
|
||||
Items []*HistoryItemType `json:"items"`
|
||||
Show bool `json:"show"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user