mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
add an updatemetadata call to objectservice
This commit is contained in:
parent
6e6b5178c1
commit
5edb882955
@ -272,6 +272,10 @@ export function CloseTab(tabId: string): Promise<void> {
|
|||||||
return wrapObjectServiceCall("CloseTab", tabId);
|
return wrapObjectServiceCall("CloseTab", tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function UpdateBlockMeta(blockId: string, meta: MetadataType): Promise<void> {
|
||||||
|
return wrapObjectServiceCall("UpdateBlockMeta", blockId, meta);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
cleanWaveObjectCache,
|
cleanWaveObjectCache,
|
||||||
clearWaveObjectCache,
|
clearWaveObjectCache,
|
||||||
|
2
frontend/types/custom.d.ts
vendored
2
frontend/types/custom.d.ts
vendored
@ -7,6 +7,8 @@ declare global {
|
|||||||
activetabid: string;
|
activetabid: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type MetadataType = { [key: string]: any };
|
||||||
|
|
||||||
type ORef = {
|
type ORef = {
|
||||||
otype: string;
|
otype: string;
|
||||||
oid: string;
|
oid: string;
|
||||||
|
@ -16,6 +16,8 @@ loadFonts();
|
|||||||
|
|
||||||
console.log("Wave Starting");
|
console.log("Wave Starting");
|
||||||
|
|
||||||
|
(window as any).WOS = WOS;
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", async () => {
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
console.log("DOMContentLoaded");
|
console.log("DOMContentLoaded");
|
||||||
// ensures client/window are loaded into the cache before rendering
|
// ensures client/window are loaded into the cache before rendering
|
||||||
|
@ -179,3 +179,14 @@ func (svc *ObjectService) CloseTab(uiContext wstore.UIContext, tabId string) (an
|
|||||||
}
|
}
|
||||||
return updatesRtn(ctx, nil)
|
return updatesRtn(ctx, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (svc *ObjectService) UpdateBlockMeta(uiContext wstore.UIContext, blockId string, meta map[string]any) (any, error) {
|
||||||
|
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
|
||||||
|
defer cancelFn()
|
||||||
|
ctx = wstore.ContextWithUpdates(ctx)
|
||||||
|
err := wstore.UpdateBlockMeta(ctx, blockId, meta)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error merging block meta: %w", err)
|
||||||
|
}
|
||||||
|
return updatesRtn(ctx, nil)
|
||||||
|
}
|
||||||
|
@ -395,6 +395,24 @@ func CloseTab(ctx context.Context, workspaceId string, tabId string) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateBlockMeta(ctx context.Context, blockId string, meta map[string]any) error {
|
||||||
|
return WithTx(ctx, func(tx *TxWrap) error {
|
||||||
|
block, _ := DBGet[*Block](tx.Context(), blockId)
|
||||||
|
if block == nil {
|
||||||
|
return fmt.Errorf("block not found: %q", blockId)
|
||||||
|
}
|
||||||
|
for k, v := range meta {
|
||||||
|
if v == nil {
|
||||||
|
delete(block.Meta, k)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
block.Meta[k] = v
|
||||||
|
}
|
||||||
|
DBUpdate(tx.Context(), block)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func EnsureInitialData() error {
|
func EnsureInitialData() error {
|
||||||
// does not need to run in a transaction since it is called on startup
|
// does not need to run in a transaction since it is called on startup
|
||||||
ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
|
ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
|
Loading…
Reference in New Issue
Block a user