2022-12-17 16:08:18 -06:00
|
|
|
<script lang="ts">
|
2022-12-26 10:35:52 -05:00
|
|
|
import { page } from '$app/stores';
|
|
|
|
|
import { oauth, UserResponseDto } from '@api';
|
|
|
|
|
import { onMount } from 'svelte';
|
2022-12-17 16:08:18 -06:00
|
|
|
import SettingAccordion from '../admin-page/settings/setting-accordion.svelte';
|
2022-12-26 10:35:52 -05:00
|
|
|
import ChangePasswordSettings from './change-password-settings.svelte';
|
|
|
|
|
import OAuthSettings from './oauth-settings.svelte';
|
2023-01-02 15:22:33 -05:00
|
|
|
import UserAPIKeyList from './user-api-key-list.svelte';
|
2022-12-26 10:35:52 -05:00
|
|
|
import UserProfileSettings from './user-profile-settings.svelte';
|
2022-12-21 10:35:59 -05:00
|
|
|
|
2022-12-17 16:08:18 -06:00
|
|
|
export let user: UserResponseDto;
|
2022-12-21 09:43:35 -05:00
|
|
|
|
2022-12-26 10:35:52 -05:00
|
|
|
let oauthEnabled = false;
|
|
|
|
|
let oauthOpen = false;
|
2022-12-21 09:43:35 -05:00
|
|
|
|
2022-12-26 10:35:52 -05:00
|
|
|
onMount(async () => {
|
|
|
|
|
oauthOpen = oauth.isCallback(window.location);
|
2022-12-21 09:43:35 -05:00
|
|
|
|
|
|
|
|
try {
|
2022-12-26 10:35:52 -05:00
|
|
|
const { data } = await oauth.getConfig(window.location);
|
|
|
|
|
oauthEnabled = data.enabled;
|
|
|
|
|
} catch {
|
|
|
|
|
// noop
|
2022-12-21 09:43:35 -05:00
|
|
|
}
|
2022-12-26 10:35:52 -05:00
|
|
|
});
|
2022-12-17 16:08:18 -06:00
|
|
|
</script>
|
|
|
|
|
|
2022-12-21 09:43:35 -05:00
|
|
|
<SettingAccordion title="User Profile" subtitle="View and manage your profile">
|
2022-12-26 10:35:52 -05:00
|
|
|
<UserProfileSettings {user} />
|
2022-12-21 09:43:35 -05:00
|
|
|
</SettingAccordion>
|
|
|
|
|
|
|
|
|
|
<SettingAccordion title="Password" subtitle="Change your password">
|
2022-12-26 10:35:52 -05:00
|
|
|
<ChangePasswordSettings />
|
2022-12-17 16:08:18 -06:00
|
|
|
</SettingAccordion>
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2023-01-02 15:22:33 -05:00
|
|
|
<SettingAccordion title="API Keys" subtitle="View and manage your API keys">
|
|
|
|
|
<UserAPIKeyList />
|
|
|
|
|
</SettingAccordion>
|
|
|
|
|
|
2022-12-26 10:35:52 -05:00
|
|
|
{#if oauthEnabled}
|
|
|
|
|
<SettingAccordion
|
|
|
|
|
title="OAuth"
|
|
|
|
|
subtitle="Manage your linked account"
|
|
|
|
|
isOpen={oauthOpen || $page.url.searchParams.get('open') === 'oauth'}
|
|
|
|
|
>
|
|
|
|
|
<OAuthSettings {user} />
|
|
|
|
|
</SettingAccordion>
|
|
|
|
|
{/if}
|