mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
update history table
This commit is contained in:
parent
adca87e9db
commit
d5cf15e946
@ -81,10 +81,13 @@ CREATE TABLE cmd (
|
||||
);
|
||||
|
||||
CREATE TABLE history (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
userid varchar(36) NOT NULL,
|
||||
historyid varchar(36) PRIMARY KEY,
|
||||
ts bigint NOT NULL,
|
||||
lineid varchar(36) NOT NULL,
|
||||
PRIMARY KEY (sessionid, windowid, lineid)
|
||||
userid varchar(36) NOT NULL,
|
||||
sessionid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
lineid int NOT NULL,
|
||||
cmdid varchar(36) NOT NULL,
|
||||
cmdstr text NOT NULL
|
||||
);
|
||||
|
@ -75,10 +75,13 @@ CREATE TABLE cmd (
|
||||
PRIMARY KEY (sessionid, cmdid)
|
||||
);
|
||||
CREATE TABLE history (
|
||||
sessionid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
userid varchar(36) NOT NULL,
|
||||
historyid varchar(36) PRIMARY KEY,
|
||||
ts bigint NOT NULL,
|
||||
lineid varchar(36) NOT NULL,
|
||||
PRIMARY KEY (sessionid, windowid, lineid)
|
||||
userid varchar(36) NOT NULL,
|
||||
sessionid varchar(36) NOT NULL,
|
||||
screenid varchar(36) NOT NULL,
|
||||
windowid varchar(36) NOT NULL,
|
||||
lineid int NOT NULL,
|
||||
cmdid varchar(36) NOT NULL,
|
||||
cmdstr text NOT NULL
|
||||
);
|
||||
|
@ -278,6 +278,10 @@ func RunCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.U
|
||||
return sstore.LineUpdate{Line: rtnLine, Cmd: cmd}, nil
|
||||
}
|
||||
|
||||
func addToHistory(ctx context.Context, pk *scpacket.FeCommandPacketType, cmdStr string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func EvalCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||
if len(pk.Args) == 0 {
|
||||
return nil, fmt.Errorf("usage: /eval [command], no command passed to eval")
|
||||
@ -287,6 +291,9 @@ func EvalCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.
|
||||
if commandStr == "" {
|
||||
return nil, fmt.Errorf("/eval, invalid emtpty command")
|
||||
}
|
||||
if !resolveBool(pk.Kwargs["nohist"], false) {
|
||||
addToHistory(ctx, pk, pk.Args[0])
|
||||
}
|
||||
metaCmd := ""
|
||||
metaSubCmd := ""
|
||||
if commandStr == "cd" || strings.HasPrefix(commandStr, "cd ") {
|
||||
@ -330,6 +337,7 @@ func EvalCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.
|
||||
newPk.Kwargs[fields[0]] = fields[1]
|
||||
}
|
||||
}
|
||||
|
||||
return HandleCommand(ctx, newPk)
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,23 @@ func InsertRemote(ctx context.Context, remote *RemoteType) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func InsertHistoryItem(ctx context.Context, hitem *HistoryItemType) error {
|
||||
if hitem == nil {
|
||||
return fmt.Errorf("cannot insert nil history item")
|
||||
}
|
||||
db, err := GetDB(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
query := `INSERT INTO history ( historyid, ts, userid, sessionid, screenid, windowid, lineid, cmdid, cmdstr) VALUES
|
||||
(:historyid,:ts,:userid,:sessionid,:screenid,:windowid,:lineid,:cmdid,:cmdstr)`
|
||||
_, err = db.NamedExec(query, hitem)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetBareSessions(ctx context.Context) ([]*SessionType, error) {
|
||||
var rtn []*SessionType
|
||||
err := WithTx(ctx, func(tx *TxWrap) error {
|
||||
|
@ -82,14 +82,13 @@ func (opts WindowOptsType) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
type WindowType struct {
|
||||
SessionId string `json:"sessionid"`
|
||||
WindowId string `json:"windowid"`
|
||||
CurRemote string `json:"curremote"`
|
||||
WinOpts WindowOptsType `json:"winopts"`
|
||||
Lines []*LineType `json:"lines"`
|
||||
Cmds []*CmdType `json:"cmds"`
|
||||
History []*HistoryItemType `json:"history"`
|
||||
Remotes []*RemoteInstance `json:"remotes"`
|
||||
SessionId string `json:"sessionid"`
|
||||
WindowId string `json:"windowid"`
|
||||
CurRemote string `json:"curremote"`
|
||||
WinOpts WindowOptsType `json:"winopts"`
|
||||
Lines []*LineType `json:"lines"`
|
||||
Cmds []*CmdType `json:"cmds"`
|
||||
Remotes []*RemoteInstance `json:"remotes"`
|
||||
|
||||
// only for updates
|
||||
Remove bool `json:"remove,omitempty"`
|
||||
@ -158,8 +157,18 @@ type ScreenWindowType struct {
|
||||
}
|
||||
|
||||
type HistoryItemType struct {
|
||||
CmdStr string `json:"cmdstr"`
|
||||
Remove bool `json:"remove"`
|
||||
HistoryId string `json:"historyid"`
|
||||
Ts int64 `json:"ts"`
|
||||
UserId string `json:"userid"`
|
||||
SessionId string `json:"sessionid"`
|
||||
ScreenId string `json:"screenid"`
|
||||
WindowId string `json:"windowid"`
|
||||
LineId int64 `json:"lineid"`
|
||||
CmdId string `json:"cmdid"`
|
||||
CmdStr string `json:"cmdstr"`
|
||||
|
||||
// only for updates
|
||||
Remove bool `json:"remove"`
|
||||
}
|
||||
|
||||
type RemoteState struct {
|
||||
|
Loading…
Reference in New Issue
Block a user