1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-28 09:33:27 +02: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
patch -u apiInner.mustache < apiInner.mustache.patch
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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@
const dispatch = createEventDispatcher();
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');
else dispatch('user-restore-fail');
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@
const { albumName }: { albumName: string } = event.detail;
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;
notificationController.show({

View File

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

View File

@ -20,7 +20,9 @@
let count = 0;
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) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,13 +15,13 @@
onMount(async () => {
// 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
users = users.filter((_user) => !(_user.deletedAt || _user.id === user.id));
// 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);
availableUsers = users.filter((user) => !partnerIds.includes(user.id));
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ export const load: PageServerLoad = async ({ params, parent, locals: { api } })
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 {
user,

View File

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

View File

@ -41,7 +41,7 @@
try {
isEditName = false;
data.person.name = name;
await api.personApi.updatePerson(data.person.id, { name });
await api.personApi.updatePerson({ id: data.person.id, personUpdateDto: { name } });
} catch (error) {
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 { data: results } = await locals.api.searchApi.search(
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
{ params: url.searchParams }
);
const { data: results } = await locals.api.searchApi.search({}, { params: url.searchParams });
return {
user,

View File

@ -7,7 +7,7 @@ export const load = (async ({ params, locals: { api } }) => {
const { key } = params;
try {
const { data: sharedLink } = await api.shareApi.getMySharedLink(key);
const { data: sharedLink } = await api.shareApi.getMySharedLink({ key });
const assetCount = sharedLink.assets.length;
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 } }) => {
try {
const { key, assetId } = params;
const { data: asset } = await api.assetApi.getAssetById(assetId, key);
const { data: asset } = await api.assetApi.getAssetById({ assetId, key });
if (!asset) {
return error(404, 'Asset not found');

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ export const load = (async ({ parent, locals: { api } }) => {
throw redirect(302, '/photos');
}
const { data } = await api.userApi.getUserCount(true);
const { data } = await api.userApi.getUserCount({ admin: true });
if (data.userCount > 0) {
// 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');
}
const { data: allUsers } = await api.userApi.getAllUsers(false);
const { data: allUsers } = await api.userApi.getAllUsers({ isAll: false });
return {
user,

View File

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

View File

@ -4,7 +4,7 @@ import type { OAuthConfigResponseDto } from '@api';
import type { PageServerLoad } from './$types';
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) {
// Admin not registered
throw redirect(302, AppRoute.AUTH_REGISTER);
@ -17,7 +17,7 @@ export const load = (async ({ locals: { api } }) => {
try {
// 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;
authConfig = data;

View File

@ -2,7 +2,7 @@ import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
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) {
// Admin has been registered, redirect to login
throw redirect(302, '/auth/login');