2022-12-26 10:35:52 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import {
|
|
|
|
|
notificationController,
|
|
|
|
|
NotificationType,
|
|
|
|
|
} from '$lib/components/shared-components/notification/notification';
|
|
|
|
|
import { fade } from 'svelte/transition';
|
|
|
|
|
import { handleError } from '../../utils/handle-error';
|
|
|
|
|
import Button from '../elements/buttons/button.svelte';
|
2024-02-13 02:47:26 +01:00
|
|
|
import { user } from '$lib/stores/user.store';
|
|
|
|
|
import { cloneDeep } from 'lodash-es';
|
2024-02-13 17:07:37 -05:00
|
|
|
import { updateUser } from '@immich/sdk';
|
2024-02-22 15:36:14 +01:00
|
|
|
import SettingInputField, {
|
|
|
|
|
SettingInputFieldType,
|
|
|
|
|
} from '$lib/components/shared-components/settings/setting-input-field.svelte';
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-02-13 02:47:26 +01:00
|
|
|
let editedUser = cloneDeep($user);
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleSaveProfile = async () => {
|
|
|
|
|
try {
|
2024-02-13 17:07:37 -05:00
|
|
|
const data = await updateUser({
|
2023-07-01 00:50:47 -04:00
|
|
|
updateUserDto: {
|
2024-02-13 02:47:26 +01:00
|
|
|
id: editedUser.id,
|
|
|
|
|
email: editedUser.email,
|
|
|
|
|
name: editedUser.name,
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
|
|
|
|
});
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-02-13 02:47:26 +01:00
|
|
|
Object.assign(editedUser, data);
|
|
|
|
|
$user = data;
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
notificationController.show({
|
|
|
|
|
message: 'Saved profile',
|
|
|
|
|
type: NotificationType.Info,
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleError(error, 'Unable to save profile');
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-12-26 10:35:52 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<section class="my-4">
|
2023-07-01 00:50:47 -04:00
|
|
|
<div in:fade={{ duration: 500 }}>
|
|
|
|
|
<form autocomplete="off" on:submit|preventDefault>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="ml-4 mt-4 flex flex-col gap-4">
|
2023-07-01 00:50:47 -04:00
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.TEXT}
|
|
|
|
|
label="USER ID"
|
2024-02-13 02:47:26 +01:00
|
|
|
bind:value={editedUser.id}
|
2023-07-01 00:50:47 -04:00
|
|
|
disabled={true}
|
|
|
|
|
/>
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-02-13 02:47:26 +01:00
|
|
|
<SettingInputField inputType={SettingInputFieldType.EMAIL} label="EMAIL" bind:value={editedUser.email} />
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-02-13 02:47:26 +01:00
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.TEXT}
|
|
|
|
|
label="NAME"
|
|
|
|
|
bind:value={editedUser.name}
|
|
|
|
|
required={true}
|
|
|
|
|
/>
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.TEXT}
|
|
|
|
|
label="STORAGE LABEL"
|
|
|
|
|
disabled={true}
|
2024-02-13 02:47:26 +01:00
|
|
|
value={editedUser.storageLabel || ''}
|
2023-07-01 00:50:47 -04:00
|
|
|
required={false}
|
|
|
|
|
/>
|
2023-05-21 23:18:10 -04:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
<div class="flex justify-end">
|
|
|
|
|
<Button type="submit" size="sm" on:click={() => handleSaveProfile()}>Save</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2022-12-26 10:35:52 -05:00
|
|
|
</section>
|