|
@@ -4,16 +4,14 @@
|
|
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
|
import { fade, fly } from 'svelte/transition';
|
|
|
import TrayArrowUp from 'svelte-material-icons/TrayArrowUp.svelte';
|
|
|
- import { clickOutside } from '../../utils/click-outside';
|
|
|
import { api, UserResponseDto } from '@api';
|
|
|
- import ThemeButton from './theme-button.svelte';
|
|
|
- import { AppRoute } from '../../constants';
|
|
|
-
|
|
|
+ import ThemeButton from '../theme-button.svelte';
|
|
|
+ import { AppRoute } from '../../../constants';
|
|
|
+ import AccountInfoPanel from './account-info-panel.svelte';
|
|
|
export let user: UserResponseDto;
|
|
|
export let shouldShowUploadButton = true;
|
|
|
|
|
|
let shouldShowAccountInfo = false;
|
|
|
- let shouldShowProfileImage = false;
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
let shouldShowAccountInfoPanel = false;
|
|
@@ -23,12 +21,7 @@
|
|
|
});
|
|
|
|
|
|
const getUserProfileImage = async () => {
|
|
|
- try {
|
|
|
- await api.userApi.getProfileImage(user.id);
|
|
|
- shouldShowProfileImage = true;
|
|
|
- } catch (e) {
|
|
|
- shouldShowProfileImage = false;
|
|
|
- }
|
|
|
+ return await api.userApi.getProfileImage(user.id);
|
|
|
};
|
|
|
const getFirstLetter = (text?: string) => {
|
|
|
return text?.charAt(0).toUpperCase();
|
|
@@ -103,15 +96,16 @@
|
|
|
<button
|
|
|
class="flex place-items-center place-content-center rounded-full bg-immich-primary hover:bg-immich-primary/80 h-12 w-12 text-gray-100 dark:text-immich-dark-bg dark:bg-immich-dark-primary"
|
|
|
>
|
|
|
- {#if shouldShowProfileImage}
|
|
|
+ {#await getUserProfileImage() then}
|
|
|
<img
|
|
|
- src={`api/user/profile-image/${user.id}`}
|
|
|
+ transition:fade={{ duration: 100 }}
|
|
|
+ src={`${$page.url.origin}/api/user/profile-image/${user.id}`}
|
|
|
alt="profile-img"
|
|
|
class="inline rounded-full h-12 w-12 object-cover shadow-md"
|
|
|
/>
|
|
|
- {:else}
|
|
|
+ {:catch}
|
|
|
{getFirstLetter(user.firstName)}{getFirstLetter(user.lastName)}
|
|
|
- {/if}
|
|
|
+ {/await}
|
|
|
</button>
|
|
|
|
|
|
{#if shouldShowAccountInfo}
|
|
@@ -129,49 +123,10 @@
|
|
|
</div>
|
|
|
|
|
|
{#if shouldShowAccountInfoPanel}
|
|
|
- <div
|
|
|
- in:fade={{ duration: 100 }}
|
|
|
- out:fade={{ duration: 100 }}
|
|
|
- id="account-info-panel"
|
|
|
- class="absolute right-[25px] top-[75px] bg-immich-bg dark:bg-immich-dark-gray dark:border dark:border-immich-dark-gray shadow-lg rounded-2xl w-[360px] text-center z-[100]"
|
|
|
- use:clickOutside
|
|
|
- on:out-click={() => (shouldShowAccountInfoPanel = false)}
|
|
|
- >
|
|
|
- <div class="flex place-items-center place-content-center mt-6">
|
|
|
- <button
|
|
|
- class="flex place-items-center place-content-center rounded-full bg-immich-primary dark:bg-immich-dark-primary dark:immich-dark-primary/80 h-20 w-20 text-gray-100 hover:bg-immich-primary dark:text-immich-dark-bg"
|
|
|
- >
|
|
|
- {#if shouldShowProfileImage}
|
|
|
- <img
|
|
|
- src={`api/user/profile-image/${user.id}`}
|
|
|
- alt="profile-img"
|
|
|
- class="inline rounded-full h-20 w-20 object-cover shadow-md"
|
|
|
- />
|
|
|
- {:else}
|
|
|
- <div class="text-lg">
|
|
|
- {getFirstLetter(user.firstName)}{getFirstLetter(user.lastName)}
|
|
|
- </div>
|
|
|
- {/if}
|
|
|
- </button>
|
|
|
- </div>
|
|
|
-
|
|
|
- <p class="text-lg text-immich-primary dark:text-immich-dark-primary font-medium mt-4">
|
|
|
- {user.firstName}
|
|
|
- {user.lastName}
|
|
|
- </p>
|
|
|
-
|
|
|
- <p class="text-sm text-gray-500 dark:text-immich-dark-fg">{user.email}</p>
|
|
|
-
|
|
|
- <div class="my-4">
|
|
|
- <hr class="dark:border-immich-dark-bg" />
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="mb-6">
|
|
|
- <button
|
|
|
- class="border rounded-3xl px-6 py-2 hover:bg-gray-50 dark:border-immich-dark-gray dark:bg-gray-300 dark:hover:bg-immich-dark-primary"
|
|
|
- on:click={logOut}>Sign Out</button
|
|
|
- >
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <AccountInfoPanel
|
|
|
+ {user}
|
|
|
+ on:close={() => (shouldShowAccountInfoPanel = false)}
|
|
|
+ on:logout={logOut}
|
|
|
+ />
|
|
|
{/if}
|
|
|
</section>
|