Spaces:
Paused
Paused
refactor: replace anchor tags with buttons in settings navigation
Browse files
src/routes/settings/(nav)/+layout.svelte
CHANGED
|
@@ -110,10 +110,12 @@
|
|
| 110 |
</h3>
|
| 111 |
|
| 112 |
{#each data.models.filter((el) => !el.unlisted) as model}
|
| 113 |
-
<
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
{model.id === page.params.model ? '!bg-gray-100 !text-gray-800' : ''}"
|
|
|
|
| 117 |
>
|
| 118 |
<div class="mr-auto truncate">{model.displayName}</div>
|
| 119 |
|
|
@@ -129,7 +131,7 @@
|
|
| 129 |
Active
|
| 130 |
</div>
|
| 131 |
{/if}
|
| 132 |
-
</
|
| 133 |
{/each}
|
| 134 |
{#if data.enableAssistants}
|
| 135 |
<h3
|
|
@@ -146,10 +148,12 @@
|
|
| 146 |
</h4>
|
| 147 |
|
| 148 |
{#each data.assistants.filter((assistant) => assistant.createdByMe) as assistant}
|
| 149 |
-
<
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
| 153 |
>
|
| 154 |
{#if assistant.avatar}
|
| 155 |
<img
|
|
@@ -172,17 +176,19 @@
|
|
| 172 |
Active
|
| 173 |
</div>
|
| 174 |
{/if}
|
| 175 |
-
</
|
| 176 |
{/each}
|
| 177 |
{#if !data.loginEnabled || (data.loginEnabled && !!data.user)}
|
| 178 |
-
<
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
| 182 |
>
|
| 183 |
<CarbonAdd />
|
| 184 |
<div class="truncate">Create new assistant</div>
|
| 185 |
-
</
|
| 186 |
{/if}
|
| 187 |
|
| 188 |
<!-- Other Assistants -->
|
|
@@ -193,82 +199,92 @@
|
|
| 193 |
</h4>
|
| 194 |
|
| 195 |
{#each data.assistants.filter((assistant) => !assistant.createdByMe) as assistant}
|
| 196 |
-
<
|
| 197 |
-
href="{base}/settings/assistants/{assistant._id.toString()}"
|
| 198 |
-
class="group flex h-10 flex-none items-center gap-2 px-4 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl md:px-3
|
| 199 |
-
{assistant._id.toString() === page.params.assistantId ? '!bg-gray-100 !text-gray-800' : ''}"
|
| 200 |
-
>
|
| 201 |
-
{#if assistant.avatar}
|
| 202 |
-
<img
|
| 203 |
-
src="{base}/settings/assistants/{assistant._id.toString()}/avatar.jpg?hash={assistant.avatar}"
|
| 204 |
-
alt="Avatar"
|
| 205 |
-
class="h-6 w-6 rounded-full"
|
| 206 |
-
/>
|
| 207 |
-
{:else}
|
| 208 |
-
<div
|
| 209 |
-
class="flex size-6 items-center justify-center rounded-full bg-gray-300 font-bold uppercase text-gray-500"
|
| 210 |
-
>
|
| 211 |
-
{assistant.name[0]}
|
| 212 |
-
</div>
|
| 213 |
-
{/if}
|
| 214 |
-
<div class="truncate">{assistant.name}</div>
|
| 215 |
-
{#if assistant._id.toString() === $settings.activeModel}
|
| 216 |
-
<div
|
| 217 |
-
class="ml-auto rounded-lg bg-black px-2 py-1.5 text-xs font-semibold leading-none text-white"
|
| 218 |
-
>
|
| 219 |
-
Active
|
| 220 |
-
</div>
|
| 221 |
-
{/if}
|
| 222 |
<button
|
| 223 |
-
type="
|
| 224 |
-
|
| 225 |
-
class=
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
? "block"
|
| 229 |
-
: "hidden group-hover:block",
|
| 230 |
-
assistant._id.toString() !== $settings.activeModel && "ml-auto",
|
| 231 |
-
]}
|
| 232 |
-
onclick={(event) => {
|
| 233 |
-
event.stopPropagation();
|
| 234 |
-
fetch(`${base}/api/assistant/${assistant._id}/subscribe`, {
|
| 235 |
-
method: "DELETE",
|
| 236 |
-
}).then((r) => {
|
| 237 |
-
if (r.ok) {
|
| 238 |
-
if (assistant._id.toString() === page.params.assistantId) {
|
| 239 |
-
goto(`${base}/settings`, { invalidateAll: true });
|
| 240 |
-
} else {
|
| 241 |
-
invalidateAll();
|
| 242 |
-
}
|
| 243 |
-
} else {
|
| 244 |
-
console.error(r);
|
| 245 |
-
$error = r.statusText;
|
| 246 |
-
}
|
| 247 |
-
});
|
| 248 |
-
}}
|
| 249 |
>
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
</button>
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
{/each}
|
| 254 |
-
<
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
| 257 |
>
|
| 258 |
<CarbonArrowUpRight class="mr-1.5 shrink-0 text-xs" />
|
| 259 |
<div class="truncate">Browse Assistants</div>
|
| 260 |
-
</
|
| 261 |
{/if}
|
| 262 |
|
| 263 |
<div class="my-2 mt-auto w-full border-b border-gray-200"></div>
|
| 264 |
-
<
|
| 265 |
-
|
| 266 |
-
|
|
|
|
| 267 |
{page.url.pathname === `${base}/settings/application` ? '!bg-gray-100 !text-gray-800' : ''}"
|
|
|
|
| 268 |
>
|
| 269 |
<UserIcon class="text-sm" />
|
| 270 |
Application Settings
|
| 271 |
-
</
|
| 272 |
</div>
|
| 273 |
{/if}
|
| 274 |
{#if showContent}
|
|
|
|
| 110 |
</h3>
|
| 111 |
|
| 112 |
{#each data.models.filter((el) => !el.unlisted) as model}
|
| 113 |
+
<button
|
| 114 |
+
type="button"
|
| 115 |
+
onclick={() => goto(`${base}/settings/${model.id}`)}
|
| 116 |
+
class="group flex h-10 w-full flex-none items-center gap-2 px-4 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl md:px-3
|
| 117 |
{model.id === page.params.model ? '!bg-gray-100 !text-gray-800' : ''}"
|
| 118 |
+
aria-label="Configure {model.displayName}"
|
| 119 |
>
|
| 120 |
<div class="mr-auto truncate">{model.displayName}</div>
|
| 121 |
|
|
|
|
| 131 |
Active
|
| 132 |
</div>
|
| 133 |
{/if}
|
| 134 |
+
</button>
|
| 135 |
{/each}
|
| 136 |
{#if data.enableAssistants}
|
| 137 |
<h3
|
|
|
|
| 148 |
</h4>
|
| 149 |
|
| 150 |
{#each data.assistants.filter((assistant) => assistant.createdByMe) as assistant}
|
| 151 |
+
<button
|
| 152 |
+
type="button"
|
| 153 |
+
onclick={() => goto(`${base}/settings/assistants/${assistant._id.toString()}`)}
|
| 154 |
+
class="group flex h-10 w-full flex-none items-center gap-2 px-4 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl md:px-3
|
| 155 |
+
{assistant._id.toString() === page.params.assistantId ? '!bg-gray-100 !text-gray-800' : ''}"
|
| 156 |
+
aria-label="Configure {assistant.name} assistant"
|
| 157 |
>
|
| 158 |
{#if assistant.avatar}
|
| 159 |
<img
|
|
|
|
| 176 |
Active
|
| 177 |
</div>
|
| 178 |
{/if}
|
| 179 |
+
</button>
|
| 180 |
{/each}
|
| 181 |
{#if !data.loginEnabled || (data.loginEnabled && !!data.user)}
|
| 182 |
+
<button
|
| 183 |
+
type="button"
|
| 184 |
+
onclick={() => goto(`${base}/settings/assistants/new`)}
|
| 185 |
+
class="group flex h-10 w-full flex-none items-center gap-2 px-4 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl md:px-3
|
| 186 |
+
{page.url.pathname === `${base}/settings/assistants/new` ? '!bg-gray-100 !text-gray-800' : ''}"
|
| 187 |
+
aria-label="Create new assistant"
|
| 188 |
>
|
| 189 |
<CarbonAdd />
|
| 190 |
<div class="truncate">Create new assistant</div>
|
| 191 |
+
</button>
|
| 192 |
{/if}
|
| 193 |
|
| 194 |
<!-- Other Assistants -->
|
|
|
|
| 199 |
</h4>
|
| 200 |
|
| 201 |
{#each data.assistants.filter((assistant) => !assistant.createdByMe) as assistant}
|
| 202 |
+
<div class="group relative">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
<button
|
| 204 |
+
type="button"
|
| 205 |
+
onclick={() => goto(`${base}/settings/assistants/${assistant._id.toString()}`)}
|
| 206 |
+
class="group flex h-10 w-full flex-none items-center gap-2 px-4 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl md:px-3
|
| 207 |
+
{assistant._id.toString() === page.params.assistantId ? '!bg-gray-100 !text-gray-800' : ''}"
|
| 208 |
+
aria-label="Configure {assistant.name} assistant"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
>
|
| 210 |
+
{#if assistant.avatar}
|
| 211 |
+
<img
|
| 212 |
+
src="{base}/settings/assistants/{assistant._id.toString()}/avatar.jpg?hash={assistant.avatar}"
|
| 213 |
+
alt="Avatar"
|
| 214 |
+
class="h-6 w-6 rounded-full"
|
| 215 |
+
/>
|
| 216 |
+
{:else}
|
| 217 |
+
<div
|
| 218 |
+
class="flex size-6 items-center justify-center rounded-full bg-gray-300 font-bold uppercase text-gray-500"
|
| 219 |
+
>
|
| 220 |
+
{assistant.name[0]}
|
| 221 |
+
</div>
|
| 222 |
+
{/if}
|
| 223 |
+
<div class="truncate">{assistant.name}</div>
|
| 224 |
+
{#if assistant._id.toString() === $settings.activeModel}
|
| 225 |
+
<div
|
| 226 |
+
class="ml-auto rounded-lg bg-black px-2 py-1.5 text-xs font-semibold leading-none text-white"
|
| 227 |
+
>
|
| 228 |
+
Active
|
| 229 |
+
</div>
|
| 230 |
+
{/if}
|
| 231 |
</button>
|
| 232 |
+
<div class="absolute right-2 top-1/2 -translate-y-1/2">
|
| 233 |
+
<button
|
| 234 |
+
type="button"
|
| 235 |
+
aria-label="Remove assistant from your list"
|
| 236 |
+
class={[
|
| 237 |
+
"rounded-full p-1 text-xs hover:bg-gray-500 hover:bg-opacity-20",
|
| 238 |
+
assistant._id.toString() === page.params.assistantId
|
| 239 |
+
? "block"
|
| 240 |
+
: "hidden group-hover:block",
|
| 241 |
+
assistant._id.toString() !== $settings.activeModel && "ml-auto",
|
| 242 |
+
]}
|
| 243 |
+
onclick={(event) => {
|
| 244 |
+
event.stopPropagation();
|
| 245 |
+
fetch(`${base}/api/assistant/${assistant._id}/subscribe`, {
|
| 246 |
+
method: "DELETE",
|
| 247 |
+
}).then((r) => {
|
| 248 |
+
if (r.ok) {
|
| 249 |
+
if (assistant._id.toString() === page.params.assistantId) {
|
| 250 |
+
goto(`${base}/settings`, { invalidateAll: true });
|
| 251 |
+
} else {
|
| 252 |
+
invalidateAll();
|
| 253 |
+
}
|
| 254 |
+
} else {
|
| 255 |
+
console.error(r);
|
| 256 |
+
$error = r.statusText;
|
| 257 |
+
}
|
| 258 |
+
});
|
| 259 |
+
}}
|
| 260 |
+
>
|
| 261 |
+
<CarbonClose class="size-4 text-gray-500" />
|
| 262 |
+
</button>
|
| 263 |
+
</div>
|
| 264 |
+
</div>
|
| 265 |
{/each}
|
| 266 |
+
<button
|
| 267 |
+
type="button"
|
| 268 |
+
onclick={() => goto(`${base}/assistants`)}
|
| 269 |
+
class="group flex h-10 w-full flex-none items-center gap-2 px-4 text-sm text-gray-500 hover:bg-gray-100 md:rounded-xl md:px-3"
|
| 270 |
+
aria-label="Browse all assistants"
|
| 271 |
>
|
| 272 |
<CarbonArrowUpRight class="mr-1.5 shrink-0 text-xs" />
|
| 273 |
<div class="truncate">Browse Assistants</div>
|
| 274 |
+
</button>
|
| 275 |
{/if}
|
| 276 |
|
| 277 |
<div class="my-2 mt-auto w-full border-b border-gray-200"></div>
|
| 278 |
+
<button
|
| 279 |
+
type="button"
|
| 280 |
+
onclick={() => goto(`${base}/settings/application`)}
|
| 281 |
+
class="group flex h-10 w-full flex-none items-center gap-2 px-4 text-sm text-gray-500 hover:bg-gray-100 max-md:order-first md:rounded-xl md:px-3
|
| 282 |
{page.url.pathname === `${base}/settings/application` ? '!bg-gray-100 !text-gray-800' : ''}"
|
| 283 |
+
aria-label="Configure application settings"
|
| 284 |
>
|
| 285 |
<UserIcon class="text-sm" />
|
| 286 |
Application Settings
|
| 287 |
+
</button>
|
| 288 |
</div>
|
| 289 |
{/if}
|
| 290 |
{#if showContent}
|