2024-01-27 05:22:25 +00:00
|
|
|
<script lang="ts">
|
2024-03-01 09:18:07 +00:00
|
|
|
import { toast } from 'svelte-sonner';
|
2024-03-02 20:38:51 +00:00
|
|
|
import { onMount, getContext } from 'svelte';
|
2024-01-27 05:22:25 +00:00
|
|
|
|
2024-12-21 06:54:43 +00:00
|
|
|
import { user, config, settings } from '$lib/stores';
|
2025-02-10 21:00:44 +00:00
|
|
|
import { updateUserProfile, createAPIKey, getAPIKey, getSessionUser } from '$lib/apis/auths';
|
2025-07-09 06:38:28 +00:00
|
|
|
import { WEBUI_BASE_URL } from '$lib/constants';
|
2024-01-27 05:22:25 +00:00
|
|
|
|
|
|
|
|
import UpdatePassword from './Account/UpdatePassword.svelte';
|
2024-01-27 05:38:33 +00:00
|
|
|
import { getGravatarUrl } from '$lib/apis/utils';
|
2024-04-05 22:04:00 +00:00
|
|
|
import { generateInitialsImage, canvasPixelTest } from '$lib/utils';
|
2024-02-20 04:44:00 +00:00
|
|
|
import { copyToClipboard } from '$lib/utils';
|
2024-04-02 16:58:34 +00:00
|
|
|
import Plus from '$lib/components/icons/Plus.svelte';
|
|
|
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
2024-06-25 12:15:29 +00:00
|
|
|
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
|
2025-08-20 21:20:38 +00:00
|
|
|
import Textarea from '$lib/components/common/Textarea.svelte';
|
2025-08-20 22:39:25 +00:00
|
|
|
import { getUserById } from '$lib/apis/users';
|
2025-09-29 05:51:06 +00:00
|
|
|
import User from '$lib/components/icons/User.svelte';
|
|
|
|
|
import UserProfileImage from './Account/UserProfileImage.svelte';
|
2024-01-27 05:22:25 +00:00
|
|
|
|
2024-03-02 20:38:51 +00:00
|
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
2024-01-27 05:22:25 +00:00
|
|
|
export let saveHandler: Function;
|
2024-12-21 06:54:43 +00:00
|
|
|
export let saveSettings: Function;
|
2024-01-27 05:22:25 +00:00
|
|
|
|
2025-08-20 22:39:25 +00:00
|
|
|
let loaded = false;
|
|
|
|
|
|
2024-01-27 05:22:25 +00:00
|
|
|
let profileImageUrl = '';
|
|
|
|
|
let name = '';
|
2025-08-20 21:20:38 +00:00
|
|
|
let bio = '';
|
2024-04-02 16:39:55 +00:00
|
|
|
|
2025-08-20 22:39:25 +00:00
|
|
|
let _gender = '';
|
|
|
|
|
let gender = '';
|
|
|
|
|
let dateOfBirth = '';
|
|
|
|
|
|
2024-12-21 06:54:43 +00:00
|
|
|
let webhookUrl = '';
|
2024-04-07 07:05:13 +00:00
|
|
|
let showAPIKeys = false;
|
|
|
|
|
|
2024-02-20 04:44:00 +00:00
|
|
|
let JWTTokenCopied = false;
|
2024-04-02 16:39:55 +00:00
|
|
|
|
|
|
|
|
let APIKey = '';
|
|
|
|
|
let APIKeyCopied = false;
|
2024-03-03 22:32:04 +00:00
|
|
|
let profileImageInputElement: HTMLInputElement;
|
2024-01-27 05:22:25 +00:00
|
|
|
|
|
|
|
|
const submitHandler = async () => {
|
2025-04-01 03:32:12 +00:00
|
|
|
if (name !== $user?.name) {
|
|
|
|
|
if (profileImageUrl === generateInitialsImage($user?.name) || profileImageUrl === '') {
|
2024-04-07 06:49:25 +00:00
|
|
|
profileImageUrl = generateInitialsImage(name);
|
|
|
|
|
}
|
2024-04-01 23:26:05 +00:00
|
|
|
}
|
2024-04-01 23:23:54 +00:00
|
|
|
|
2024-12-21 06:54:43 +00:00
|
|
|
if (webhookUrl !== $settings?.notifications?.webhook_url) {
|
|
|
|
|
saveSettings({
|
|
|
|
|
notifications: {
|
|
|
|
|
...$settings.notifications,
|
|
|
|
|
webhook_url: webhookUrl
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-20 22:39:25 +00:00
|
|
|
const updatedUser = await updateUserProfile(localStorage.token, {
|
|
|
|
|
name: name,
|
|
|
|
|
profile_image_url: profileImageUrl,
|
|
|
|
|
bio: bio ? bio : null,
|
|
|
|
|
gender: gender ? gender : null,
|
|
|
|
|
date_of_birth: dateOfBirth ? dateOfBirth : null
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
toast.error(`${error}`);
|
|
|
|
|
});
|
2024-01-27 05:22:25 +00:00
|
|
|
|
|
|
|
|
if (updatedUser) {
|
2025-02-10 21:00:44 +00:00
|
|
|
// Get Session User Info
|
|
|
|
|
const sessionUser = await getSessionUser(localStorage.token).catch((error) => {
|
|
|
|
|
toast.error(`${error}`);
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await user.set(sessionUser);
|
2024-01-27 05:22:25 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-02 16:39:55 +00:00
|
|
|
const createAPIKeyHandler = async () => {
|
|
|
|
|
APIKey = await createAPIKey(localStorage.token);
|
|
|
|
|
if (APIKey) {
|
2024-03-26 10:24:14 +00:00
|
|
|
toast.success($i18n.t('API Key created.'));
|
|
|
|
|
} else {
|
|
|
|
|
toast.error($i18n.t('Failed to create API Key.'));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-02 16:39:55 +00:00
|
|
|
onMount(async () => {
|
2025-08-20 22:39:25 +00:00
|
|
|
const user = await getSessionUser(localStorage.token).catch((error) => {
|
|
|
|
|
toast.error(`${error}`);
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (user) {
|
|
|
|
|
name = user?.name ?? '';
|
|
|
|
|
profileImageUrl = user?.profile_image_url ?? '';
|
|
|
|
|
bio = user?.bio ?? '';
|
|
|
|
|
|
|
|
|
|
_gender = user?.gender ?? '';
|
|
|
|
|
gender = _gender;
|
|
|
|
|
|
|
|
|
|
dateOfBirth = user?.date_of_birth ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-21 06:54:43 +00:00
|
|
|
webhookUrl = $settings?.notifications?.webhook_url ?? '';
|
2024-04-02 16:39:55 +00:00
|
|
|
|
|
|
|
|
APIKey = await getAPIKey(localStorage.token).catch((error) => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
return '';
|
|
|
|
|
});
|
2025-08-20 22:39:25 +00:00
|
|
|
|
|
|
|
|
loaded = true;
|
2024-01-27 05:22:25 +00:00
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
2025-06-11 11:45:47 +00:00
|
|
|
<div id="tab-account" class="flex flex-col h-full justify-between text-sm">
|
2025-09-23 00:03:44 +00:00
|
|
|
<div class=" overflow-y-scroll max-h-[28rem] md:max-h-full">
|
2024-04-07 07:31:59 +00:00
|
|
|
<div class="space-y-1">
|
2025-08-20 21:20:38 +00:00
|
|
|
<div>
|
|
|
|
|
<div class="text-base font-medium">{$i18n.t('Your Account')}</div>
|
|
|
|
|
|
|
|
|
|
<div class="text-xs text-gray-500 mt-0.5">
|
|
|
|
|
{$i18n.t('Manage your account information.')}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-04-07 07:31:59 +00:00
|
|
|
<!-- <div class=" text-sm font-medium">{$i18n.t('Account')}</div> -->
|
|
|
|
|
|
2025-08-20 22:39:25 +00:00
|
|
|
<div class="flex space-x-5 my-4">
|
2025-09-29 05:51:06 +00:00
|
|
|
<UserProfileImage bind:profileImageUrl user={$user} />
|
2024-04-07 07:31:59 +00:00
|
|
|
|
2025-08-20 21:20:38 +00:00
|
|
|
<div class="flex flex-1 flex-col">
|
|
|
|
|
<div class=" flex-1">
|
|
|
|
|
<div class="flex flex-col w-full">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Name')}</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex-1">
|
|
|
|
|
<input
|
|
|
|
|
class="w-full text-sm dark:text-gray-300 bg-transparent outline-hidden"
|
|
|
|
|
type="text"
|
|
|
|
|
bind:value={name}
|
|
|
|
|
required
|
|
|
|
|
placeholder={$i18n.t('Enter your name')}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-07 07:31:59 +00:00
|
|
|
|
2025-08-20 21:20:38 +00:00
|
|
|
<div class="flex flex-col w-full mt-2">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Bio')}</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex-1">
|
|
|
|
|
<Textarea
|
|
|
|
|
className="w-full text-sm dark:text-gray-300 bg-transparent outline-hidden"
|
2025-08-20 22:39:25 +00:00
|
|
|
minSize={60}
|
2025-08-20 21:20:38 +00:00
|
|
|
bind:value={bio}
|
|
|
|
|
placeholder={$i18n.t('Share your background and interests')}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-08-20 22:39:25 +00:00
|
|
|
|
|
|
|
|
<div class="flex flex-col w-full mt-2">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Gender')}</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex-1">
|
|
|
|
|
<select
|
|
|
|
|
class="w-full text-sm dark:text-gray-300 bg-transparent outline-hidden"
|
|
|
|
|
bind:value={_gender}
|
|
|
|
|
on:change={(e) => {
|
|
|
|
|
console.log(_gender);
|
|
|
|
|
|
|
|
|
|
if (_gender === 'custom') {
|
|
|
|
|
// Handle custom gender input
|
|
|
|
|
gender = '';
|
|
|
|
|
} else {
|
|
|
|
|
gender = _gender;
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<option value="" selected>{$i18n.t('Prefer not to say')}</option>
|
|
|
|
|
<option value="male">{$i18n.t('Male')}</option>
|
|
|
|
|
<option value="female">{$i18n.t('Female')}</option>
|
|
|
|
|
<option value="custom">{$i18n.t('Custom')}</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if _gender === 'custom'}
|
|
|
|
|
<input
|
|
|
|
|
class="w-full text-sm dark:text-gray-300 bg-transparent outline-hidden mt-1"
|
|
|
|
|
type="text"
|
|
|
|
|
required
|
|
|
|
|
placeholder={$i18n.t('Enter your gender')}
|
|
|
|
|
bind:value={gender}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-col w-full mt-2">
|
|
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Birth Date')}</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex-1">
|
|
|
|
|
<input
|
|
|
|
|
class="w-full text-sm dark:text-gray-300 dark:placeholder:text-gray-300 bg-transparent outline-hidden"
|
|
|
|
|
type="date"
|
|
|
|
|
bind:value={dateOfBirth}
|
|
|
|
|
required
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-07 07:31:59 +00:00
|
|
|
</div>
|
2024-01-27 05:22:25 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-08-20 21:20:38 +00:00
|
|
|
</div>
|
2024-01-27 05:22:25 +00:00
|
|
|
|
2025-08-20 21:20:38 +00:00
|
|
|
{#if $config?.features?.enable_user_webhooks}
|
|
|
|
|
<div class="mt-2">
|
2024-04-07 07:31:59 +00:00
|
|
|
<div class="flex flex-col w-full">
|
2025-08-20 21:20:38 +00:00
|
|
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Notification Webhook')}</div>
|
2024-04-07 07:31:59 +00:00
|
|
|
|
|
|
|
|
<div class="flex-1">
|
|
|
|
|
<input
|
2025-08-20 21:20:38 +00:00
|
|
|
class="w-full text-sm outline-hidden"
|
|
|
|
|
type="url"
|
|
|
|
|
placeholder={$i18n.t('Enter your webhook URL')}
|
|
|
|
|
bind:value={webhookUrl}
|
2024-04-07 07:31:59 +00:00
|
|
|
required
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-04-07 06:49:25 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-08-20 21:20:38 +00:00
|
|
|
{/if}
|
2024-12-21 06:54:43 +00:00
|
|
|
|
2025-08-20 21:20:38 +00:00
|
|
|
<hr class="border-gray-50 dark:border-gray-850 my-4" />
|
2024-03-26 10:24:14 +00:00
|
|
|
|
2025-08-13 17:58:17 +00:00
|
|
|
{#if $config?.features.enable_login_form}
|
2025-08-20 21:20:38 +00:00
|
|
|
<div class="mt-2">
|
2025-08-13 17:58:17 +00:00
|
|
|
<UpdatePassword />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-02-20 04:44:00 +00:00
|
|
|
|
2025-04-28 13:45:17 +00:00
|
|
|
{#if ($config?.features?.enable_api_key ?? true) || $user?.role === 'admin'}
|
2025-08-20 21:20:38 +00:00
|
|
|
<div class="flex justify-between items-center text-sm mt-2">
|
2025-04-28 13:45:17 +00:00
|
|
|
<div class=" font-medium">{$i18n.t('API keys')}</div>
|
|
|
|
|
<button
|
|
|
|
|
class=" text-xs font-medium text-gray-500"
|
|
|
|
|
type="button"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
showAPIKeys = !showAPIKeys;
|
|
|
|
|
}}>{showAPIKeys ? $i18n.t('Hide') : $i18n.t('Show')}</button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
2024-02-20 04:44:00 +00:00
|
|
|
|
2025-04-28 13:45:17 +00:00
|
|
|
{#if showAPIKeys}
|
2025-08-20 21:20:38 +00:00
|
|
|
<div class="flex flex-col py-2.5">
|
2025-04-28 13:45:17 +00:00
|
|
|
{#if $user?.role === 'admin'}
|
|
|
|
|
<div class="justify-between w-full">
|
|
|
|
|
<div class="flex justify-between w-full">
|
2025-04-28 14:21:48 +00:00
|
|
|
<div class="self-center text-xs font-medium mb-1">{$i18n.t('JWT Token')}</div>
|
2025-04-28 13:45:17 +00:00
|
|
|
</div>
|
2024-03-26 10:24:14 +00:00
|
|
|
|
2025-04-28 14:21:48 +00:00
|
|
|
<div class="flex">
|
2025-04-28 13:45:17 +00:00
|
|
|
<SensitiveInput value={localStorage.token} readOnly={true} />
|
2024-04-02 16:33:27 +00:00
|
|
|
|
2024-04-07 07:05:13 +00:00
|
|
|
<button
|
2024-11-19 14:14:52 +00:00
|
|
|
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-850 transition rounded-lg"
|
2024-04-07 07:05:13 +00:00
|
|
|
on:click={() => {
|
2025-04-28 13:45:17 +00:00
|
|
|
copyToClipboard(localStorage.token);
|
|
|
|
|
JWTTokenCopied = true;
|
2024-11-19 14:14:52 +00:00
|
|
|
setTimeout(() => {
|
2025-04-28 13:45:17 +00:00
|
|
|
JWTTokenCopied = false;
|
2024-11-19 14:14:52 +00:00
|
|
|
}, 2000);
|
2024-04-07 07:05:13 +00:00
|
|
|
}}
|
|
|
|
|
>
|
2025-04-28 13:45:17 +00:00
|
|
|
{#if JWTTokenCopied}
|
2024-11-19 14:14:52 +00:00
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 20 20"
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
class="w-4 h-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
{:else}
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
class="w-4 h-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M11.986 3H12a2 2 0 0 1 2 2v6a2 2 0 0 1-1.5 1.937V7A2.5 2.5 0 0 0 10 4.5H4.063A2 2 0 0 1 6 3h.014A2.25 2.25 0 0 1 8.25 1h1.5a2.25 2.25 0 0 1 2.236 2ZM10.5 4v-.75a.75.75 0 0 0-.75-.75h-1.5a.75.75 0 0 0-.75.75V4h3Z"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
<path
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M3 6a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm1.75 2.5a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5h-3.5ZM4 11.75a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75Z"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
{/if}
|
2024-04-07 07:05:13 +00:00
|
|
|
</button>
|
2025-04-28 13:45:17 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if $config?.features?.enable_api_key ?? true}
|
2025-08-20 21:20:38 +00:00
|
|
|
<div class="justify-between w-full mt-2">
|
2025-04-28 13:45:17 +00:00
|
|
|
{#if $user?.role === 'admin'}
|
|
|
|
|
<div class="flex justify-between w-full">
|
2025-04-28 14:21:48 +00:00
|
|
|
<div class="self-center text-xs font-medium mb-1">{$i18n.t('API Key')}</div>
|
2025-04-28 13:45:17 +00:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
2025-04-28 14:21:48 +00:00
|
|
|
<div class="flex">
|
2025-04-28 13:45:17 +00:00
|
|
|
{#if APIKey}
|
|
|
|
|
<SensitiveInput value={APIKey} readOnly={true} />
|
2024-04-07 07:05:13 +00:00
|
|
|
|
2024-11-19 14:14:52 +00:00
|
|
|
<button
|
2025-04-28 13:45:17 +00:00
|
|
|
class="ml-1.5 px-1.5 py-1 dark:hover:bg-gray-850 transition rounded-lg"
|
2024-11-19 14:14:52 +00:00
|
|
|
on:click={() => {
|
2025-04-28 13:45:17 +00:00
|
|
|
copyToClipboard(APIKey);
|
|
|
|
|
APIKeyCopied = true;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
APIKeyCopied = false;
|
|
|
|
|
}, 2000);
|
2024-11-19 14:14:52 +00:00
|
|
|
}}
|
|
|
|
|
>
|
2025-04-28 13:45:17 +00:00
|
|
|
{#if APIKeyCopied}
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 20 20"
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
class="w-4 h-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
{:else}
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
class="w-4 h-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M11.986 3H12a2 2 0 0 1 2 2v6a2 2 0 0 1-1.5 1.937V7A2.5 2.5 0 0 0 10 4.5H4.063A2 2 0 0 1 6 3h.014A2.25 2.25 0 0 1 8.25 1h1.5a2.25 2.25 0 0 1 2.236 2ZM10.5 4v-.75a.75.75 0 0 0-.75-.75h-1.5a.75.75 0 0 0-.75.75V4h3Z"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
<path
|
|
|
|
|
fill-rule="evenodd"
|
|
|
|
|
d="M3 6a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm1.75 2.5a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5h-3.5ZM4 11.75a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75Z"
|
|
|
|
|
clip-rule="evenodd"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
{/if}
|
2024-11-19 14:14:52 +00:00
|
|
|
</button>
|
|
|
|
|
|
2025-04-28 13:45:17 +00:00
|
|
|
<Tooltip content={$i18n.t('Create new key')}>
|
|
|
|
|
<button
|
|
|
|
|
class=" px-1.5 py-1 dark:hover:bg-gray-850transition rounded-lg"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
createAPIKeyHandler();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
fill="none"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
stroke-width="2"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
class="size-4"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
{:else}
|
|
|
|
|
<button
|
|
|
|
|
class="flex gap-1.5 items-center font-medium px-3.5 py-1.5 rounded-lg bg-gray-100/70 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-850 transition"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
createAPIKeyHandler();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Plus strokeWidth="2" className=" size-3.5" />
|
|
|
|
|
|
|
|
|
|
{$i18n.t('Create new secret key')}</button
|
|
|
|
|
>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2024-11-19 14:14:52 +00:00
|
|
|
</div>
|
2025-04-28 13:45:17 +00:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-04-07 07:05:13 +00:00
|
|
|
{/if}
|
2024-01-27 05:22:25 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end pt-3 text-sm font-medium">
|
|
|
|
|
<button
|
2024-10-21 07:05:27 +00:00
|
|
|
class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full"
|
2024-01-27 05:22:25 +00:00
|
|
|
on:click={async () => {
|
|
|
|
|
const res = await submitHandler();
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
saveHandler();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-03-04 08:53:56 +00:00
|
|
|
{$i18n.t('Save')}
|
2024-01-27 05:22:25 +00:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|