finishing up historytype and making remotes update

This commit is contained in:
sawka 2022-08-31 23:12:26 -07:00
parent 1a88d564bb
commit d55bb8812b
4 changed files with 18 additions and 7 deletions

View File

@ -158,7 +158,12 @@ func HandleGetRemotes(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Vary", "Origin")
w.Header().Set("Cache-Control", "no-cache")
remotes := remote.GetAllRemoteRuntimeState()
WriteJsonSuccess(w, remotes)
ifarr := make([]interface{}, len(remotes))
for idx, r := range remotes {
ifarr[idx] = r
}
update := sstore.ModelUpdate{Remotes: ifarr}
WriteJsonSuccess(w, update)
return
}

View File

@ -70,6 +70,7 @@ func init() {
registerCmdAlias("remote", RemoteCommand)
registerCmdFn("remote:show", RemoteShowCommand)
registerCmdFn("remote:showall", RemoteShowAllCommand)
registerCmdFn("remote:new", RemoteNewCommand)
registerCmdFn("history", HistoryCommand)
}
@ -360,6 +361,10 @@ func UnSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore
return update, nil
}
func RemoteNewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
return nil, nil
}
func RemoteShowCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
ids, err := resolveUiIds(ctx, pk, R_Session|R_Window|R_Remote)
if err != nil {

View File

@ -273,7 +273,7 @@ func (proc *MShellProc) GetRemoteRuntimeState() RemoteRuntimeState {
func (msh *MShellProc) NotifyUpdate() {
rstate := msh.GetRemoteRuntimeState()
update := &sstore.ModelUpdate{Remote: rstate}
update := &sstore.ModelUpdate{Remotes: []interface{}{rstate}}
sstore.MainBus.SendUpdate("", update)
}

View File

@ -31,7 +31,7 @@ type ModelUpdate struct {
Cmd *CmdType `json:"cmd,omitempty"`
CmdLine *CmdLineType `json:"cmdline,omitempty"`
Info *InfoMsgType `json:"info,omitempty"`
Remote interface{} `json:"remote,omitempty"` // *remote.RemoteState
Remotes []interface{} `json:"remotes,omitempty"` // []*remote.RemoteState
History *HistoryInfoType `json:"history,omitempty"`
}
@ -76,10 +76,11 @@ type InfoMsgType struct {
}
type HistoryInfoType struct {
SessionId string `json:"sessionid,omitempty"`
WindowId string `json:"windowid,omitempty"`
Items []*HistoryItemType `json:"items"`
Show bool `json:"show"`
HistoryType string `json:"historytype"`
SessionId string `json:"sessionid,omitempty"`
WindowId string `json:"windowid,omitempty"`
Items []*HistoryItemType `json:"items"`
Show bool `json:"show"`
}
type CmdLineType struct {