1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

chore(web): generate API functions with a single argument (#2568)

This commit is contained in:
Sergey Kondrikov 2023-05-28 04:52:22 +03:00 committed by GitHub
parent a460940430
commit 6c6c5ef651
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 1913 additions and 491 deletions

View file

@ -20,7 +20,7 @@ function web {
wget -O apiInner.mustache https://raw.githubusercontent.com/OpenAPITools/openapi-generator/v6.0.1/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache wget -O apiInner.mustache https://raw.githubusercontent.com/OpenAPITools/openapi-generator/v6.0.1/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache
patch -u apiInner.mustache < apiInner.mustache.patch patch -u apiInner.mustache < apiInner.mustache.patch
cd ../../.. cd ../../..
npx --yes @openapitools/openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ../web/src/api/open-api -t ./openapi-generator/templates/web npx --yes @openapitools/openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ../web/src/api/open-api -t ./openapi-generator/templates/web --additional-properties=useSingleRequestParameter=true
} }
if [[ $1 == 'mobile' ]]; then if [[ $1 == 'mobile' ]]; then

File diff suppressed because it is too large Load diff

View file

@ -21,13 +21,13 @@ export const oauth = {
getConfig: (location: Location) => { getConfig: (location: Location) => {
const redirectUri = location.href.split('?')[0]; const redirectUri = location.href.split('?')[0];
console.log(`OAuth Redirect URI: ${redirectUri}`); console.log(`OAuth Redirect URI: ${redirectUri}`);
return api.oauthApi.generateConfig({ redirectUri }); return api.oauthApi.generateConfig({ oAuthConfigDto: { redirectUri } });
}, },
login: (location: Location) => { login: (location: Location) => {
return api.oauthApi.callback({ url: location.href }); return api.oauthApi.callback({ oAuthCallbackDto: { url: location.href } });
}, },
link: (location: Location): AxiosPromise<UserResponseDto> => { link: (location: Location): AxiosPromise<UserResponseDto> => {
return api.oauthApi.link({ url: location.href }); return api.oauthApi.link({ oAuthCallbackDto: { url: location.href } });
}, },
unlink: () => { unlink: () => {
return api.oauthApi.unlink(); return api.oauthApi.unlink();

View file

@ -10,7 +10,7 @@
const deleteUser = async () => { const deleteUser = async () => {
try { try {
const deletedUser = await api.userApi.deleteUser(user.id); const deletedUser = await api.userApi.deleteUser({ userId: user.id });
if (deletedUser.data.deletedAt != null) { if (deletedUser.data.deletedAt != null) {
dispatch('user-delete-success'); dispatch('user-delete-success');
} else { } else {

View file

@ -102,7 +102,7 @@
const title = jobDetails[jobId]?.title; const title = jobDetails[jobId]?.title;
try { try {
const { data } = await api.jobApi.sendJobCommand(jobId, jobCommand); const { data } = await api.jobApi.sendJobCommand({ jobId, jobCommandDto: jobCommand });
jobs[jobId] = data; jobs[jobId] = data;
switch (jobCommand.command) { switch (jobCommand.command) {

View file

@ -8,7 +8,7 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const restoreUser = async () => { const restoreUser = async () => {
const restoredUser = await api.userApi.restoreUser(user.id); const restoredUser = await api.userApi.restoreUser({ userId: user.id });
if (restoredUser.data.deletedAt == null) dispatch('user-restore-success'); if (restoredUser.data.deletedAt == null) dispatch('user-restore-success');
else dispatch('user-restore-fail'); else dispatch('user-restore-fail');
}; };

View file

@ -28,8 +28,10 @@
const { data: configs } = await api.systemConfigApi.getConfig(); const { data: configs } = await api.systemConfigApi.getConfig();
const result = await api.systemConfigApi.updateConfig({ const result = await api.systemConfigApi.updateConfig({
...configs, systemConfigDto: {
ffmpeg: ffmpegConfig ...configs,
ffmpeg: ffmpegConfig
}
}); });
ffmpegConfig = { ...result.data.ffmpeg }; ffmpegConfig = { ...result.data.ffmpeg };

View file

@ -73,8 +73,10 @@
} }
const { data: updated } = await api.systemConfigApi.updateConfig({ const { data: updated } = await api.systemConfigApi.updateConfig({
...current, systemConfigDto: {
oauth: oauthConfig ...current,
oauth: oauthConfig
}
}); });
oauthConfig = { ...updated.oauth }; oauthConfig = { ...updated.oauth };

View file

@ -48,8 +48,10 @@
} }
const { data: updated } = await api.systemConfigApi.updateConfig({ const { data: updated } = await api.systemConfigApi.updateConfig({
...current, systemConfigDto: {
passwordLogin: passwordLoginConfig ...current,
passwordLogin: passwordLoginConfig
}
}); });
passwordLoginConfig = { ...updated.passwordLogin }; passwordLoginConfig = { ...updated.passwordLogin };

View file

@ -97,8 +97,10 @@
const { data: currentConfig } = await api.systemConfigApi.getConfig(); const { data: currentConfig } = await api.systemConfigApi.getConfig();
const result = await api.systemConfigApi.updateConfig({ const result = await api.systemConfigApi.updateConfig({
...currentConfig, systemConfigDto: {
storageTemplate: storageConfig ...currentConfig,
storageTemplate: storageConfig
}
}); });
storageConfig.template = result.data.storageTemplate.template; storageConfig.template = result.data.storageTemplate.template;

View file

@ -86,9 +86,10 @@ describe('AlbumCard component', () => {
expect(albumImgElement).toHaveAttribute('alt', album.id); expect(albumImgElement).toHaveAttribute('alt', album.id);
expect(apiMock.assetApi.getAssetThumbnail).toHaveBeenCalledTimes(1); expect(apiMock.assetApi.getAssetThumbnail).toHaveBeenCalledTimes(1);
expect(apiMock.assetApi.getAssetThumbnail).toHaveBeenCalledWith( expect(apiMock.assetApi.getAssetThumbnail).toHaveBeenCalledWith(
'thumbnailIdOne', {
ThumbnailFormat.Jpeg, assetId: 'thumbnailIdOne',
undefined, format: ThumbnailFormat.Jpeg
},
{ responseType: 'blob' } { responseType: 'blob' }
); );
expect(createObjectURLMock).toHaveBeenCalledWith(thumbnailBlob); expect(createObjectURLMock).toHaveBeenCalledWith(thumbnailBlob);

View file

@ -36,9 +36,10 @@
} }
const { data } = await api.assetApi.getAssetThumbnail( const { data } = await api.assetApi.getAssetThumbnail(
thubmnailId, {
ThumbnailFormat.Jpeg, assetId: thubmnailId,
undefined, format: ThumbnailFormat.Jpeg
},
{ {
responseType: 'blob' responseType: 'blob'
} }
@ -61,7 +62,7 @@
}); });
const getAlbumOwnerInfo = async (): Promise<UserResponseDto> => { const getAlbumOwnerInfo = async (): Promise<UserResponseDto> => {
const { data } = await api.userApi.getUserById(album.ownerId); const { data } = await api.userApi.getUserById({ userId: album.ownerId });
return data; return data;
}; };

View file

@ -124,8 +124,11 @@
$: { $: {
if (!isEditingTitle && currentAlbumName != album.albumName && isOwned) { if (!isEditingTitle && currentAlbumName != album.albumName && isOwned) {
api.albumApi api.albumApi
.updateAlbumInfo(album.id, { .updateAlbumInfo({
albumName: album.albumName id: album.id,
updateAlbumDto: {
albumName: album.albumName
}
}) })
.then(() => { .then(() => {
currentAlbumName = album.albumName; currentAlbumName = album.albumName;
@ -143,13 +146,13 @@
const createAlbumHandler = async (event: CustomEvent) => { const createAlbumHandler = async (event: CustomEvent) => {
const { assets }: { assets: AssetResponseDto[] } = event.detail; const { assets }: { assets: AssetResponseDto[] } = event.detail;
try { try {
const { data } = await api.albumApi.addAssetsToAlbum( const { data } = await api.albumApi.addAssetsToAlbum({
album.id, id: album.id,
{ addAssetsDto: {
assetIds: assets.map((a) => a.id) assetIds: assets.map((a) => a.id)
}, },
sharedLink?.key key: sharedLink?.key
); });
if (data.album) { if (data.album) {
album = data.album; album = data.album;
@ -168,8 +171,11 @@
const { selectedUsers }: { selectedUsers: UserResponseDto[] } = event.detail; const { selectedUsers }: { selectedUsers: UserResponseDto[] } = event.detail;
try { try {
const { data } = await api.albumApi.addUsersToAlbum(album.id, { const { data } = await api.albumApi.addUsersToAlbum({
sharedUserIds: Array.from(selectedUsers).map((u) => u.id) id: album.id,
addUsersDto: {
sharedUserIds: Array.from(selectedUsers).map((u) => u.id)
}
}); });
album = data; album = data;
@ -193,7 +199,7 @@
} }
try { try {
const { data } = await api.albumApi.getAlbumInfo(album.id); const { data } = await api.albumApi.getAlbumInfo({ id: album.id });
album = data; album = data;
isShowShareInfoModal = false; isShowShareInfoModal = false;
@ -213,7 +219,7 @@
) )
) { ) {
try { try {
await api.albumApi.deleteAlbum(album.id); await api.albumApi.deleteAlbum({ id: album.id });
goto(backUrl); goto(backUrl);
} catch (e) { } catch (e) {
console.error('Error [userDeleteMenu] ', e); console.error('Error [userDeleteMenu] ', e);
@ -241,10 +247,7 @@
let total = 0; let total = 0;
const { data, status, headers } = await api.albumApi.downloadArchive( const { data, status, headers } = await api.albumApi.downloadArchive(
album.id, { id: album.id, skip: skip || undefined, key: sharedLink?.key },
undefined,
skip || undefined,
sharedLink?.key,
{ {
responseType: 'blob', responseType: 'blob',
onDownloadProgress: function (progressEvent) { onDownloadProgress: function (progressEvent) {
@ -311,8 +314,11 @@
const setAlbumThumbnailHandler = (event: CustomEvent) => { const setAlbumThumbnailHandler = (event: CustomEvent) => {
const { asset }: { asset: AssetResponseDto } = event.detail; const { asset }: { asset: AssetResponseDto } = event.detail;
try { try {
api.albumApi.updateAlbumInfo(album.id, { api.albumApi.updateAlbumInfo({
albumThumbnailAssetId: asset.id id: album.id,
updateAlbumDto: {
albumThumbnailAssetId: asset.id
}
}); });
} catch (e) { } catch (e) {
console.error('Error [setAlbumThumbnailHandler] ', e); console.error('Error [setAlbumThumbnailHandler] ', e);

View file

@ -53,7 +53,7 @@
const removeUser = async (userId: string) => { const removeUser = async (userId: string) => {
if (window.confirm('Do you want to remove selected user from the album?')) { if (window.confirm('Do you want to remove selected user from the album?')) {
try { try {
await api.albumApi.removeUserFromAlbum(album.id, userId); await api.albumApi.removeUserFromAlbum({ id: album.id, userId });
dispatch('user-deleted', { userId }); dispatch('user-deleted', { userId });
} catch (e) { } catch (e) {
console.error('Error [share-info-modal] [removeUser]', e); console.error('Error [share-info-modal] [removeUser]', e);

View file

@ -19,7 +19,7 @@
let sharedLinks: SharedLinkResponseDto[] = []; let sharedLinks: SharedLinkResponseDto[] = [];
onMount(async () => { onMount(async () => {
await getSharedLinks(); await getSharedLinks();
const { data } = await api.userApi.getAllUsers(false); const { data } = await api.userApi.getAllUsers({ isAll: false });
// remove invalid users // remove invalid users
users = data.filter((user) => !(user.deletedAt || user.id === album.ownerId)); users = data.filter((user) => !(user.deletedAt || user.id === album.ownerId));

View file

@ -65,7 +65,7 @@
const getAllAlbums = async () => { const getAllAlbums = async () => {
try { try {
const { data } = await api.albumApi.getAllAlbums(undefined, asset.id); const { data } = await api.albumApi.getAllAlbums({ assetId: asset.id });
appearsInAlbums = data; appearsInAlbums = data;
} catch (e) { } catch (e) {
console.error('Error getting album that asset belong to', e); console.error('Error getting album that asset belong to', e);
@ -151,16 +151,19 @@
$downloadAssets[imageFileName] = 0; $downloadAssets[imageFileName] = 0;
const { data, status } = await api.assetApi.downloadFile(assetId, key, { const { data, status } = await api.assetApi.downloadFile(
responseType: 'blob', { assetId, key },
onDownloadProgress: (progressEvent) => { {
if (progressEvent.lengthComputable) { responseType: 'blob',
const total = progressEvent.total; onDownloadProgress: (progressEvent) => {
const current = progressEvent.loaded; if (progressEvent.lengthComputable) {
$downloadAssets[imageFileName] = Math.floor((current / total) * 100); const total = progressEvent.total;
const current = progressEvent.loaded;
$downloadAssets[imageFileName] = Math.floor((current / total) * 100);
}
} }
} }
}); );
if (!(data instanceof Blob)) { if (!(data instanceof Blob)) {
return; return;
@ -203,7 +206,9 @@
) )
) { ) {
const { data: deletedAssets } = await api.assetApi.deleteAsset({ const { data: deletedAssets } = await api.assetApi.deleteAsset({
ids: [asset.id] deleteAssetDto: {
ids: [asset.id]
}
}); });
navigateAssetForward(); navigateAssetForward();
@ -224,8 +229,11 @@
}; };
const toggleFavorite = async () => { const toggleFavorite = async () => {
const { data } = await api.assetApi.updateAsset(asset.id, { const { data } = await api.assetApi.updateAsset({
isFavorite: !asset.isFavorite assetId: asset.id,
updateAssetDto: {
isFavorite: !asset.isFavorite
}
}); });
asset.isFavorite = data.isFavorite; asset.isFavorite = data.isFavorite;
@ -241,10 +249,12 @@
isShowAlbumPicker = false; isShowAlbumPicker = false;
const { albumName }: { albumName: string } = event.detail; const { albumName }: { albumName: string } = event.detail;
api.albumApi.createAlbum({ albumName, assetIds: [asset.id] }).then((response) => { api.albumApi
const album = response.data; .createAlbum({ createAlbumDto: { albumName, assetIds: [asset.id] } })
goto('/albums/' + album.id); .then((response) => {
}); const album = response.data;
goto('/albums/' + album.id);
});
}; };
const handleAddToAlbum = async (event: CustomEvent<{ album: AlbumResponseDto }>) => { const handleAddToAlbum = async (event: CustomEvent<{ album: AlbumResponseDto }>) => {
@ -272,8 +282,11 @@
const toggleArchive = async () => { const toggleArchive = async () => {
try { try {
const { data } = await api.assetApi.updateAsset(asset.id, { const { data } = await api.assetApi.updateAsset({
isArchived: !asset.isArchived assetId: asset.id,
updateAssetDto: {
isArchived: !asset.isArchived
}
}); });
asset.isArchived = data.isArchived; asset.isArchived = data.isArchived;

View file

@ -21,7 +21,7 @@
$: { $: {
// Get latest description from server // Get latest description from server
if (asset.id) { if (asset.id) {
api.assetApi.getAssetById(asset.id).then((res) => { api.assetApi.getAssetById({ assetId: asset.id }).then((res) => {
people = res.data?.people || []; people = res.data?.people || [];
textarea.value = res.data?.exifInfo?.description || ''; textarea.value = res.data?.exifInfo?.description || '';
}); });
@ -64,8 +64,11 @@
const handleFocusOut = async () => { const handleFocusOut = async () => {
dispatch('description-focus-out'); dispatch('description-focus-out');
try { try {
await api.assetApi.updateAsset(asset.id, { await api.assetApi.updateAsset({
description: description assetId: asset.id,
updateAssetDto: {
description: description
}
}); });
} catch (error) { } catch (error) {
console.error(error); console.error(error);

View file

@ -26,9 +26,12 @@
const loadAssetData = async () => { const loadAssetData = async () => {
try { try {
const { data } = await api.assetApi.serveFile(asset.id, false, true, publicSharedKey, { const { data } = await api.assetApi.serveFile(
responseType: 'blob' { assetId: asset.id, isThumb: false, isWeb: true, key: publicSharedKey },
}); {
responseType: 'blob'
}
);
if (!(data instanceof Blob)) { if (!(data instanceof Blob)) {
return; return;

View file

@ -31,10 +31,12 @@
const lastName = form.get('lastName'); const lastName = form.get('lastName');
const { status } = await api.authenticationApi.adminSignUp({ const { status } = await api.authenticationApi.adminSignUp({
email: String(email), signUpDto: {
password: String(password), email: String(email),
firstName: String(firstName), password: String(password),
lastName: String(lastName) firstName: String(firstName),
lastName: String(lastName)
}
}); });
if (status === 201) { if (status === 201) {

View file

@ -29,9 +29,11 @@
error = ''; error = '';
const { status } = await api.userApi.updateUser({ const { status } = await api.userApi.updateUser({
id: user.id, updateUserDto: {
password: String(password), id: user.id,
shouldChangePassword: false password: String(password),
shouldChangePassword: false
}
}); });
if (status === 200) { if (status === 200) {

View file

@ -46,10 +46,12 @@
try { try {
const { status } = await api.userApi.createUser({ const { status } = await api.userApi.createUser({
email: String(email), createUserDto: {
password: String(password), email: String(email),
firstName: String(firstName), password: String(password),
lastName: String(lastName) firstName: String(firstName),
lastName: String(lastName)
}
}); });
if (status === 201) { if (status === 201) {

View file

@ -21,11 +21,13 @@
try { try {
const { id, email, firstName, lastName, storageLabel } = user; const { id, email, firstName, lastName, storageLabel } = user;
const { status } = await api.userApi.updateUser({ const { status } = await api.userApi.updateUser({
id, updateUserDto: {
email, id,
firstName, email,
lastName, firstName,
storageLabel: storageLabel || '' lastName,
storageLabel: storageLabel || ''
}
}); });
if (status === 200) { if (status === 200) {
@ -42,9 +44,11 @@
const defaultPassword = 'password'; const defaultPassword = 'password';
const { status } = await api.userApi.updateUser({ const { status } = await api.userApi.updateUser({
id: user.id, updateUserDto: {
password: defaultPassword, id: user.id,
shouldChangePassword: true password: defaultPassword,
shouldChangePassword: true
}
}); });
if (status == 200) { if (status == 200) {

View file

@ -57,8 +57,10 @@
loading = true; loading = true;
const { data } = await api.authenticationApi.login({ const { data } = await api.authenticationApi.login({
email, loginCredentialDto: {
password email,
password
}
}); });
if (!data.isAdmin && data.shouldChangePassword) { if (!data.isAdmin && data.shouldChangePassword) {

View file

@ -27,7 +27,7 @@
const { albumName }: { albumName: string } = event.detail; const { albumName }: { albumName: string } = event.detail;
const assetIds = Array.from(getAssets()).map((asset) => asset.id); const assetIds = Array.from(getAssets()).map((asset) => asset.id);
api.albumApi.createAlbum({ albumName, assetIds }).then((response) => { api.albumApi.createAlbum({ createAlbumDto: { albumName, assetIds } }).then((response) => {
const { id, albumName } = response.data; const { id, albumName } = response.data;
notificationController.show({ notificationController.show({

View file

@ -28,7 +28,7 @@
for (const asset of getAssets()) { for (const asset of getAssets()) {
if (asset.isArchived !== isArchived) { if (asset.isArchived !== isArchived) {
api.assetApi.updateAsset(asset.id, { isArchived }); api.assetApi.updateAsset({ assetId: asset.id, updateAssetDto: { isArchived } });
onAssetArchive(asset, isArchived); onAssetArchive(asset, isArchived);
cnt = cnt + 1; cnt = cnt + 1;

View file

@ -20,7 +20,9 @@
let count = 0; let count = 0;
const { data: deletedAssets } = await api.assetApi.deleteAsset({ const { data: deletedAssets } = await api.assetApi.deleteAsset({
ids: Array.from(getAssets()).map((a) => a.id) deleteAssetDto: {
ids: Array.from(getAssets()).map((a) => a.id)
}
}); });
for (const asset of deletedAssets) { for (const asset of deletedAssets) {

View file

@ -28,7 +28,7 @@
let cnt = 0; let cnt = 0;
for (const asset of getAssets()) { for (const asset of getAssets()) {
if (asset.isFavorite !== isFavorite) { if (asset.isFavorite !== isFavorite) {
api.assetApi.updateAsset(asset.id, { isFavorite }); api.assetApi.updateAsset({ assetId: asset.id, updateAssetDto: { isFavorite } });
onAssetFavorite(asset, isFavorite); onAssetFavorite(asset, isFavorite);
cnt = cnt + 1; cnt = cnt + 1;
} }

View file

@ -15,8 +15,11 @@
const handleRemoveFromAlbum = async () => { const handleRemoveFromAlbum = async () => {
if (window.confirm('Do you want to remove selected assets from the album?')) { if (window.confirm('Do you want to remove selected assets from the album?')) {
try { try {
const { data } = await api.albumApi.removeAssetFromAlbum(album.id, { const { data } = await api.albumApi.removeAssetFromAlbum({
assetIds: Array.from(getAssets()).map((a) => a.id) id: album.id,
removeAssetsDto: {
assetIds: Array.from(getAssets()).map((a) => a.id)
}
}); });
album = data; album = data;

View file

@ -14,12 +14,12 @@
// TODO: Rename API method or change functionality. The assetIds passed // TODO: Rename API method or change functionality. The assetIds passed
// in are kept instead of removed. // in are kept instead of removed.
const assetsToKeep = allAssets.filter((a) => !getAssets().has(a)); const assetsToKeep = allAssets.filter((a) => !getAssets().has(a));
await api.assetApi.removeAssetsFromSharedLink( await api.assetApi.removeAssetsFromSharedLink({
{ removeAssetsDto: {
assetIds: assetsToKeep.map((a) => a.id) assetIds: assetsToKeep.map((a) => a.id)
}, },
sharedLink?.key key: sharedLink?.key
); });
sharedLink.assets = assetsToKeep; sharedLink.assets = assetsToKeep;
clearSelect(); clearSelect();

View file

@ -28,8 +28,10 @@
onMount(async () => { onMount(async () => {
const { data: assetCountByTimebucket } = await api.assetApi.getAssetCountByTimeBucket({ const { data: assetCountByTimebucket } = await api.assetApi.getAssetCountByTimeBucket({
timeGroup: TimeGroupEnum.Month, getAssetCountByTimeBucketDto: {
userId: user?.id timeGroup: TimeGroupEnum.Month,
userId: user?.id
}
}); });
bucketInfo = assetCountByTimebucket; bucketInfo = assetCountByTimebucket;

View file

@ -40,12 +40,12 @@
const assetIds = results.filter((id) => !!id) as string[]; const assetIds = results.filter((id) => !!id) as string[];
await api.assetApi.addAssetsToSharedLink( await api.assetApi.addAssetsToSharedLink({
{ addAssetsDto: {
assetIds assetIds
}, },
sharedLink?.key key: sharedLink?.key
); });
notificationController.show({ notificationController.show({
message: `Successfully add ${assetIds.length} to the shared link`, message: `Successfully add ${assetIds.length} to the shared link`,

View file

@ -16,7 +16,7 @@
export let shared: boolean; export let shared: boolean;
onMount(async () => { onMount(async () => {
const { data } = await api.albumApi.getAllAlbums(shared || undefined); const { data } = await api.albumApi.getAllAlbums({ shared: shared || undefined });
albums = data; albums = data;
recentAlbums = albums recentAlbums = albums

View file

@ -10,9 +10,12 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const getUserAvatar = async () => { const getUserAvatar = async () => {
const { data } = await api.userApi.getProfileImage(user.id, { const { data } = await api.userApi.getProfileImage(
responseType: 'blob' { userId: user.id },
}); {
responseType: 'blob'
}
);
if (data instanceof Blob) { if (data instanceof Blob) {
return URL.createObjectURL(data); return URL.createObjectURL(data);

View file

@ -60,22 +60,26 @@
try { try {
if (shareType === SharedLinkType.Album && album) { if (shareType === SharedLinkType.Album && album) {
const { data } = await api.albumApi.createAlbumSharedLink({ const { data } = await api.albumApi.createAlbumSharedLink({
albumId: album.id, createAlbumShareLinkDto: {
expiresAt: expirationDate, albumId: album.id,
allowUpload: isAllowUpload, expiresAt: expirationDate,
description: description, allowUpload: isAllowUpload,
allowDownload: isAllowDownload, description: description,
showExif: shouldShowExif allowDownload: isAllowDownload,
showExif: shouldShowExif
}
}); });
buildSharedLink(data); buildSharedLink(data);
} else { } else {
const { data } = await api.assetApi.createAssetsSharedLink({ const { data } = await api.assetApi.createAssetsSharedLink({
assetIds: sharedAssets.map((a) => a.id), createAssetsShareLinkDto: {
expiresAt: expirationDate, assetIds: sharedAssets.map((a) => a.id),
allowUpload: isAllowUpload, expiresAt: expirationDate,
description: description, allowUpload: isAllowUpload,
allowDownload: isAllowDownload, description: description,
showExif: shouldShowExif allowDownload: isAllowDownload,
showExif: shouldShowExif
}
}); });
buildSharedLink(data); buildSharedLink(data);
} }
@ -133,12 +137,15 @@
? new Date(currentTime + expirationTime).toISOString() ? new Date(currentTime + expirationTime).toISOString()
: null; : null;
await api.shareApi.editSharedLink(editingLink.id, { await api.shareApi.editSharedLink({
description, id: editingLink.id,
expiresAt: shouldChangeExpirationTime ? expirationDate : undefined, editSharedLinkDto: {
allowUpload: isAllowUpload, description,
allowDownload: isAllowDownload, expiresAt: shouldChangeExpirationTime ? expirationDate : undefined,
showExif: shouldShowExif allowUpload: isAllowUpload,
allowDownload: isAllowDownload,
showExif: shouldShowExif
}
}); });
notificationController.show({ notificationController.show({

View file

@ -30,7 +30,7 @@
const getFavoriteCount = async () => { const getFavoriteCount = async () => {
try { try {
const { data: assets } = await api.assetApi.getAllAssets(undefined, true, undefined); const { data: assets } = await api.assetApi.getAllAssets({ isFavorite: true });
return { return {
favorites: assets.length favorites: assets.length

View file

@ -30,7 +30,7 @@
assetId = link.assets[0].id; assetId = link.assets[0].id;
} }
const { data } = await api.assetApi.getAssetById(assetId); const { data } = await api.assetApi.getAssetById({ assetId });
return data; return data;
}; };

View file

@ -17,8 +17,10 @@
const handleChangePassword = async () => { const handleChangePassword = async () => {
try { try {
await api.authenticationApi.changePassword({ await api.authenticationApi.changePassword({
password, changePasswordDto: {
newPassword password,
newPassword
}
}); });
notificationController.show({ notificationController.show({

View file

@ -29,7 +29,7 @@
} }
try { try {
await api.authenticationApi.logoutAuthDevice(deleteDevice.id); await api.authenticationApi.logoutAuthDevice({ id: deleteDevice.id });
notificationController.show({ message: `Logged out device`, type: NotificationType.Info }); notificationController.show({ message: `Logged out device`, type: NotificationType.Info });
} catch (error) { } catch (error) {
handleError(error, 'Unable to log out device'); handleError(error, 'Unable to log out device');

View file

@ -15,13 +15,13 @@
onMount(async () => { onMount(async () => {
// TODO: update endpoint to have a query param for deleted users // TODO: update endpoint to have a query param for deleted users
let { data: users } = await api.userApi.getAllUsers(false); let { data: users } = await api.userApi.getAllUsers({ isAll: false });
// remove invalid users // remove invalid users
users = users.filter((_user) => !(_user.deletedAt || _user.id === user.id)); users = users.filter((_user) => !(_user.deletedAt || _user.id === user.id));
// exclude partners from the list of users available for selection // exclude partners from the list of users available for selection
const { data: partners } = await api.partnerApi.getPartners('shared-by'); const { data: partners } = await api.partnerApi.getPartners({ direction: 'shared-by' });
const partnerIds = partners.map((partner) => partner.id); const partnerIds = partners.map((partner) => partner.id);
availableUsers = users.filter((user) => !partnerIds.includes(user.id)); availableUsers = users.filter((user) => !partnerIds.includes(user.id));
}); });

View file

@ -16,7 +16,7 @@
let removePartner: UserResponseDto | null = null; let removePartner: UserResponseDto | null = null;
const refreshPartners = async () => { const refreshPartners = async () => {
const { data } = await api.partnerApi.getPartners('shared-by'); const { data } = await api.partnerApi.getPartners({ direction: 'shared-by' });
partners = data; partners = data;
}; };
@ -26,7 +26,7 @@
} }
try { try {
await api.partnerApi.removePartner(removePartner.id); await api.partnerApi.removePartner({ id: removePartner.id });
removePartner = null; removePartner = null;
await refreshPartners(); await refreshPartners();
} catch (error) { } catch (error) {
@ -37,7 +37,7 @@
const handleCreatePartners = async (users: UserResponseDto[]) => { const handleCreatePartners = async (users: UserResponseDto[]) => {
try { try {
for (const user of users) { for (const user of users) {
await api.partnerApi.createPartner(user.id); await api.partnerApi.createPartner({ id: user.id });
} }
await refreshPartners(); await refreshPartners();

View file

@ -40,7 +40,7 @@
const handleCreate = async (event: CustomEvent<APIKeyResponseDto>) => { const handleCreate = async (event: CustomEvent<APIKeyResponseDto>) => {
try { try {
const dto = event.detail; const dto = event.detail;
const { data } = await api.keyApi.createKey(dto); const { data } = await api.keyApi.createKey({ aPIKeyCreateDto: dto });
secret = data.secret; secret = data.secret;
} catch (error) { } catch (error) {
handleError(error, 'Unable to create a new API Key'); handleError(error, 'Unable to create a new API Key');
@ -58,7 +58,7 @@
const dto = event.detail; const dto = event.detail;
try { try {
await api.keyApi.updateKey(editKey.id, { name: dto.name }); await api.keyApi.updateKey({ id: editKey.id, aPIKeyUpdateDto: { name: dto.name } });
notificationController.show({ notificationController.show({
message: `Saved API Key`, message: `Saved API Key`,
type: NotificationType.Info type: NotificationType.Info
@ -77,7 +77,7 @@
} }
try { try {
await api.keyApi.deleteKey(deleteKey.id); await api.keyApi.deleteKey({ id: deleteKey.id });
notificationController.show({ notificationController.show({
message: `Removed API Key: ${deleteKey.name}`, message: `Removed API Key: ${deleteKey.name}`,
type: NotificationType.Info type: NotificationType.Info

View file

@ -16,10 +16,12 @@
const handleSaveProfile = async () => { const handleSaveProfile = async () => {
try { try {
const { data } = await api.userApi.updateUser({ const { data } = await api.userApi.updateUser({
id: user.id, updateUserDto: {
email: user.email, id: user.id,
firstName: user.firstName, email: user.email,
lastName: user.lastName firstName: user.firstName,
lastName: user.lastName
}
}); });
Object.assign(user, data); Object.assign(user, data);

View file

@ -57,7 +57,7 @@ function createAssetInteractionStore() {
}; };
const setViewingAssetId = async (id: string) => { const setViewingAssetId = async (id: string) => {
const { data } = await api.assetApi.getAssetById(id); const { data } = await api.assetApi.getAssetById({ assetId: id });
viewingAssetStoreState.set(data); viewingAssetStoreState.set(data);
isViewingAssetStoreState.set(true); isViewingAssetStoreState.set(true);
}; };

View file

@ -66,9 +66,11 @@ function createAssetStore() {
}); });
const { data: assets } = await api.assetApi.getAssetByTimeBucket( const { data: assets } = await api.assetApi.getAssetByTimeBucket(
{ {
timeBucket: [bucket], getAssetByTimeBucketDto: {
userId: _assetGridState.userId, timeBucket: [bucket],
withoutThumbs: true userId: _assetGridState.userId,
withoutThumbs: true
}
}, },
{ signal: currentBucketData?.cancelToken.signal } { signal: currentBucketData?.cancelToken.signal }
); );

View file

@ -10,17 +10,19 @@ export const addAssetsToAlbum = async (
assetIds: Array<string>, assetIds: Array<string>,
key: string | undefined = undefined key: string | undefined = undefined
): Promise<AddAssetsResponseDto> => ): Promise<AddAssetsResponseDto> =>
api.albumApi.addAssetsToAlbum(albumId, { assetIds }, key).then(({ data: dto }) => { api.albumApi
if (dto.successfullyAdded > 0) { .addAssetsToAlbum({ id: albumId, addAssetsDto: { assetIds }, key })
// This might be 0 if the user tries to add an asset that is already in the album .then(({ data: dto }) => {
notificationController.show({ if (dto.successfullyAdded > 0) {
message: `Added ${dto.successfullyAdded} to ${dto.album?.albumName}`, // This might be 0 if the user tries to add an asset that is already in the album
type: NotificationType.Info notificationController.show({
}); message: `Added ${dto.successfullyAdded} to ${dto.album?.albumName}`,
} type: NotificationType.Info
});
}
return dto; return dto;
}); });
export async function bulkDownload( export async function bulkDownload(
fileName: string, fileName: string,
@ -43,20 +45,23 @@ export async function bulkDownload(
let total = 0; let total = 0;
const { data, status, headers } = await api.assetApi.downloadFiles({ assetIds }, key, { const { data, status, headers } = await api.assetApi.downloadFiles(
responseType: 'blob', { downloadFilesDto: { assetIds }, key },
onDownloadProgress: function (progressEvent) { {
const request = this as XMLHttpRequest; responseType: 'blob',
if (!total) { onDownloadProgress: function (progressEvent) {
total = Number(request.getResponseHeader('X-Immich-Content-Length-Hint')) || 0; const request = this as XMLHttpRequest;
} if (!total) {
total = Number(request.getResponseHeader('X-Immich-Content-Length-Hint')) || 0;
}
if (total) { if (total) {
const current = progressEvent.loaded; const current = progressEvent.loaded;
downloadAssets.set({ [downloadFileName]: Math.floor((current / total) * 100) }); downloadAssets.set({ [downloadFileName]: Math.floor((current / total) * 100) });
}
} }
} }
}); );
const isNotComplete = headers['x-immich-archive-complete'] === 'false'; const isNotComplete = headers['x-immich-archive-complete'] === 'false';
const fileCount = Number(headers['x-immich-archive-file-count']) || 0; const fileCount = Number(headers['x-immich-archive-file-count']) || 0;

View file

@ -10,7 +10,7 @@ export const load = (async ({ params, locals: { api, user } }) => {
const albumId = params['albumId']; const albumId = params['albumId'];
try { try {
const { data: album } = await api.albumApi.getAlbumInfo(albumId); const { data: album } = await api.albumApi.getAlbumInfo({ id: albumId });
return { return {
album, album,
meta: { meta: {

View file

@ -90,7 +90,7 @@ describe('Albums BLoC', () => {
const newAlbum = await sut.createAlbum(); const newAlbum = await sut.createAlbum();
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledTimes(1); expect(apiMock.albumApi.createAlbum).toHaveBeenCalledTimes(1);
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledWith(payload); expect(apiMock.albumApi.createAlbum).toHaveBeenCalledWith({ createAlbumDto: payload });
expect(newAlbum).toEqual(returnedAlbum); expect(newAlbum).toEqual(returnedAlbum);
}); });
@ -130,7 +130,7 @@ describe('Albums BLoC', () => {
const updatedAlbums = get(sut.albums); const updatedAlbums = get(sut.albums);
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledTimes(1); expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledTimes(1);
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledWith(albumToDeleteId); expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledWith({ id: albumToDeleteId });
expect(updatedAlbums).toHaveLength(4); expect(updatedAlbums).toHaveLength(4);
expect(updatedAlbums).not.toContain(albumToDelete); expect(updatedAlbums).not.toContain(albumToDelete);
expect(get(sut.isShowContextMenu)).toBe(false); expect(get(sut.isShowContextMenu)).toBe(false);

View file

@ -40,7 +40,9 @@ export const useAlbums = (props: AlbumsProps) => {
async function createAlbum(): Promise<AlbumResponseDto | undefined> { async function createAlbum(): Promise<AlbumResponseDto | undefined> {
try { try {
const { data: newAlbum } = await api.albumApi.createAlbum({ const { data: newAlbum } = await api.albumApi.createAlbum({
albumName: 'Untitled' createAlbumDto: {
albumName: 'Untitled'
}
}); });
return newAlbum; return newAlbum;
@ -53,7 +55,7 @@ export const useAlbums = (props: AlbumsProps) => {
} }
async function deleteAlbum(album: AlbumResponseDto): Promise<void> { async function deleteAlbum(album: AlbumResponseDto): Promise<void> {
await api.albumApi.deleteAlbum(album.id); await api.albumApi.deleteAlbum({ id: album.id });
} }
async function showAlbumContextMenu( async function showAlbumContextMenu(
@ -83,7 +85,7 @@ export const useAlbums = (props: AlbumsProps) => {
) )
) { ) {
try { try {
await api.albumApi.deleteAlbum(albumToDelete.id); await api.albumApi.deleteAlbum({ id: albumToDelete.id });
const _albums = get(albums); const _albums = get(albums);
albums.set(_albums.filter((a) => a.id !== albumToDelete.id)); albums.set(_albums.filter((a) => a.id !== albumToDelete.id));
} catch { } catch {

View file

@ -26,7 +26,7 @@
onMount(async () => { onMount(async () => {
try { try {
const { data: assets } = await api.assetApi.getAllAssets(undefined, undefined, true); const { data: assets } = await api.assetApi.getAllAssets({ isArchived: true });
$archivedAsset = assets; $archivedAsset = assets;
} catch { } catch {
handleError(Error, 'Unable to load archived assets'); handleError(Error, 'Unable to load archived assets');

View file

@ -28,7 +28,7 @@
onMount(async () => { onMount(async () => {
try { try {
const { data: assets } = await api.assetApi.getAllAssets(undefined, true, undefined); const { data: assets } = await api.assetApi.getAllAssets({ isFavorite: true });
favorites = assets; favorites = assets;
} catch { } catch {
handleError(Error, 'Unable to load favorites'); handleError(Error, 'Unable to load favorites');

View file

@ -48,9 +48,11 @@
const { fileCreatedAfter, fileCreatedBefore } = getFileCreatedDates(); const { fileCreatedAfter, fileCreatedBefore } = getFileCreatedDates();
const { data } = await api.assetApi.getMapMarkers( const { data } = await api.assetApi.getMapMarkers(
onlyFavorites || undefined, {
fileCreatedAfter, isFavorite: onlyFavorites || undefined,
fileCreatedBefore, fileCreatedAfter,
fileCreatedBefore
},
{ {
signal: abortController.signal signal: abortController.signal
} }

View file

@ -9,7 +9,7 @@ export const load: PageServerLoad = async ({ params, parent, locals: { api } })
throw redirect(302, AppRoute.AUTH_LOGIN); throw redirect(302, AppRoute.AUTH_LOGIN);
} }
const { data: partner } = await api.userApi.getUserById(params['userId']); const { data: partner } = await api.userApi.getUserById({ userId: params['userId'] });
return { return {
user, user,

View file

@ -7,8 +7,8 @@ export const load = (async ({ locals, parent, params }) => {
throw redirect(302, '/auth/login'); throw redirect(302, '/auth/login');
} }
const { data: person } = await locals.api.personApi.getPerson(params.personId); const { data: person } = await locals.api.personApi.getPerson({ id: params.personId });
const { data: assets } = await locals.api.personApi.getPersonAssets(params.personId); const { data: assets } = await locals.api.personApi.getPersonAssets({ id: params.personId });
return { return {
user, user,

View file

@ -41,7 +41,7 @@
try { try {
isEditName = false; isEditName = false;
data.person.name = name; data.person.name = name;
await api.personApi.updatePerson(data.person.id, { name }); await api.personApi.updatePerson({ id: data.person.id, personUpdateDto: { name } });
} catch (error) { } catch (error) {
handleError(error, 'Unable to save name'); handleError(error, 'Unable to save name');
} }

View file

@ -9,24 +9,7 @@ export const load = (async ({ locals, parent, url }) => {
const term = url.searchParams.get('q') || url.searchParams.get('query') || undefined; const term = url.searchParams.get('q') || url.searchParams.get('query') || undefined;
const { data: results } = await locals.api.searchApi.search( const { data: results } = await locals.api.searchApi.search({}, { params: url.searchParams });
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
{ params: url.searchParams }
);
return { return {
user, user,

View file

@ -7,7 +7,7 @@ export const load = (async ({ params, locals: { api } }) => {
const { key } = params; const { key } = params;
try { try {
const { data: sharedLink } = await api.shareApi.getMySharedLink(key); const { data: sharedLink } = await api.shareApi.getMySharedLink({ key });
const assetCount = sharedLink.assets.length; const assetCount = sharedLink.assets.length;
const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id; const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id;

View file

@ -6,7 +6,7 @@ import type { PageServerLoad } from './$types';
export const load = (async ({ params, locals: { api } }) => { export const load = (async ({ params, locals: { api } }) => {
try { try {
const { key, assetId } = params; const { key, assetId } = params;
const { data: asset } = await api.assetApi.getAssetById(assetId, key); const { data: asset } = await api.assetApi.getAssetById({ assetId, key });
if (!asset) { if (!asset) {
return error(404, 'Asset not found'); return error(404, 'Asset not found');

View file

@ -8,8 +8,8 @@ export const load = (async ({ locals: { api, user } }) => {
} }
try { try {
const { data: sharedAlbums } = await api.albumApi.getAllAlbums(true); const { data: sharedAlbums } = await api.albumApi.getAllAlbums({ shared: true });
const { data: partners } = await api.partnerApi.getPartners('shared-with'); const { data: partners } = await api.partnerApi.getPartners({ direction: 'shared-with' });
return { return {
user, user,

View file

@ -21,7 +21,9 @@
const createSharedAlbum = async () => { const createSharedAlbum = async () => {
try { try {
const { data: newAlbum } = await api.albumApi.createAlbum({ const { data: newAlbum } = await api.albumApi.createAlbum({
albumName: 'Untitled' createAlbumDto: {
albumName: 'Untitled'
}
}); });
goto('/albums/' + newAlbum.id); goto('/albums/' + newAlbum.id);

View file

@ -29,7 +29,7 @@
const handleDeleteLink = async (linkId: string) => { const handleDeleteLink = async (linkId: string) => {
if (window.confirm('Do you want to delete the shared link? ')) { if (window.confirm('Do you want to delete the shared link? ')) {
try { try {
await api.shareApi.removeSharedLink(linkId); await api.shareApi.removeSharedLink({ id: linkId });
notificationController.show({ notificationController.show({
message: 'Shared link deleted', message: 'Shared link deleted',
type: NotificationType.Info type: NotificationType.Info
@ -47,7 +47,7 @@
}; };
const handleEditLink = async (id: string) => { const handleEditLink = async (id: string) => {
const { data } = await api.shareApi.getSharedLinkById(id); const { data } = await api.shareApi.getSharedLinkById({ id });
editSharedLink = data; editSharedLink = data;
showEditForm = true; showEditForm = true;
}; };

View file

@ -9,7 +9,7 @@ export const load = (async ({ parent, locals: { api } }) => {
throw redirect(302, '/photos'); throw redirect(302, '/photos');
} }
const { data } = await api.userApi.getUserCount(true); const { data } = await api.userApi.getUserCount({ admin: true });
if (data.userCount > 0) { if (data.userCount > 0) {
// Redirect to login page if an admin is already registered. // Redirect to login page if an admin is already registered.

View file

@ -10,7 +10,7 @@ export const load = (async ({ parent, locals: { api } }) => {
throw redirect(302, '/photos'); throw redirect(302, '/photos');
} }
const { data: allUsers } = await api.userApi.getAllUsers(false); const { data: allUsers } = await api.userApi.getAllUsers({ isAll: false });
return { return {
user, user,

View file

@ -46,7 +46,7 @@
}; };
const onUserCreated = async () => { const onUserCreated = async () => {
const getAllUsersRes = await api.userApi.getAllUsers(false); const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data; allUsers = getAllUsersRes.data;
shouldShowCreateUserForm = false; shouldShowCreateUserForm = false;
}; };
@ -57,13 +57,13 @@
}; };
const onEditUserSuccess = async () => { const onEditUserSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers(false); const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data; allUsers = getAllUsersRes.data;
shouldShowEditUserForm = false; shouldShowEditUserForm = false;
}; };
const onEditPasswordSuccess = async () => { const onEditPasswordSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers(false); const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data; allUsers = getAllUsersRes.data;
shouldShowEditUserForm = false; shouldShowEditUserForm = false;
shouldShowInfoPanel = true; shouldShowInfoPanel = true;
@ -75,13 +75,13 @@
}; };
const onUserDeleteSuccess = async () => { const onUserDeleteSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers(false); const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data; allUsers = getAllUsersRes.data;
shouldShowDeleteConfirmDialog = false; shouldShowDeleteConfirmDialog = false;
}; };
const onUserDeleteFail = async () => { const onUserDeleteFail = async () => {
const getAllUsersRes = await api.userApi.getAllUsers(false); const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data; allUsers = getAllUsersRes.data;
shouldShowDeleteConfirmDialog = false; shouldShowDeleteConfirmDialog = false;
}; };
@ -92,14 +92,14 @@
}; };
const onUserRestoreSuccess = async () => { const onUserRestoreSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers(false); const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data; allUsers = getAllUsersRes.data;
shouldShowRestoreDialog = false; shouldShowRestoreDialog = false;
}; };
const onUserRestoreFail = async () => { const onUserRestoreFail = async () => {
// show fail dialog // show fail dialog
const getAllUsersRes = await api.userApi.getAllUsers(false); const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data; allUsers = getAllUsersRes.data;
shouldShowRestoreDialog = false; shouldShowRestoreDialog = false;
}; };

View file

@ -4,7 +4,7 @@ import type { OAuthConfigResponseDto } from '@api';
import type { PageServerLoad } from './$types'; import type { PageServerLoad } from './$types';
export const load = (async ({ locals: { api } }) => { export const load = (async ({ locals: { api } }) => {
const { data } = await api.userApi.getUserCount(true); const { data } = await api.userApi.getUserCount({ admin: true });
if (data.userCount === 0) { if (data.userCount === 0) {
// Admin not registered // Admin not registered
throw redirect(302, AppRoute.AUTH_REGISTER); throw redirect(302, AppRoute.AUTH_REGISTER);
@ -17,7 +17,7 @@ export const load = (async ({ locals: { api } }) => {
try { try {
// TODO: Figure out how to get correct redirect URI server-side. // TODO: Figure out how to get correct redirect URI server-side.
const { data } = await api.oauthApi.generateConfig({ redirectUri: '/' }); const { data } = await api.oauthApi.generateConfig({ oAuthConfigDto: { redirectUri: '/' } });
data.url = undefined; data.url = undefined;
authConfig = data; authConfig = data;

View file

@ -2,7 +2,7 @@ import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types'; import type { PageServerLoad } from './$types';
export const load = (async ({ locals: { api } }) => { export const load = (async ({ locals: { api } }) => {
const { data } = await api.userApi.getUserCount(true); const { data } = await api.userApi.getUserCount({ admin: true });
if (data.userCount != 0) { if (data.userCount != 0) {
// Admin has been registered, redirect to login // Admin has been registered, redirect to login
throw redirect(302, '/auth/login'); throw redirect(302, '/auth/login');