mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
Show assets on web (#168)
* Implemented lazy loading thumbnail * Display assets as date-time grouping * Update Readme * Modify GitHub action to run from the latest update
This commit is contained in:
28
web/src/lib/stores/assets.ts
Normal file
28
web/src/lib/stores/assets.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { writable, derived } from 'svelte/store';
|
||||
import { getRequest } from '$lib/api';
|
||||
import type { ImmichAsset } from '$lib/models/immich-asset'
|
||||
import * as _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
const assets = writable<ImmichAsset[]>([]);
|
||||
|
||||
const assetsGroupByDate = derived(assets, ($assets) => {
|
||||
|
||||
return _.chain($assets)
|
||||
.groupBy((a) => moment(a.createdAt).format('ddd, MMM DD'))
|
||||
.sortBy((group) => $assets.indexOf(group[0]))
|
||||
.value();
|
||||
|
||||
})
|
||||
|
||||
const getAssetsInfo = async (accessToken: string) => {
|
||||
const res = await getRequest('asset', accessToken);
|
||||
|
||||
assets.set(res);
|
||||
}
|
||||
|
||||
export default {
|
||||
assets,
|
||||
assetsGroupByDate,
|
||||
getAssetsInfo,
|
||||
}
|
||||
Reference in New Issue
Block a user