Files
immich/web/src/lib/stores/assets.ts
Alex 1e3464fe47 Feature - Add upload functionality on Web (#231)
* Added file selector

* Extract metadata to upload files to the web

* Added request for uploading

* Generate jpeg/Webp thumbnail for asset uploaded without thumbnail data

* Added generating thumbnail for video and WebSocket broadcast after thumbnail is generated

* Added video length extraction

* Added Uploading Panel

* Added upload progress store and styling the uploaded asset

* Added condition to only show upload panel when there is upload in progress

* Remove asset from the upload list after successfully uploading

* Added WebSocket to listen to upload event on the web

* Added mechanism to check for existing assets before uploading on the web

* Added test workflow

* Update readme
2022-06-19 08:16:35 -05:00

30 lines
847 B
TypeScript

import { writable, derived } from 'svelte/store';
import { getRequest } from '$lib/api';
import type { ImmichAsset } from '$lib/models/immich-asset';
import lodash from 'lodash-es';
import moment from 'moment';
export const assets = writable<ImmichAsset[]>([]);
export const assetsGroupByDate = derived(assets, ($assets) => {
try {
return lodash
.chain($assets)
.groupBy((a) => moment(a.createdAt).format('ddd, MMM DD'))
.sortBy((group) => $assets.indexOf(group[0]))
.value();
} catch (e) {
console.log('error deriving state assets', e);
return [];
}
});
export const flattenAssetGroupByDate = derived(assetsGroupByDate, ($assetsGroupByDate) => {
return $assetsGroupByDate.flat();
});
export const getAssetsInfo = async (accessToken: string) => {
const res = await getRequest('asset', accessToken);
assets.set(res);
};