Skip to content

Commit

Permalink
feat: add ability to delete all sessions and settings (#34)
Browse files Browse the repository at this point in the history
* feat: add ability to delete all sessions and settings

* add test for "Delete server settings"

* use tabs

* add "Delete all sessions" test
  • Loading branch information
fmaclen authored Apr 23, 2024
1 parent 1c683b7 commit b2e426b
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 191 deletions.
55 changes: 42 additions & 13 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@
}
}
function deleteSessions(): void {
if (confirm('Are you sure you want to delete all sessions?')) {
localStorage.removeItem('hollama-sessions');
location.reload();
}
}
function deleteSettings(): void {
if (confirm('Are you sure you want to delete server settings?')) {
localStorage.removeItem('hollama-settings');
location.reload();
}
}
onMount(async () => {
// Get the current URL
ollamaURL = new URL(window.location.href);
Expand All @@ -52,9 +66,9 @@

<div class="flex w-full flex-col bg-secondary">
<div class="justify-content-center m-auto max-w-[40ch] p-6">
<div class="container">
<div class="fieldset">
<Field name="server">
<span slot="title">
<span slot="title" class="flex w-full items-center justify-between">
Server
<Badge variant={serverStatus === 'disconnected' ? 'warning' : 'positive'}>
{serverStatus}
Expand Down Expand Up @@ -109,13 +123,23 @@
{/if}
</div>

<div class="container">
<div class="fieldset">
<FieldModels models={ollamaTagResponse?.models || []} bind:value={ollamaModel.value} />
</div>

<Separator class="mb-8 mt-8" />

<div class="container">
<div class="fieldset">
<Field name="danger-zone">
<span slot="title">Danger zone</span>
<Button variant="outline" on:click={deleteSessions}>Delete all sessions</Button>
<Button variant="outline" on:click={deleteSettings}>Delete server settings</Button>
</Field>
</div>

<Separator class="mb-8 mt-8" />

<div class="fieldset">
<p class="p"><strong>About</strong></p>
<p class="p">
<strong>Hollama</strong> is a minimalistic web interface for
Expand All @@ -126,22 +150,27 @@
target="_blank">Ollama</Button
>
servers. Code is available on
<Button variant="link" size="link" href="https://github.com/fmaclen/hollama" target="_blank"
>Github</Button
>.
<Button
variant="link"
size="link"
href="https://github.com/fmaclen/hollama"
target="_blank"
>
Github
</Button>.
</p>
<p class="p">
Made by
<Button variant="link" size="link" href="https://fernando.is" target="_blank"
>@fmaclen</Button
>
<Button variant="link" size="link" href="https://fernando.is" target="_blank">
@fmaclen
</Button>
</p>
</div>
</div>
</div>

<style lang="scss">
.container {
.fieldset {
@apply mb-6 mt-6 flex flex-col gap-y-3;
}
Expand All @@ -158,10 +187,10 @@
}
.p {
@apply text-sm text-neutral-600;
@apply text-sm text-neutral-500;
strong {
@apply font-medium leading-none;
@apply font-medium leading-none text-primary;
}
}
</style>
Loading

0 comments on commit b2e426b

Please sign in to comment.