Skip to content

Commit

Permalink
feat: adding icon to NavPage
Browse files Browse the repository at this point in the history
  • Loading branch information
axel7083 committed Jan 11, 2024
1 parent bdfeaaf commit 8306115
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/backend/src/ai.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description" : "Chat bot application",
"name" : "ChatBot",
"repository": "https://github.com/axel7083/locallm",
"icon": "natural-language-processing",
"categories": [
"natural-language-processing"
],
Expand Down
7 changes: 7 additions & 0 deletions packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import content from './ai.json';
import { ApplicationManager } from './managers/applicationManager';
import { RecipeStatusRegistry } from './registries/RecipeStatusRegistry';
import { RecipeStatus } from '@shared/models/IRecipeStatus';
import {exec} from 'child_process';

export const RECENT_CATEGORY_ID = 'recent-category';

Expand All @@ -14,6 +15,12 @@ export class StudioApiImpl implements StudioAPI {
private recipeStatusRegistry: RecipeStatusRegistry,
) {}

async openURL(url: string): Promise<void> {
// TODO: probably not really secure, ask the user to validate opening
exec(`start "${url}"`);
return;
}

async getPullingStatus(recipeId: string): Promise<RecipeStatus> {
return this.recipeStatusRegistry.getStatus(recipeId);
}
Expand Down
14 changes: 12 additions & 2 deletions packages/frontend/src/lib/NavPage.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<script lang="ts">
import Fa from 'svelte-fa';
import type { IconDefinition } from '@fortawesome/free-regular-svg-icons';
export let title: string;
export let searchTerm = '';
export let searchEnabled = true;
export let icon: IconDefinition | undefined = undefined;
</script>

<div class="flex flex-col w-full h-full shadow-pageheader">
<div class="flex flex-col w-full h-full pt-4" role="region" aria-label="{title}">
<div class="flex pb-2 px-5" role="region" aria-label="header">

<div class="flex flex-col">
<h1 class="text-xl first-letter:uppercase">{title}</h1>
<div class="flex flex-row">
{#if icon}
<div class="bg-charcoal-800 rounded-full w-8 h-8 flex items-center justify-center mr-3">
<Fa size="20" class="text-purple-500" icon="{icon}" />
</div>
{/if}
<h1 class="text-xl first-letter:uppercase">{title}</h1>
</div>
<slot name="subtitle" />
</div>

Expand Down
9 changes: 7 additions & 2 deletions packages/frontend/src/pages/Recipe.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import TasksProgress from '/@/lib/progress/TasksProgress.svelte';
import Button from '/@/lib/button/Button.svelte';
import { getDisplayName } from '/@/utils/versionControlUtils';
import type { RecipeStatus } from '@shared/models/IRecipeStatus';
import { getIcon } from '/@/utils/categoriesUtils';
export let recipeId: string;
Expand Down Expand Up @@ -53,9 +54,13 @@ onDestroy(() => {
intervalId = undefined;
}
});
const onClickRepository = () => {
studioClient.openURL(recipe?.repository);
}
</script>

<NavPage title="{recipe?.name || ''}">
<NavPage title="{recipe?.name || ''}" icon="{getIcon(recipe?.icon)}">
<svelte:fragment slot="tabs">
<Tab title="Summary" url="{recipeId}" />
<Tab title="Models" url="{recipeId}/models" />
Expand All @@ -74,7 +79,7 @@ onDestroy(() => {
<div class="cursor-pointer flex text-nowrap items-center">
<Fa size="20" icon="{faGithub}"/>
<div class="ml-2">
<a href="{recipe?.repository}" target="_blank">{getDisplayName(recipe?.repository)}</a>
<a on:click={onClickRepository}>{getDisplayName(recipe?.repository)}</a>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/shared/StudioAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export abstract class StudioAPI {
abstract searchRecipes(query: string): Promise<Recipe[]>;
abstract getPullingStatus(recipeId: string): Promise<RecipeStatus>
abstract pullApplication(recipeId: string): Promise<void>;
abstract openURL(url: string): Promise<void>;
}

0 comments on commit 8306115

Please sign in to comment.