diff --git a/src/lib/components/AddBookmarkForm/AddBookmarkForm.svelte b/src/lib/components/AddBookmarkForm/AddBookmarkForm.svelte index 8c14550..83df3a7 100644 --- a/src/lib/components/AddBookmarkForm/AddBookmarkForm.svelte +++ b/src/lib/components/AddBookmarkForm/AddBookmarkForm.svelte @@ -1,197 +1,198 @@
{ + await invalidate('app:main-page'); if (result.type === 'success' && result?.data?.bookmark) { // @ts-ignore-next-line addBookmarkToSearchIndex($searchEngine, result.data.bookmark); @@ -213,8 +215,7 @@ closeModal(); } }; - }} -> + }}>
@@ -223,8 +224,7 @@ type="text" class="hidden" name="content_published_date" - value={metadata.contentPublishedDate} - /> + value={metadata.contentPublishedDate} /> {#if error}
{error}
@@ -243,8 +243,7 @@ name="url" value={metadata.url} on:input={onGetMetadata} - disabled={$loading} - /> + disabled={$loading} /> {#if metadata.url} {/if} @@ -274,8 +272,7 @@ placeholder="Select category..." value={`${defaultCategory.id}`} items={categorySelectItems} - class="this-select input input-bordered w-full" - /> + class="this-select input input-bordered w-full" />
@@ -291,8 +288,7 @@ bind:value={$bookmarkTagsInput} bind:loading={$loadingTags} items={$bookmarkTags} - class="this-select input input-bordered min-w-full flex-1" - > + class="this-select input input-bordered min-w-full flex-1">
{item.created ? 'Create tag: ' : ''} {item.label} @@ -309,20 +305,17 @@ type="radio" name="importance" class="mask mask-star-2 bg-orange-400" - value="1" - /> + value="1" /> + value="2" /> + value="3" />
@@ -345,8 +338,7 @@ on:input={(event) => { // @ts-ignore-next-line metadata.title = event.target.value; - }} - /> + }} />
@@ -359,8 +351,7 @@ on:input={(event) => { // @ts-ignore-next-line metadata.icon_url = event.target.value; - }} - /> + }} /> {#if metadata.iconUrl} {metadata.title} {/if} @@ -375,8 +366,7 @@ on:input={(event) => { // @ts-ignore-next-line metadata.description = event.target.value; - }} - /> + }} />
@@ -384,8 +374,7 @@ {metadata.title} + alt={metadata.title} /> {/if} { // @ts-ignore-next-line metadata.main_image_url = event.target.value; - }} - /> + }} />
@@ -408,8 +396,7 @@ on:input={(event) => { // @ts-ignore-next-line metadata.content_text = event.target.value; - }} - /> + }} />
@@ -418,8 +405,7 @@ class="input input-bordered" name="author" value={metadata.author} - placeholder="Extracted if possible..." - /> + placeholder="Extracted if possible..." />
@@ -431,16 +417,14 @@ on:input={(event) => { // @ts-ignore-next-line metadata.note = event.target.value; - }} - /> + }} />
{/if} + disabled={$loading || !metadata.url || !metadata.title}>Add
diff --git a/src/lib/components/BookmarkCard/BookmarkCard.svelte b/src/lib/components/BookmarkCard/BookmarkCard.svelte index 0849610..b3f82c5 100644 --- a/src/lib/components/BookmarkCard/BookmarkCard.svelte +++ b/src/lib/components/BookmarkCard/BookmarkCard.svelte @@ -2,11 +2,12 @@ import type { Bookmark } from '$lib/types/Bookmark.type'; import { applyAction, enhance } from '$app/forms'; + import { invalidate } from '$app/navigation'; + import { page } from '$app/stores'; import { bookmarksStore } from '$lib/stores/bookmarks.store'; import { editBookmarkStore } from '$lib/stores/edit-bookmark.store'; import { searchEngine } from '$lib/stores/search.store'; import { showBookmarkStore } from '$lib/stores/show-bookmark.store'; - import { userSettingsStore } from '$lib/stores/user-settings.store'; import { removeBookmarkFromSearchIndex } from '$lib/utils/search'; import { showToast } from '$lib/utils/show-toast'; import { @@ -37,7 +38,7 @@
-
- {bookmark.category.name} -
+ {bookmark.category.name} + + {/if}
{ return async ({ result }) => { + await invalidate('app:main-page'); if (result.type === 'success') { showToast.success('Bookmark deleted', { position: 'bottom-center' diff --git a/src/lib/components/BookmarkListItem/BookmarkListItem.svelte b/src/lib/components/BookmarkListItem/BookmarkListItem.svelte index 13215f3..4c9cd4d 100644 --- a/src/lib/components/BookmarkListItem/BookmarkListItem.svelte +++ b/src/lib/components/BookmarkListItem/BookmarkListItem.svelte @@ -1,10 +1,11 @@ {#if $bookmark?.id} @@ -142,8 +143,9 @@ method="POST" action="/?/updateBookmark" use:enhance={() => - ({ update, result }) => { + async ({ update, result }) => { if (result.type === 'success') { + await invalidate('app:main-page'); showToast.success('Bookmark updated', { position: 'bottom-center' }); @@ -162,8 +164,7 @@ } closeModal(); update(); - }} - > + }}>
@@ -174,8 +175,7 @@ type="text" class="hidden" name="content_published_date" - value={$bookmark.contentPublishedDate} - /> + value={$bookmark.contentPublishedDate} /> {#if error}
{error}
@@ -188,8 +188,7 @@ name="url" value={$bookmark.url} on:input={onGetMetadata} - disabled={$loading} - /> + disabled={$loading} />
{#if $loading} @@ -207,8 +206,7 @@ items={categoryItems} value={`${$bookmark.category?.id}`} placeholder={'Select category'} - class="this-select input input-bordered w-full md:min-w-28" - /> + class="this-select input input-bordered w-full md:min-w-28" /> {/if}
@@ -224,8 +222,7 @@ bind:filterText={tagsInputFilterText} bind:value={$bookmarkTagsInput} items={$bookmarkTags} - class="this-select input input-bordered min-w-full flex-1" - > + class="this-select input input-bordered min-w-full flex-1">
{item.created ? 'Create tag: ' : ''} {item.label} @@ -242,29 +239,25 @@ name="importance" class="rating-hidden" value="" - checked={!$bookmark.importance} - /> + checked={!$bookmark.importance} /> + checked={$bookmark.importance === 1} /> + checked={$bookmark.importance === 2} /> + checked={$bookmark.importance === 3} />
@@ -275,8 +268,7 @@ type="checkbox" name="flagged" class="checkbox-error checkbox" - checked={!!$bookmark.flagged} - /> + checked={!!$bookmark.flagged} />
@@ -292,8 +284,7 @@ on:input={(event) => { // @ts-ignore-next-line $bookmark.title = event.target.value; - }} - /> + }} />
@@ -306,8 +297,7 @@ on:input={(event) => { // @ts-ignore-next-line $bookmark.icon_url = event.target.value; - }} - /> + }} /> {#if $bookmark.iconUrl} {$bookmark.title} {/if} @@ -322,8 +312,7 @@ on:change={(event) => { // @ts-ignore-next-line $bookmark.description = event.target.value; - }} - /> + }} />
@@ -331,8 +320,7 @@ {$bookmark.title} + alt={$bookmark.title} /> {/if} { // @ts-ignore-next-line $bookmark.main_image_url = event.target.value; - }} - /> + }} />
@@ -355,8 +342,7 @@ on:input={(event) => { // @ts-ignore-next-line bookmark.content_text = event.target.value; - }} - /> + }} />
@@ -369,8 +355,7 @@ on:input={(event) => { // @ts-ignore-next-line $bookmark.author = event.target.value; - }} - /> + }} />
@@ -382,15 +367,13 @@ on:input={(event) => { // @ts-ignore-next-line $bookmark.note = event.target.value; - }} - /> + }} />
+ disabled={$loading || !$bookmark.url || !$bookmark.title}>Save
diff --git a/src/lib/components/EditCategoryForm/EditCategoryForm.svelte b/src/lib/components/EditCategoryForm/EditCategoryForm.svelte index 5c688a5..f7bd698 100644 --- a/src/lib/components/EditCategoryForm/EditCategoryForm.svelte +++ b/src/lib/components/EditCategoryForm/EditCategoryForm.svelte @@ -16,9 +16,9 @@ let form: HTMLFormElement; export let closeModal: () => void; - const categoriesOptions = writable<{ value: string; label: string }[]>([ + const categoriesOptions = writable<{ value: number; label: string }[]>([ { - value: 'null', + value: 0, label: 'No parent' } ]); @@ -26,7 +26,7 @@ $: { $categoriesOptions = [ { - value: 'null', + value: 0, label: 'No parent' }, ...$page.data.categories diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 704e257..7d8e3f4 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -1,7 +1,8 @@ import type { LayoutServerLoad } from './$types'; import { db } from '$lib/database/db'; import { - getBookmarksByUserId, getBookmarksCountForUser + getBookmarksByUserId, + getBookmarksCountForUser } from '$lib/database/repositories/Bookmark.repository'; import { fetchUserCategoryAndTags, getUserCount } from '$lib/database/repositories/User.repository'; import { searchIndexKeys } from '$lib/utils/search'; @@ -10,7 +11,9 @@ import type { Category } from '$lib/types/Category.type'; import type { Bookmark, BookmarkForIndex } from '$lib/types/Bookmark.type'; import type { Tag } from '$lib/types/Tag.type'; -export const load = (async ({ locals, url }) => { +export const load = (async ({ locals, url, depends }) => { + depends('app:main-page'); + const userCount = await getUserCount(); const noUsersFound = userCount === 0; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 0e47f83..47c1720 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,30 +1,53 @@ + +
@@ -42,8 +65,7 @@ type="text" placeholder="Search" bind:value={$searchedValue} - class={`input input-bordered w-full ${$searchedValue ? 'rounded-r-none' : ''}`} - /> + class={`input input-bordered w-full ${$searchedValue ? 'rounded-r-none' : ''}`} /> {#if $searchedValue}
- + {#if !user}
@@ -114,8 +134,7 @@

Categories

+ onclick="addCategoryModal.showModal()">➕
@@ -127,8 +146,7 @@ {#each $page.data.tags as tag (tag.id)} {#if tag.bookmarks?.length > 0} #{tag.name} + >#{tag.name} {/if} {/each}
@@ -159,28 +177,4 @@ - - + }} /> diff --git a/src/routes/settings/+page.server.ts b/src/routes/settings/+page.server.ts index dda4fb8..954ffb6 100644 --- a/src/routes/settings/+page.server.ts +++ b/src/routes/settings/+page.server.ts @@ -22,16 +22,43 @@ export const actions = { }; } - const data = await request.formData(); - const settings = JSON.parse(data.get('settings') as string) as UserSettings; + const settings = await request.formData(); - const updatedSettings = await updateUserSettings(owner, settings) + const mappedSettings: UserSettings = { + theme: settings.get('theme') as UserSettings['theme'], + uiAnimations: settings.get('uiAnimations') === 'on', + llm: { + enabled: settings.get('llmEnabled') === 'on', + provider: settings.get('llmProvider') as UserSettings['llm']['provider'], + ollama: { + url: settings.get('llmOllamaUrl') as string, + model: settings.get('llmOllamaModel') as string, + summarize: { + enabled: settings.get('llmOllamaSummarizeEnabled') === 'on', + system: settings.get('llmOllamaSystemmsg') as string + }, + generateTags: { + enabled: settings.get('llmOllamaGenerateTagsEnabled') === 'on', + system: settings.get('llmOllamaSystemmsg') as string + } + }, + openai: { + apiKey: settings.get('llmOpenaiApikey') as string + } + } + }; + + console.log('Received mappedSettings:', JSON.stringify(mappedSettings, null, 2)); + + const updatedSettings = await updateUserSettings(owner, mappedSettings) .then(({ settings }) => settings) .catch((err) => { console.error('Error updating user settings. Details:', JSON.stringify(err, null, 2)); return null; }); + console.log('Updated settings:', JSON.stringify(updatedSettings, null, 2)); + if (!updatedSettings) { return { success: false,