refactor(web): user-settings (#3700)

* refactor(web): user-settings

* feat: move the logic to the server

* use const

* fix: error 403

* fix: remove console.log
This commit is contained in:
martin 2023-08-17 05:56:06 +02:00 committed by GitHub
parent 53f5643994
commit 78a2a9e666
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 26 deletions

View file

@ -1,7 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
import { oauth, UserResponseDto } from '@api';
import { onMount } from 'svelte';
import { APIKeyResponseDto, AuthDeviceResponseDto, oauth, UserResponseDto } from '@api';
import SettingAccordion from '../admin-page/settings/setting-accordion.svelte';
import ChangePasswordSettings from './change-password-settings.svelte';
import DeviceList from './device-list.svelte';
@ -10,15 +9,19 @@
import PartnerSettings from './partner-settings.svelte';
import UserAPIKeyList from './user-api-key-list.svelte';
import UserProfileSettings from './user-profile-settings.svelte';
import { onMount } from 'svelte';
export let user: UserResponseDto;
export let keys: APIKeyResponseDto[] = [];
export let devices: AuthDeviceResponseDto[] = [];
export let partners: UserResponseDto[] = [];
let oauthEnabled = false;
let oauthOpen = false;
onMount(async () => {
oauthOpen = oauth.isCallback(window.location);
try {
const { data } = await oauth.getConfig(window.location);
oauthEnabled = data.enabled;
@ -33,11 +36,11 @@
</SettingAccordion>
<SettingAccordion title="API Keys" subtitle="Manage your API keys">
<UserAPIKeyList />
<UserAPIKeyList bind:keys />
</SettingAccordion>
<SettingAccordion title="Authorized Devices" subtitle="Manage your logged-in devices">
<DeviceList />
<DeviceList bind:devices />
</SettingAccordion>
<SettingAccordion title="Memories" subtitle="Manage what you see in your memories.">
@ -59,5 +62,5 @@
</SettingAccordion>
<SettingAccordion title="Sharing" subtitle="Manage sharing with partners">
<PartnerSettings {user} />
<PartnerSettings {user} bind:partners />
</SettingAccordion>