2024-02-29 19:35:37 +01:00
|
|
|
import { authenticate, requestServerInfo } from '$lib/utils/auth';
|
2024-06-29 18:29:56 +02:00
|
|
|
import { getFormatter } from '$lib/utils/i18n';
|
2025-11-18 21:27:41 +01:00
|
|
|
import { getAllLibraries, getLibraryStatistics, getUserAdmin, searchUsersAdmin } from '@immich/sdk';
|
2024-02-29 19:35:37 +01:00
|
|
|
import type { PageLoad } from './$types';
|
|
|
|
|
|
2025-05-15 14:45:23 -04:00
|
|
|
export const load = (async ({ url }) => {
|
|
|
|
|
await authenticate(url, { admin: true });
|
2024-02-29 19:35:37 +01:00
|
|
|
await requestServerInfo();
|
2024-05-26 18:15:52 -04:00
|
|
|
const allUsers = await searchUsersAdmin({ withDeleted: false });
|
2024-06-29 18:29:56 +02:00
|
|
|
const $t = await getFormatter();
|
2024-02-29 19:35:37 +01:00
|
|
|
|
2025-11-18 21:27:41 +01:00
|
|
|
const libraries = await getAllLibraries();
|
|
|
|
|
const statistics = await Promise.all(
|
|
|
|
|
libraries.map(async ({ id }) => [id, await getLibraryStatistics({ id })] as const),
|
|
|
|
|
);
|
|
|
|
|
const owners = await Promise.all(
|
|
|
|
|
libraries.map(async ({ id, ownerId }) => [id, await getUserAdmin({ id: ownerId })] as const),
|
|
|
|
|
);
|
|
|
|
|
|
2024-02-29 19:35:37 +01:00
|
|
|
return {
|
|
|
|
|
allUsers,
|
2025-11-18 21:27:41 +01:00
|
|
|
libraries,
|
|
|
|
|
statistics: Object.fromEntries(statistics),
|
|
|
|
|
owners: Object.fromEntries(owners),
|
2024-02-29 19:35:37 +01:00
|
|
|
meta: {
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $t('admin.external_library_management'),
|
2024-02-29 19:35:37 +01:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}) satisfies PageLoad;
|