refactor(server, web): create shared link (#2879)

* refactor: shared links

* chore: open api

* fix: tsc error
This commit is contained in:
Jason Rasmussen 2023-06-20 21:08:43 -04:00 committed by GitHub
parent 746ca5d5ed
commit 868f629f32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 2150 additions and 2642 deletions

View file

@ -17,6 +17,7 @@
notificationController,
NotificationType
} from '../shared-components/notification/notification';
import { handleError } from '../../utils/handle-error';
export let sharedLink: SharedLinkResponseDto;
export let isOwned: boolean;
@ -26,43 +27,40 @@
$: assets = sharedLink.assets;
$: isMultiSelectionMode = selectedAssets.size > 0;
const clearMultiSelectAssetAssetHandler = () => {
selectedAssets = new Set();
};
const downloadAssets = async () => {
await bulkDownload('immich-shared', assets, undefined, sharedLink?.key);
await bulkDownload('immich-shared', assets, undefined, sharedLink.key);
};
const handleUploadAssets = async () => {
try {
const results = await openFileUploadDialog(undefined, sharedLink?.key);
const results = await openFileUploadDialog(undefined, sharedLink.key);
const assetIds = results.filter((id) => !!id) as string[];
await api.assetApi.addAssetsToSharedLink({
addAssetsDto: {
assetIds
const { data } = await api.sharedLinkApi.addSharedLinkAssets({
id: sharedLink.id,
assetIdsDto: {
assetIds: results.filter((id) => !!id) as string[]
},
key: sharedLink?.key
key: sharedLink.key
});
const added = data.filter((item) => item.success).length;
notificationController.show({
message: `Successfully add ${assetIds.length} to the shared link`,
message: `Added ${added} assets`,
type: NotificationType.Info
});
} catch (e) {
console.error('handleUploadAssets', e);
handleError(e, 'Unable to add assets to shared link');
}
};
</script>
<section class="bg-immich-bg dark:bg-immich-dark-bg">
{#if isMultiSelectionMode}
<AssetSelectControlBar assets={selectedAssets} clearSelect={clearMultiSelectAssetAssetHandler}>
<AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}>
<DownloadAction filename="immich-shared" sharedLinkKey={sharedLink.key} />
{#if isOwned}
<RemoveFromSharedLink bind:sharedLink allAssets={assets} />
<RemoveFromSharedLink bind:sharedLink />
{/if}
</AssetSelectControlBar>
{:else}