mirror of
https://github.com/immich-app/immich.git
synced 2025-12-30 00:30:37 -05:00
* Multi add to album picker: - update modal for multi select - Update add-to-album and add-to-album-action to work with new array return from AlbumPickerModal - Add asset-utils.addAssetsToAlbums (incomplete) * initial addToAlbums endpoint * - fix endpoint - add test * - update return type - make open-api * - simplify return dto - handle notification * - fix returns - clean up * - update i18n - format & check * - checks * - correct successId count - fix assets_cannot_be_added language call * tests * foromat * refactor * - update successful add message to included total attempted * - fix web test - format i18n * - fix open-api * - fix imports to resolve checks * - PR suggestions * open-api * refactor addAssetsToAlbums * refactor it again * - fix error returns and tests * - swap icon for IconButton - don't nest the buttons * open-api * - Cleanup multi-select button to match Thumbnail * merge and openapi * - remove onclick from icon element * - fix double onClose call with keyboard shortcuts * - spelling and formatting - apply new api permission * - open-api * chore: styling * translation --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
131 lines
4.1 KiB
TypeScript
131 lines
4.1 KiB
TypeScript
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Patch, Post, Put, Query } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import {
|
|
AddUsersDto,
|
|
AlbumInfoDto,
|
|
AlbumResponseDto,
|
|
AlbumsAddAssetsDto,
|
|
AlbumsAddAssetsResponseDto,
|
|
AlbumStatisticsResponseDto,
|
|
CreateAlbumDto,
|
|
GetAlbumsDto,
|
|
UpdateAlbumDto,
|
|
UpdateAlbumUserDto,
|
|
} from 'src/dtos/album.dto';
|
|
import { BulkIdResponseDto, BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
import { Permission } from 'src/enum';
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
import { AlbumService } from 'src/services/album.service';
|
|
import { ParseMeUUIDPipe, UUIDParamDto } from 'src/validation';
|
|
|
|
@ApiTags('Albums')
|
|
@Controller('albums')
|
|
export class AlbumController {
|
|
constructor(private service: AlbumService) {}
|
|
|
|
@Get()
|
|
@Authenticated({ permission: Permission.AlbumRead })
|
|
getAllAlbums(@Auth() auth: AuthDto, @Query() query: GetAlbumsDto): Promise<AlbumResponseDto[]> {
|
|
return this.service.getAll(auth, query);
|
|
}
|
|
|
|
@Post()
|
|
@Authenticated({ permission: Permission.AlbumCreate })
|
|
createAlbum(@Auth() auth: AuthDto, @Body() dto: CreateAlbumDto): Promise<AlbumResponseDto> {
|
|
return this.service.create(auth, dto);
|
|
}
|
|
|
|
@Get('statistics')
|
|
@Authenticated({ permission: Permission.AlbumStatistics })
|
|
getAlbumStatistics(@Auth() auth: AuthDto): Promise<AlbumStatisticsResponseDto> {
|
|
return this.service.getStatistics(auth);
|
|
}
|
|
|
|
@Authenticated({ permission: Permission.AlbumRead, sharedLink: true })
|
|
@Get(':id')
|
|
getAlbumInfo(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Query() dto: AlbumInfoDto,
|
|
): Promise<AlbumResponseDto> {
|
|
return this.service.get(auth, id, dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@Authenticated({ permission: Permission.AlbumUpdate })
|
|
updateAlbumInfo(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: UpdateAlbumDto,
|
|
): Promise<AlbumResponseDto> {
|
|
return this.service.update(auth, id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@Authenticated({ permission: Permission.AlbumDelete })
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
deleteAlbum(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto) {
|
|
return this.service.delete(auth, id);
|
|
}
|
|
|
|
@Put(':id/assets')
|
|
@Authenticated({ permission: Permission.AlbumAssetCreate, sharedLink: true })
|
|
addAssetsToAlbum(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: BulkIdsDto,
|
|
): Promise<BulkIdResponseDto[]> {
|
|
return this.service.addAssets(auth, id, dto);
|
|
}
|
|
|
|
@Put('assets')
|
|
@Authenticated({ permission: Permission.AlbumAssetCreate, sharedLink: true })
|
|
addAssetsToAlbums(@Auth() auth: AuthDto, @Body() dto: AlbumsAddAssetsDto): Promise<AlbumsAddAssetsResponseDto> {
|
|
return this.service.addAssetsToAlbums(auth, dto);
|
|
}
|
|
|
|
@Delete(':id/assets')
|
|
@Authenticated({ permission: Permission.AlbumAssetDelete })
|
|
removeAssetFromAlbum(
|
|
@Auth() auth: AuthDto,
|
|
@Body() dto: BulkIdsDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
): Promise<BulkIdResponseDto[]> {
|
|
return this.service.removeAssets(auth, id, dto);
|
|
}
|
|
|
|
@Put(':id/users')
|
|
@Authenticated({ permission: Permission.AlbumUserCreate })
|
|
addUsersToAlbum(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: AddUsersDto,
|
|
): Promise<AlbumResponseDto> {
|
|
return this.service.addUsers(auth, id, dto);
|
|
}
|
|
|
|
@Put(':id/user/:userId')
|
|
@Authenticated({ permission: Permission.AlbumUserUpdate })
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
updateAlbumUser(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Param('userId', new ParseMeUUIDPipe({ version: '4' })) userId: string,
|
|
@Body() dto: UpdateAlbumUserDto,
|
|
): Promise<void> {
|
|
return this.service.updateUser(auth, id, userId, dto);
|
|
}
|
|
|
|
@Delete(':id/user/:userId')
|
|
@Authenticated({ permission: Permission.AlbumUserDelete })
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
removeUserFromAlbum(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Param('userId', new ParseMeUUIDPipe({ version: '4' })) userId: string,
|
|
): Promise<void> {
|
|
return this.service.removeUser(auth, id, userId);
|
|
}
|
|
}
|