mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
wsh rpc working (#55)
lots of iterations on an RPC protocol. getting wsh working with a getmeta/setmeta command in addition to html mode.
This commit is contained in:
@@ -5,7 +5,6 @@ package objectservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
@@ -72,26 +71,6 @@ func (svc *ObjectService) GetObjects(orefStrArr []string) ([]waveobj.WaveObj, er
|
||||
return wstore.DBSelectORefs(ctx, orefArr)
|
||||
}
|
||||
|
||||
func updatesRtn(ctx context.Context, rtnVal map[string]any) (any, error) {
|
||||
updates := wstore.ContextGetUpdates(ctx)
|
||||
if len(updates) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
updateArr := make([]wstore.WaveObjUpdate, 0, len(updates))
|
||||
for _, update := range updates {
|
||||
updateArr = append(updateArr, update)
|
||||
}
|
||||
jval, err := json.Marshal(updateArr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting updates to JSON: %w", err)
|
||||
}
|
||||
if rtnVal == nil {
|
||||
rtnVal = make(map[string]any)
|
||||
}
|
||||
rtnVal["updates"] = json.RawMessage(jval)
|
||||
return rtnVal, nil
|
||||
}
|
||||
|
||||
func (svc *ObjectService) AddTabToWorkspace_Meta() tsgenmeta.MethodMeta {
|
||||
return tsgenmeta.MethodMeta{
|
||||
ArgNames: []string{"uiContext", "tabName", "activateTab"},
|
||||
|
||||
@@ -13,7 +13,9 @@ import (
|
||||
"github.com/wavetermdev/thenextwave/pkg/service/clientservice"
|
||||
"github.com/wavetermdev/thenextwave/pkg/service/fileservice"
|
||||
"github.com/wavetermdev/thenextwave/pkg/service/objectservice"
|
||||
"github.com/wavetermdev/thenextwave/pkg/service/windowservice"
|
||||
"github.com/wavetermdev/thenextwave/pkg/tsgen/tsgenmeta"
|
||||
"github.com/wavetermdev/thenextwave/pkg/util/utilfn"
|
||||
"github.com/wavetermdev/thenextwave/pkg/waveobj"
|
||||
"github.com/wavetermdev/thenextwave/pkg/web/webcmd"
|
||||
"github.com/wavetermdev/thenextwave/pkg/wshutil"
|
||||
@@ -25,6 +27,7 @@ var ServiceMap = map[string]any{
|
||||
"object": &objectservice.ObjectService{},
|
||||
"file": &fileservice.FileService{},
|
||||
"client": &clientservice.ClientService{},
|
||||
"window": &windowservice.WindowService{},
|
||||
}
|
||||
|
||||
var contextRType = reflect.TypeOf((*context.Context)(nil)).Elem()
|
||||
@@ -85,7 +88,7 @@ func convertNumber(argType reflect.Type, jsonArg float64) (any, error) {
|
||||
|
||||
func convertComplex(argType reflect.Type, jsonArg any) (any, error) {
|
||||
nativeArgVal := reflect.New(argType)
|
||||
err := waveobj.DoMapStucture(nativeArgVal.Interface(), jsonArg)
|
||||
err := utilfn.DoMapStucture(nativeArgVal.Interface(), jsonArg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2024, Command Line Inc.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package windowservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/wavetermdev/thenextwave/pkg/wstore"
|
||||
)
|
||||
|
||||
type WindowService struct{}
|
||||
|
||||
func (ws *WindowService) SetWindowPosAndSize(ctx context.Context, windowId string, pos *wstore.Point, size *wstore.WinSize) (wstore.UpdatesRtnType, error) {
|
||||
if pos == nil && size == nil {
|
||||
return nil, nil
|
||||
}
|
||||
ctx = wstore.ContextWithUpdates(ctx)
|
||||
win, err := wstore.DBMustGet[*wstore.Window](ctx, windowId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if pos != nil {
|
||||
win.Pos = *pos
|
||||
}
|
||||
if size != nil {
|
||||
win.WinSize = *size
|
||||
}
|
||||
err = wstore.DBUpdate(ctx, win)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return wstore.ContextGetUpdatesRtn(ctx), nil
|
||||
}
|
||||
Reference in New Issue
Block a user