2022-07-15 23:18:17 -05:00
|
|
|
<script lang="ts">
|
2022-07-22 09:44:22 -05:00
|
|
|
import { afterNavigate, goto } from '$app/navigation';
|
2022-07-18 00:22:39 -05:00
|
|
|
import { page } from '$app/stores';
|
2022-07-22 09:44:22 -05:00
|
|
|
import { AlbumResponseDto, api, AssetResponseDto, ThumbnailFormat, UserResponseDto } from '@api';
|
2022-07-23 23:23:14 -05:00
|
|
|
import { onMount } from 'svelte';
|
2022-07-15 23:18:17 -05:00
|
|
|
import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte';
|
2022-07-22 09:44:22 -05:00
|
|
|
import Plus from 'svelte-material-icons/Plus.svelte';
|
2022-07-15 23:18:17 -05:00
|
|
|
import FileImagePlusOutline from 'svelte-material-icons/FileImagePlusOutline.svelte';
|
2022-07-23 13:08:49 -05:00
|
|
|
import ShareVariantOutline from 'svelte-material-icons/ShareVariantOutline.svelte';
|
2022-07-18 00:22:39 -05:00
|
|
|
import AssetViewer from '../asset-viewer/asset-viewer.svelte';
|
2022-07-16 23:52:00 -05:00
|
|
|
import CircleAvatar from '../shared-components/circle-avatar.svelte';
|
|
|
|
|
import ImmichThumbnail from '../shared-components/immich-thumbnail.svelte';
|
2022-07-22 09:44:22 -05:00
|
|
|
import AssetSelection from './asset-selection.svelte';
|
|
|
|
|
import UserSelectionModal from './user-selection-modal.svelte';
|
2022-07-23 13:08:49 -05:00
|
|
|
import ShareInfoModal from './share-info-modal.svelte';
|
|
|
|
|
import CircleIconButton from '../shared-components/circle-icon-button.svelte';
|
2022-07-23 23:23:14 -05:00
|
|
|
import Close from 'svelte-material-icons/Close.svelte';
|
|
|
|
|
import DeleteOutline from 'svelte-material-icons/DeleteOutline.svelte';
|
2022-07-27 11:16:02 -05:00
|
|
|
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
|
|
|
|
|
import ContextMenu from '../shared-components/context-menu/context-menu.svelte';
|
|
|
|
|
import MenuOption from '../shared-components/context-menu/menu-option.svelte';
|
|
|
|
|
import ThumbnailSelection from './thumbnail-selection.svelte';
|
2022-08-08 22:06:11 -05:00
|
|
|
import ControlAppBar from '../shared-components/control-app-bar.svelte';
|
2022-08-26 10:36:41 -07:00
|
|
|
import {
|
|
|
|
|
notificationController,
|
|
|
|
|
NotificationType
|
|
|
|
|
} from '../shared-components/notification/notification';
|
2022-09-04 08:34:39 -05:00
|
|
|
import { browser } from '$app/env';
|
2022-09-09 15:55:20 -05:00
|
|
|
import { albumAssetSelectionStore } from '$lib/stores/album-asset-selection.store';
|
2022-07-27 11:16:02 -05:00
|
|
|
|
2022-07-15 23:18:17 -05:00
|
|
|
export let album: AlbumResponseDto;
|
2022-09-09 15:55:20 -05:00
|
|
|
const { isAlbumAssetSelectionOpen } = albumAssetSelectionStore;
|
2022-07-18 00:22:39 -05:00
|
|
|
|
|
|
|
|
let isShowAssetViewer = false;
|
2022-09-04 08:34:39 -05:00
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
let isShowAssetSelection = false;
|
2022-09-09 15:55:20 -05:00
|
|
|
|
|
|
|
|
$: $isAlbumAssetSelectionOpen = isShowAssetSelection;
|
2022-09-04 08:34:39 -05:00
|
|
|
$: {
|
|
|
|
|
if (browser) {
|
|
|
|
|
if (isShowAssetSelection) {
|
|
|
|
|
document.body.style.overflow = 'hidden';
|
|
|
|
|
} else {
|
|
|
|
|
document.body.style.overflow = 'auto';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-22 09:44:22 -05:00
|
|
|
let isShowShareUserSelection = false;
|
|
|
|
|
let isEditingTitle = false;
|
|
|
|
|
let isCreatingSharedAlbum = false;
|
2022-07-23 13:08:49 -05:00
|
|
|
let isShowShareInfoModal = false;
|
2022-07-27 11:16:02 -05:00
|
|
|
let isShowAlbumOptions = false;
|
|
|
|
|
let isShowThumbnailSelection = false;
|
2022-07-22 09:44:22 -05:00
|
|
|
|
2022-07-18 00:22:39 -05:00
|
|
|
let selectedAsset: AssetResponseDto;
|
|
|
|
|
let currentViewAssetIndex = 0;
|
|
|
|
|
|
2022-07-15 23:18:17 -05:00
|
|
|
let viewWidth: number;
|
2022-09-08 17:30:49 +02:00
|
|
|
let thumbnailSize = 300;
|
2022-07-16 23:52:00 -05:00
|
|
|
let backUrl = '/albums';
|
2022-07-22 09:44:22 -05:00
|
|
|
let currentAlbumName = '';
|
|
|
|
|
let currentUser: UserResponseDto;
|
2022-07-26 12:28:07 -05:00
|
|
|
let titleInput: HTMLInputElement;
|
2022-07-27 11:16:02 -05:00
|
|
|
let contextMenuPosition = { x: 0, y: 0 };
|
2022-07-22 09:44:22 -05:00
|
|
|
|
|
|
|
|
$: isOwned = currentUser?.id == album.ownerId;
|
2022-07-15 23:18:17 -05:00
|
|
|
|
2022-07-23 23:23:14 -05:00
|
|
|
let multiSelectAsset: Set<AssetResponseDto> = new Set();
|
|
|
|
|
$: isMultiSelectionMode = multiSelectAsset.size > 0;
|
|
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
afterNavigate(({ from }) => {
|
2022-07-16 23:52:00 -05:00
|
|
|
backUrl = from?.pathname ?? '/albums';
|
2022-07-22 09:44:22 -05:00
|
|
|
|
|
|
|
|
if (from?.pathname === '/sharing') {
|
|
|
|
|
isCreatingSharedAlbum = true;
|
|
|
|
|
}
|
2022-07-16 23:52:00 -05:00
|
|
|
});
|
2022-07-22 09:44:22 -05:00
|
|
|
|
2022-07-15 23:18:17 -05:00
|
|
|
$: {
|
2022-08-06 18:14:54 -05:00
|
|
|
if (album.assets?.length < 6) {
|
2022-08-10 22:48:25 -05:00
|
|
|
thumbnailSize = Math.floor(viewWidth / album.assetCount - album.assetCount);
|
2022-07-15 23:18:17 -05:00
|
|
|
} else {
|
|
|
|
|
thumbnailSize = Math.floor(viewWidth / 6 - 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getDateRange = () => {
|
|
|
|
|
const startDate = new Date(album.assets[0].createdAt);
|
2022-08-10 22:48:25 -05:00
|
|
|
const endDate = new Date(album.assets[album.assetCount - 1].createdAt);
|
2022-07-15 23:18:17 -05:00
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
const timeFormatOption: Intl.DateTimeFormatOptions = {
|
2022-07-15 23:18:17 -05:00
|
|
|
month: 'short',
|
|
|
|
|
day: 'numeric',
|
|
|
|
|
year: 'numeric'
|
2022-07-22 09:44:22 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const startDateString = startDate.toLocaleDateString('us-EN', timeFormatOption);
|
|
|
|
|
const endDateString = endDate.toLocaleDateString('us-EN', timeFormatOption);
|
2022-07-15 23:18:17 -05:00
|
|
|
return `${startDateString} - ${endDateString}`;
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
onMount(async () => {
|
|
|
|
|
currentAlbumName = album.albumName;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await api.userApi.getMyUserInfo();
|
|
|
|
|
currentUser = data;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log('Error [getMyUserInfo - album-viewer] ', e);
|
|
|
|
|
}
|
2022-07-15 23:18:17 -05:00
|
|
|
});
|
2022-07-18 00:22:39 -05:00
|
|
|
|
2022-07-23 23:23:14 -05:00
|
|
|
const viewAssetHandler = (event: CustomEvent) => {
|
|
|
|
|
const { asset }: { asset: AssetResponseDto } = event.detail;
|
2022-07-18 00:22:39 -05:00
|
|
|
|
2022-07-23 23:23:14 -05:00
|
|
|
currentViewAssetIndex = album.assets.findIndex((a) => a.id == asset.id);
|
2022-07-18 00:22:39 -05:00
|
|
|
selectedAsset = album.assets[currentViewAssetIndex];
|
|
|
|
|
isShowAssetViewer = true;
|
|
|
|
|
pushState(selectedAsset.id);
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-23 23:23:14 -05:00
|
|
|
const selectAssetHandler = (event: CustomEvent) => {
|
|
|
|
|
const { asset }: { asset: AssetResponseDto } = event.detail;
|
|
|
|
|
let temp = new Set(multiSelectAsset);
|
|
|
|
|
|
|
|
|
|
if (multiSelectAsset.has(asset)) {
|
|
|
|
|
temp.delete(asset);
|
|
|
|
|
} else {
|
|
|
|
|
temp.add(asset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
multiSelectAsset = temp;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const clearMultiSelectAssetAssetHandler = () => {
|
|
|
|
|
multiSelectAsset = new Set();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const removeSelectedAssetFromAlbum = async () => {
|
|
|
|
|
if (window.confirm('Do you want to remove selected assets from the album?')) {
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await api.albumApi.removeAssetFromAlbum(album.id, {
|
|
|
|
|
assetIds: Array.from(multiSelectAsset).map((a) => a.id)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
album = data;
|
|
|
|
|
multiSelectAsset = new Set();
|
|
|
|
|
} catch (e) {
|
2022-08-26 10:36:41 -07:00
|
|
|
console.error('Error [album-viewer] [removeAssetFromAlbum]', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: 'Error removing assets from album, check console for more details'
|
|
|
|
|
});
|
2022-07-23 23:23:14 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-07-18 00:22:39 -05:00
|
|
|
const navigateAssetForward = () => {
|
|
|
|
|
try {
|
2022-08-10 22:48:25 -05:00
|
|
|
if (currentViewAssetIndex < album.assetCount - 1) {
|
2022-07-18 00:22:39 -05:00
|
|
|
currentViewAssetIndex++;
|
|
|
|
|
selectedAsset = album.assets[currentViewAssetIndex];
|
|
|
|
|
pushState(selectedAsset.id);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const navigateAssetBackward = () => {
|
|
|
|
|
try {
|
|
|
|
|
if (currentViewAssetIndex > 0) {
|
|
|
|
|
currentViewAssetIndex--;
|
|
|
|
|
selectedAsset = album.assets[currentViewAssetIndex];
|
|
|
|
|
pushState(selectedAsset.id);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const pushState = (assetId: string) => {
|
|
|
|
|
// add a URL to the browser's history
|
|
|
|
|
// changes the current URL in the address bar but doesn't perform any SvelteKit navigation
|
|
|
|
|
history.pushState(null, '', `${$page.url.pathname}/photos/${assetId}`);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const closeViewer = () => {
|
|
|
|
|
isShowAssetViewer = false;
|
|
|
|
|
history.pushState(null, '', `${$page.url.pathname}`);
|
|
|
|
|
};
|
2022-07-22 09:44:22 -05:00
|
|
|
|
|
|
|
|
// Update Album Name
|
|
|
|
|
$: {
|
|
|
|
|
if (!isEditingTitle && currentAlbumName != album.albumName && isOwned) {
|
|
|
|
|
api.albumApi
|
|
|
|
|
.updateAlbumInfo(album.id, {
|
|
|
|
|
albumName: album.albumName
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
currentAlbumName = album.albumName;
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
2022-08-26 10:36:41 -07:00
|
|
|
console.error('Error [updateAlbumInfo] ', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: "Error updating album's name, check console for more details"
|
|
|
|
|
});
|
2022-07-22 09:44:22 -05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const createAlbumHandler = async (event: CustomEvent) => {
|
2022-09-04 08:34:39 -05:00
|
|
|
const { assets }: { assets: AssetResponseDto[] } = event.detail;
|
2022-07-22 09:44:22 -05:00
|
|
|
try {
|
2022-09-04 08:34:39 -05:00
|
|
|
const { data } = await api.albumApi.addAssetsToAlbum(album.id, {
|
|
|
|
|
assetIds: assets.map((a) => a.id)
|
|
|
|
|
});
|
2022-07-22 09:44:22 -05:00
|
|
|
album = data;
|
|
|
|
|
|
|
|
|
|
isShowAssetSelection = false;
|
|
|
|
|
} catch (e) {
|
2022-08-26 10:36:41 -07:00
|
|
|
console.error('Error [createAlbumHandler] ', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: 'Error creating album, check console for more details'
|
|
|
|
|
});
|
2022-07-22 09:44:22 -05:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-09-05 00:18:53 -05:00
|
|
|
const assetUploadedToAlbumHandler = async (event: CustomEvent) => {
|
|
|
|
|
const { assetIds }: { assetIds: string[] } = event.detail;
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await api.albumApi.addAssetsToAlbum(album.id, {
|
|
|
|
|
assetIds: assetIds
|
|
|
|
|
});
|
|
|
|
|
album = data;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Error [assetUploadedToAlbumHandler] ', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: 'Error adding asset to album, check console for more details'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
const addUserHandler = async (event: CustomEvent) => {
|
|
|
|
|
const { selectedUsers }: { selectedUsers: UserResponseDto[] } = event.detail;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await api.albumApi.addUsersToAlbum(album.id, {
|
|
|
|
|
sharedUserIds: Array.from(selectedUsers).map((u) => u.id)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
album = data;
|
|
|
|
|
|
|
|
|
|
isShowShareUserSelection = false;
|
|
|
|
|
} catch (e) {
|
2022-08-26 10:36:41 -07:00
|
|
|
console.error('Error [addUserHandler] ', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: 'Error adding users to album, check console for more details'
|
|
|
|
|
});
|
2022-07-22 09:44:22 -05:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-23 13:08:49 -05:00
|
|
|
const sharedUserDeletedHandler = async (event: CustomEvent) => {
|
|
|
|
|
const { userId }: { userId: string } = event.detail;
|
|
|
|
|
|
|
|
|
|
if (userId == 'me') {
|
|
|
|
|
isShowShareInfoModal = false;
|
|
|
|
|
goto(backUrl);
|
2022-07-22 09:44:22 -05:00
|
|
|
}
|
2022-07-23 13:08:49 -05:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await api.albumApi.getAlbumInfo(album.id);
|
|
|
|
|
|
|
|
|
|
album = data;
|
|
|
|
|
isShowShareInfoModal = false;
|
|
|
|
|
} catch (e) {
|
2022-08-26 10:36:41 -07:00
|
|
|
console.error('Error [sharedUserDeletedHandler] ', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: 'Error deleting share users, check console for more details'
|
|
|
|
|
});
|
2022-07-23 13:08:49 -05:00
|
|
|
}
|
|
|
|
|
};
|
2022-07-24 22:47:12 -05:00
|
|
|
|
|
|
|
|
const removeAlbum = async () => {
|
|
|
|
|
if (
|
|
|
|
|
window.confirm(
|
|
|
|
|
`Are you sure you want to delete album ${album.albumName}? If the album is shared, other users will not be able to access it.`
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
await api.albumApi.deleteAlbum(album.id);
|
|
|
|
|
goto(backUrl);
|
|
|
|
|
} catch (e) {
|
2022-08-26 10:36:41 -07:00
|
|
|
console.error('Error [userDeleteMenu] ', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: 'Error deleting album, check console for more details'
|
|
|
|
|
});
|
2022-07-24 22:47:12 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-07-27 11:16:02 -05:00
|
|
|
|
|
|
|
|
const showAlbumOptionsMenu = (event: CustomEvent) => {
|
|
|
|
|
contextMenuPosition = {
|
|
|
|
|
x: event.detail.mouseEvent.x,
|
|
|
|
|
y: event.detail.mouseEvent.y
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
isShowAlbumOptions = !isShowAlbumOptions;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const setAlbumThumbnailHandler = (event: CustomEvent) => {
|
|
|
|
|
const { asset }: { asset: AssetResponseDto } = event.detail;
|
|
|
|
|
try {
|
|
|
|
|
api.albumApi.updateAlbumInfo(album.id, {
|
|
|
|
|
albumThumbnailAssetId: asset.id
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
2022-08-26 10:36:41 -07:00
|
|
|
console.error('Error [setAlbumThumbnailHandler] ', e);
|
|
|
|
|
notificationController.show({
|
|
|
|
|
type: NotificationType.Error,
|
|
|
|
|
message: 'Error setting album thumbnail, check console for more details'
|
|
|
|
|
});
|
2022-07-27 11:16:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isShowThumbnailSelection = false;
|
|
|
|
|
};
|
2022-07-15 23:18:17 -05:00
|
|
|
</script>
|
|
|
|
|
|
2022-07-23 13:08:49 -05:00
|
|
|
<section class="bg-immich-bg">
|
2022-07-23 23:23:14 -05:00
|
|
|
<!-- Multiselection mode app bar -->
|
|
|
|
|
{#if isMultiSelectionMode}
|
2022-08-08 22:06:11 -05:00
|
|
|
<ControlAppBar
|
2022-07-23 23:23:14 -05:00
|
|
|
on:close-button-click={clearMultiSelectAssetAssetHandler}
|
|
|
|
|
backIcon={Close}
|
|
|
|
|
tailwindClasses={'bg-white shadow-md'}
|
|
|
|
|
>
|
|
|
|
|
<svelte:fragment slot="leading">
|
|
|
|
|
<p class="font-medium text-immich-primary">Selected {multiSelectAsset.size}</p>
|
|
|
|
|
</svelte:fragment>
|
|
|
|
|
<svelte:fragment slot="trailing">
|
|
|
|
|
{#if isOwned}
|
|
|
|
|
<CircleIconButton
|
|
|
|
|
title="Remove from album"
|
|
|
|
|
on:click={removeSelectedAssetFromAlbum}
|
|
|
|
|
logo={DeleteOutline}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
</svelte:fragment>
|
2022-08-08 22:06:11 -05:00
|
|
|
</ControlAppBar>
|
2022-07-23 23:23:14 -05:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<!-- Default app bar -->
|
|
|
|
|
{#if !isMultiSelectionMode}
|
2022-08-08 22:06:11 -05:00
|
|
|
<ControlAppBar on:close-button-click={() => goto(backUrl)} backIcon={ArrowLeft}>
|
2022-07-23 23:23:14 -05:00
|
|
|
<svelte:fragment slot="trailing">
|
2022-08-10 22:48:25 -05:00
|
|
|
{#if album.assetCount > 0}
|
2022-07-23 23:23:14 -05:00
|
|
|
<CircleIconButton
|
|
|
|
|
title="Add Photos"
|
|
|
|
|
on:click={() => (isShowAssetSelection = true)}
|
|
|
|
|
logo={FileImagePlusOutline}
|
|
|
|
|
/>
|
|
|
|
|
|
2022-07-27 11:16:02 -05:00
|
|
|
<!-- Share and remove album -->
|
2022-07-23 23:23:14 -05:00
|
|
|
{#if isOwned}
|
|
|
|
|
<CircleIconButton
|
|
|
|
|
title="Share"
|
|
|
|
|
on:click={() => (isShowShareUserSelection = true)}
|
|
|
|
|
logo={ShareVariantOutline}
|
|
|
|
|
/>
|
2022-07-24 22:47:12 -05:00
|
|
|
<CircleIconButton title="Remove album" on:click={removeAlbum} logo={DeleteOutline} />
|
2022-07-23 23:23:14 -05:00
|
|
|
{/if}
|
2022-07-27 11:16:02 -05:00
|
|
|
|
|
|
|
|
<CircleIconButton
|
|
|
|
|
title="Album options"
|
|
|
|
|
on:click={(event) => showAlbumOptionsMenu(event)}
|
|
|
|
|
logo={DotsVertical}
|
|
|
|
|
/>
|
2022-07-23 23:23:14 -05:00
|
|
|
{/if}
|
2022-07-22 09:44:22 -05:00
|
|
|
|
2022-07-23 23:23:14 -05:00
|
|
|
{#if isCreatingSharedAlbum && album.sharedUsers.length == 0}
|
|
|
|
|
<button
|
2022-08-10 22:48:25 -05:00
|
|
|
disabled={album.assetCount == 0}
|
2022-07-23 23:23:14 -05:00
|
|
|
on:click={() => (isShowShareUserSelection = true)}
|
|
|
|
|
class="immich-text-button border bg-immich-primary text-gray-50 hover:bg-immich-primary/75 px-6 text-sm disabled:opacity-25 disabled:bg-gray-500 disabled:cursor-not-allowed"
|
|
|
|
|
><span class="px-2">Share</span></button
|
|
|
|
|
>
|
|
|
|
|
{/if}
|
|
|
|
|
</svelte:fragment>
|
2022-08-08 22:06:11 -05:00
|
|
|
</ControlAppBar>
|
2022-07-23 23:23:14 -05:00
|
|
|
{/if}
|
2022-07-15 23:18:17 -05:00
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
<section class="m-auto my-[160px] w-[60%]">
|
|
|
|
|
<input
|
2022-07-26 12:28:07 -05:00
|
|
|
on:keydown={(e) => {
|
|
|
|
|
if (e.key == 'Enter') {
|
|
|
|
|
isEditingTitle = false;
|
|
|
|
|
titleInput.blur();
|
|
|
|
|
}
|
|
|
|
|
}}
|
2022-07-22 09:44:22 -05:00
|
|
|
on:focus={() => (isEditingTitle = true)}
|
|
|
|
|
on:blur={() => (isEditingTitle = false)}
|
|
|
|
|
class={`transition-all text-6xl text-immich-primary w-[99%] border-b-2 border-transparent outline-none ${
|
|
|
|
|
isOwned ? 'hover:border-gray-400' : 'hover:border-transparent'
|
|
|
|
|
} focus:outline-none focus:border-b-2 focus:border-immich-primary bg-immich-bg`}
|
|
|
|
|
type="text"
|
|
|
|
|
bind:value={album.albumName}
|
|
|
|
|
disabled={!isOwned}
|
2022-07-26 12:28:07 -05:00
|
|
|
bind:this={titleInput}
|
2022-07-22 09:44:22 -05:00
|
|
|
/>
|
2022-07-15 23:18:17 -05:00
|
|
|
|
2022-08-10 22:48:25 -05:00
|
|
|
{#if album.assetCount > 0}
|
2022-07-23 13:08:49 -05:00
|
|
|
<p class="my-4 text-sm text-gray-500 font-medium">{getDateRange()}</p>
|
2022-07-22 09:44:22 -05:00
|
|
|
{/if}
|
2022-07-15 23:18:17 -05:00
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
{#if album.shared}
|
2022-07-23 13:08:49 -05:00
|
|
|
<div class="my-6 flex">
|
2022-07-15 23:18:17 -05:00
|
|
|
{#each album.sharedUsers as user}
|
2022-07-23 23:23:14 -05:00
|
|
|
{#key user.id}
|
|
|
|
|
<span class="mr-1">
|
|
|
|
|
<CircleAvatar {user} on:click={() => (isShowShareInfoModal = true)} />
|
|
|
|
|
</span>
|
|
|
|
|
{/key}
|
2022-07-15 23:18:17 -05:00
|
|
|
{/each}
|
2022-07-22 09:44:22 -05:00
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
style:display={isOwned ? 'block' : 'none'}
|
|
|
|
|
on:click={() => (isShowShareUserSelection = true)}
|
|
|
|
|
title="Add more users"
|
|
|
|
|
class="h-12 w-12 border bg-white transition-colors hover:bg-gray-300 text-3xl flex place-items-center place-content-center rounded-full"
|
|
|
|
|
>+</button
|
|
|
|
|
>
|
2022-07-15 23:18:17 -05:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2022-08-10 22:48:25 -05:00
|
|
|
{#if album.assetCount > 0}
|
2022-07-23 13:08:49 -05:00
|
|
|
<div class="flex flex-wrap gap-1 w-full pb-20" bind:clientWidth={viewWidth}>
|
2022-07-22 09:44:22 -05:00
|
|
|
{#each album.assets as asset}
|
2022-07-23 23:23:14 -05:00
|
|
|
{#key asset.id}
|
2022-08-10 22:48:25 -05:00
|
|
|
{#if album.assetCount < 7}
|
2022-07-23 23:23:14 -05:00
|
|
|
<ImmichThumbnail
|
|
|
|
|
{asset}
|
|
|
|
|
{thumbnailSize}
|
|
|
|
|
format={ThumbnailFormat.Jpeg}
|
|
|
|
|
on:click={(e) =>
|
|
|
|
|
isMultiSelectionMode ? selectAssetHandler(e) : viewAssetHandler(e)}
|
|
|
|
|
on:select={selectAssetHandler}
|
|
|
|
|
selected={multiSelectAsset.has(asset)}
|
|
|
|
|
/>
|
|
|
|
|
{:else}
|
|
|
|
|
<ImmichThumbnail
|
|
|
|
|
{asset}
|
|
|
|
|
{thumbnailSize}
|
|
|
|
|
on:click={(e) =>
|
|
|
|
|
isMultiSelectionMode ? selectAssetHandler(e) : viewAssetHandler(e)}
|
|
|
|
|
on:select={selectAssetHandler}
|
|
|
|
|
selected={multiSelectAsset.has(asset)}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
{/key}
|
2022-07-22 09:44:22 -05:00
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{:else}
|
|
|
|
|
<!-- Album is empty - Show asset selectection buttons -->
|
|
|
|
|
<section id="empty-album" class=" mt-[200px] flex place-content-center place-items-center">
|
|
|
|
|
<div class="w-[300px]">
|
|
|
|
|
<p class="text-xs">ADD PHOTOS</p>
|
|
|
|
|
<button
|
|
|
|
|
on:click={() => (isShowAssetSelection = true)}
|
|
|
|
|
class="w-full py-8 border bg-white rounded-md mt-5 flex place-items-center gap-6 px-8 transition-all hover:bg-gray-100 hover:text-immich-primary"
|
|
|
|
|
>
|
|
|
|
|
<span><Plus color="#4250af" size="24" /> </span>
|
|
|
|
|
<span class="text-lg text-immich-fg">Select photos</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
{/if}
|
2022-07-15 23:18:17 -05:00
|
|
|
</section>
|
|
|
|
|
</section>
|
2022-07-18 00:22:39 -05:00
|
|
|
|
|
|
|
|
<!-- Overlay Asset Viewer -->
|
|
|
|
|
{#if isShowAssetViewer}
|
|
|
|
|
<AssetViewer
|
|
|
|
|
asset={selectedAsset}
|
2022-09-04 08:34:39 -05:00
|
|
|
on:navigate-previous={navigateAssetBackward}
|
|
|
|
|
on:navigate-next={navigateAssetForward}
|
2022-07-18 00:22:39 -05:00
|
|
|
on:close={closeViewer}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
2022-07-22 09:44:22 -05:00
|
|
|
|
|
|
|
|
{#if isShowAssetSelection}
|
|
|
|
|
<AssetSelection
|
|
|
|
|
assetsInAlbum={album.assets}
|
|
|
|
|
on:go-back={() => (isShowAssetSelection = false)}
|
|
|
|
|
on:create-album={createAlbumHandler}
|
2022-09-05 00:18:53 -05:00
|
|
|
on:asset-uploaded={assetUploadedToAlbumHandler}
|
2022-07-22 09:44:22 -05:00
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if isShowShareUserSelection}
|
|
|
|
|
<UserSelectionModal
|
|
|
|
|
on:close={() => (isShowShareUserSelection = false)}
|
|
|
|
|
on:add-user={addUserHandler}
|
|
|
|
|
sharedUsersInAlbum={new Set(album.sharedUsers)}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
2022-07-23 13:08:49 -05:00
|
|
|
|
|
|
|
|
{#if isShowShareInfoModal}
|
|
|
|
|
<ShareInfoModal
|
|
|
|
|
on:close={() => (isShowShareInfoModal = false)}
|
|
|
|
|
{album}
|
|
|
|
|
on:user-deleted={sharedUserDeletedHandler}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
2022-07-27 11:16:02 -05:00
|
|
|
|
|
|
|
|
{#if isShowAlbumOptions}
|
|
|
|
|
<ContextMenu {...contextMenuPosition} on:clickoutside={() => (isShowAlbumOptions = false)}>
|
|
|
|
|
{#if isOwned}
|
|
|
|
|
<MenuOption
|
|
|
|
|
on:click={() => {
|
|
|
|
|
isShowThumbnailSelection = true;
|
|
|
|
|
isShowAlbumOptions = false;
|
|
|
|
|
}}
|
|
|
|
|
text="Set album cover"
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
</ContextMenu>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if isShowThumbnailSelection}
|
|
|
|
|
<ThumbnailSelection
|
|
|
|
|
{album}
|
|
|
|
|
on:close={() => (isShowThumbnailSelection = false)}
|
|
|
|
|
on:thumbnail-selected={setAlbumThumbnailHandler}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|