| 126 | } |
| 127 | |
| 128 | func SavePlotData(ctx context.Context, blockId string, history string) error { |
| 129 | block, err := wstore.DBMustGet[*waveobj.Block](ctx, blockId) |
| 130 | if err != nil { |
| 131 | return err |
| 132 | } |
| 133 | viewName := block.Meta.GetString(waveobj.MetaKey_View, "") |
| 134 | if viewName != "cpuplot" && viewName != "sysinfo" { |
| 135 | return fmt.Errorf("invalid view type: %s", viewName) |
| 136 | } |
| 137 | // todo: interpret the data being passed |
| 138 | // for now, this is just to throw an error if the block was closed |
| 139 | historyBytes, err := json.Marshal(history) |
| 140 | if err != nil { |
| 141 | return fmt.Errorf("unable to serialize plot data: %v", err) |
| 142 | } |
| 143 | // ignore MakeFile error (already exists is ok) |
| 144 | return filestore.WFS.WriteFile(ctx, blockId, "cpuplotdata", historyBytes) |
| 145 | } |
| 146 | |
| 147 | func (ws *WshServer) GetMetaCommand(ctx context.Context, data wshrpc.CommandGetMetaData) (waveobj.MetaMapType, error) { |
| 148 | obj, err := wstore.DBGetORef(ctx, data.ORef) |