|
@@ -2,7 +2,7 @@
|
|
import { toast } from 'svelte-sonner';
|
|
import { toast } from 'svelte-sonner';
|
|
import { onMount, getContext } from 'svelte';
|
|
import { onMount, getContext } from 'svelte';
|
|
|
|
|
|
- import { user, config } from '$lib/stores';
|
|
|
|
|
|
+ import { user, config, settings } from '$lib/stores';
|
|
import { updateUserProfile, createAPIKey, getAPIKey } from '$lib/apis/auths';
|
|
import { updateUserProfile, createAPIKey, getAPIKey } from '$lib/apis/auths';
|
|
|
|
|
|
import UpdatePassword from './Account/UpdatePassword.svelte';
|
|
import UpdatePassword from './Account/UpdatePassword.svelte';
|
|
@@ -16,10 +16,12 @@
|
|
const i18n = getContext('i18n');
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
export let saveHandler: Function;
|
|
export let saveHandler: Function;
|
|
|
|
+ export let saveSettings: Function;
|
|
|
|
|
|
let profileImageUrl = '';
|
|
let profileImageUrl = '';
|
|
let name = '';
|
|
let name = '';
|
|
|
|
|
|
|
|
+ let webhookUrl = '';
|
|
let showAPIKeys = false;
|
|
let showAPIKeys = false;
|
|
|
|
|
|
let JWTTokenCopied = false;
|
|
let JWTTokenCopied = false;
|
|
@@ -35,6 +37,15 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (webhookUrl !== $settings?.notifications?.webhook_url) {
|
|
|
|
+ saveSettings({
|
|
|
|
+ notifications: {
|
|
|
|
+ ...$settings.notifications,
|
|
|
|
+ webhook_url: webhookUrl
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
const updatedUser = await updateUserProfile(localStorage.token, name, profileImageUrl).catch(
|
|
const updatedUser = await updateUserProfile(localStorage.token, name, profileImageUrl).catch(
|
|
(error) => {
|
|
(error) => {
|
|
toast.error(error);
|
|
toast.error(error);
|
|
@@ -60,6 +71,7 @@
|
|
onMount(async () => {
|
|
onMount(async () => {
|
|
name = $user.name;
|
|
name = $user.name;
|
|
profileImageUrl = $user.profile_image_url;
|
|
profileImageUrl = $user.profile_image_url;
|
|
|
|
+ webhookUrl = $settings?.notifications?.webhook_url ?? '';
|
|
|
|
|
|
APIKey = await getAPIKey(localStorage.token).catch((error) => {
|
|
APIKey = await getAPIKey(localStorage.token).catch((error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -226,6 +238,22 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <div class="pt-2">
|
|
|
|
+ <div class="flex flex-col w-full">
|
|
|
|
+ <div class=" mb-1 text-xs font-medium">{$i18n.t('Notification Webhook')}</div>
|
|
|
|
+
|
|
|
|
+ <div class="flex-1">
|
|
|
|
+ <input
|
|
|
|
+ class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
|
|
|
|
+ type="url"
|
|
|
|
+ placeholder={$i18n.t('Enter your webhook URL')}
|
|
|
|
+ bind:value={webhookUrl}
|
|
|
|
+ required
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="py-0.5">
|
|
<div class="py-0.5">
|