From 2a7093aae17d4ee153fc9cd9b0a4e7c1b142ed16 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:10:24 +0100 Subject: [PATCH] feat: playground navigate to container --- packages/backend/src/studio-api-impl.ts | 4 ++ .../frontend/src/lib/button/Button.svelte | 2 +- .../src/lib/images/ContainerIcon.svelte | 45 +++++++++++++++++++ .../frontend/src/pages/ModelPlayground.svelte | 15 +++++++ packages/shared/src/StudioAPI.ts | 2 + 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 packages/frontend/src/lib/images/ContainerIcon.svelte diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index d1521db75..7702c0ea1 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -118,4 +118,8 @@ export class StudioApiImpl implements StudioAPI { async deleteLocalModel(modelId: string): Promise { await this.modelsManager.deleteLocalModel(modelId); } + + navigateToContainer(containerId: string): Promise { + return podmanDesktopApi.navigation.navigateToContainer(containerId); + } } diff --git a/packages/frontend/src/lib/button/Button.svelte b/packages/frontend/src/lib/button/Button.svelte index 6aafe58fe..b88d18bcf 100644 --- a/packages/frontend/src/lib/button/Button.svelte +++ b/packages/frontend/src/lib/button/Button.svelte @@ -73,7 +73,7 @@ $: { {:else if iconType === 'fa'} {:else if iconType === 'unknown'} - + {/if} {#if $$slots.default} diff --git a/packages/frontend/src/lib/images/ContainerIcon.svelte b/packages/frontend/src/lib/images/ContainerIcon.svelte new file mode 100644 index 000000000..7b4bbce47 --- /dev/null +++ b/packages/frontend/src/lib/images/ContainerIcon.svelte @@ -0,0 +1,45 @@ + + + + {#if solid} + + + + + + + + + + + + {:else} + + + + + + {/if} + diff --git a/packages/frontend/src/pages/ModelPlayground.svelte b/packages/frontend/src/pages/ModelPlayground.svelte index 7394256b9..2fd78c661 100644 --- a/packages/frontend/src/pages/ModelPlayground.svelte +++ b/packages/frontend/src/pages/ModelPlayground.svelte @@ -12,6 +12,7 @@ export let model: ModelInfo | undefined; import Fa from 'svelte-fa'; import { faPlay, faStop, faInfo, faWarning } from '@fortawesome/free-solid-svg-icons'; + import ContainerIcon from '/@/lib/images/ContainerIcon.svelte'; let prompt = ''; let queryId: number; @@ -147,6 +148,17 @@ return true; } } + + const navigateToContainer = () => { + if(playgroundState?.container?.containerId === undefined) + return; + + try { + studioClient.navigateToContainer(playgroundState?.container?.containerId); + } catch(err) { + console.error(err); + } + }
@@ -155,6 +167,9 @@ {#key playgroundState?.status} Playground {playgroundState?.status}
diff --git a/packages/shared/src/StudioAPI.ts b/packages/shared/src/StudioAPI.ts index 7e406b63a..c15e47af1 100644 --- a/packages/shared/src/StudioAPI.ts +++ b/packages/shared/src/StudioAPI.ts @@ -25,4 +25,6 @@ export abstract class StudioAPI { abstract askPlayground(modelId: string, prompt: string): Promise; abstract getPlaygroundQueriesState(): Promise; abstract getPlaygroundsState(): Promise; + + abstract navigateToContainer(containerId: string): Promise; }