From 7e78889e33b09ba86a6b7c560eb2098ef88cba76 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 15 Nov 2024 18:56:13 -0800 Subject: [PATCH] refac: styling --- .../components/admin/Settings/Models.svelte | 349 +++++++++--------- 1 file changed, 180 insertions(+), 169 deletions(-) diff --git a/src/lib/components/admin/Settings/Models.svelte b/src/lib/components/admin/Settings/Models.svelte index 6934157fa..0740e5afa 100644 --- a/src/lib/components/admin/Settings/Models.svelte +++ b/src/lib/components/admin/Settings/Models.svelte @@ -18,11 +18,12 @@ import Search from '$lib/components/icons/Search.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte'; import Switch from '$lib/components/common/Switch.svelte'; + import Spinner from '$lib/components/common/Spinner.svelte'; let importFiles; let modelsImportInputElement: HTMLInputElement; - let models = []; + let models = null; let filteredModels = []; $: if (models) { @@ -65,195 +66,205 @@ }); -
-
-
- {$i18n.t('Models')} -
- {filteredModels.length} -
-
- -
-
-
- +{#if models !== null} +
+
+
+ {$i18n.t('Models')} +
+ {filteredModels.length} +
+
+ +
+
+
+ +
+
-
-
-
- {#each filteredModels as model (model.id)} -
- + {#each filteredModels as model (model.id)} +
-
-
- modelfile profile -
-
- -
- -
{model.name}
-
-
- {model?.meta?.description ?? model.id} -
-
-
-
- {#if $user?.role === 'admin' || model.user_id === $user?.id} - - +
+
- - - - {/if} +
+
-
- - { - toggleModelById(localStorage.token, model.id); - _models.set(await getModels(localStorage.token)); - }} - /> - +
+ +
{model.name}
+
+
+ {model?.meta?.description ?? model.id} +
+
+ +
+ {#if $user?.role === 'admin' || model.user_id === $user?.id} + + + + + + {/if} + +
+ + { + toggleModelById(localStorage.token, model.id); + _models.set(await getModels(localStorage.token)); + }} + /> + +
-
- {/each} -
+ {/each} +
-{#if $user?.role === 'admin'} -
-
- { - console.log(importFiles); + {#if $user?.role === 'admin'} +
+
+ { + console.log(importFiles); - let reader = new FileReader(); - reader.onload = async (event) => { - let savedModels = JSON.parse(event.target.result); - console.log(savedModels); + let reader = new FileReader(); + reader.onload = async (event) => { + let savedModels = JSON.parse(event.target.result); + console.log(savedModels); - for (const model of savedModels) { - if (model?.info ?? false) { - if ($_models.find((m) => m.id === model.id)) { - await updateModelById(localStorage.token, model.id, model.info).catch((error) => { - return null; - }); - } else { - await createNewModel(localStorage.token, model.info).catch((error) => { - return null; - }); + for (const model of savedModels) { + if (model?.info ?? false) { + if ($_models.find((m) => m.id === model.id)) { + await updateModelById(localStorage.token, model.id, model.info).catch( + (error) => { + return null; + } + ); + } else { + await createNewModel(localStorage.token, model.info).catch((error) => { + return null; + }); + } } } - } - await _models.set(await getModels(localStorage.token)); - init(); - }; + await _models.set(await getModels(localStorage.token)); + init(); + }; - reader.readAsText(importFiles[0]); - }} - /> + reader.readAsText(importFiles[0]); + }} + /> - +
+ + + +
+ - +
+ + + +
+ +
+ {/if} +{:else} +
+
{/if}