mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
* - add component - update server's StackCreateDto for merge parameter - Update stackRepo to only merge stacks when merge=true (default) - update web action handlers to show stack changes * - make open-api * lint & format * - Add proper icon to 'remove from stack' - change web unstack icon to image-off-outline * - cleanup * - format & lint * - make open-api: StackCreateDto merge optional * initial addition of new endpoint * remove stack endpoint * - fix up remove stack endpoint - open-api * - Undo stackCreate merge parameter * - open-api typescript * open-api dart * Tests: - add tests - update assetStub.imageFrom2015 to have required stack attributes to include it with tests * update event name * Fix event name in test * remove asset_update check * - merge stack.removeAsset params into one object - refactor asset existence check (no need for asset fetch) - fix tests * Don't return updated stack * Create specialized stack id & primary asset fetch for asset removal checks * Correct new permission names * make sql * - fix open-api * - cleanup
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
import { StackCreateDto, StackResponseDto, StackSearchDto, StackUpdateDto } from 'src/dtos/stack.dto';
|
|
import { Permission } from 'src/enum';
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
import { StackService } from 'src/services/stack.service';
|
|
import { UUIDAssetIDParamDto, UUIDParamDto } from 'src/validation';
|
|
|
|
@ApiTags('Stacks')
|
|
@Controller('stacks')
|
|
export class StackController {
|
|
constructor(private service: StackService) {}
|
|
|
|
@Get()
|
|
@Authenticated({ permission: Permission.StackRead })
|
|
searchStacks(@Auth() auth: AuthDto, @Query() query: StackSearchDto): Promise<StackResponseDto[]> {
|
|
return this.service.search(auth, query);
|
|
}
|
|
|
|
@Post()
|
|
@Authenticated({ permission: Permission.StackCreate })
|
|
createStack(@Auth() auth: AuthDto, @Body() dto: StackCreateDto): Promise<StackResponseDto> {
|
|
return this.service.create(auth, dto);
|
|
}
|
|
|
|
@Delete()
|
|
@Authenticated({ permission: Permission.StackDelete })
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
deleteStacks(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<void> {
|
|
return this.service.deleteAll(auth, dto);
|
|
}
|
|
|
|
@Get(':id')
|
|
@Authenticated({ permission: Permission.StackRead })
|
|
getStack(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<StackResponseDto> {
|
|
return this.service.get(auth, id);
|
|
}
|
|
|
|
@Put(':id')
|
|
@Authenticated({ permission: Permission.StackUpdate })
|
|
updateStack(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: StackUpdateDto,
|
|
): Promise<StackResponseDto> {
|
|
return this.service.update(auth, id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@Authenticated({ permission: Permission.StackDelete })
|
|
deleteStack(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
|
return this.service.delete(auth, id);
|
|
}
|
|
|
|
@Delete(':id/assets/:assetId')
|
|
@Authenticated({ permission: Permission.StackUpdate })
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
removeAssetFromStack(@Auth() auth: AuthDto, @Param() dto: UUIDAssetIDParamDto): Promise<void> {
|
|
return this.service.removeAsset(auth, dto);
|
|
}
|
|
}
|