Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Remove archive enpoints and update PUT endpoint for project

Yehor Dremliuha5bf6a76c80ba
diff --git a/apps/production/src/project/dto/update-project.dto.ts b/apps/production/src/project/dto/update-project.dto.ts
index a6dbcde0c..f08ac2a40 100644
--- a/apps/production/src/project/dto/update-project.dto.ts
+++ b/apps/production/src/project/dto/update-project.dto.ts
@@ -2,6 +2,7 @@ import { IntersectionType, PartialType } from '@nestjs/mapped-types'
import { ApiProperty } from '@nestjs/swagger'
import { ProjectDTO } from './project.dto'
import { ProjectPasswordDto } from './project-password.dto'
+import { IsBoolean, IsOptional } from 'class-validator'
export class UpdateProjectDto extends IntersectionType(
PartialType(ProjectDTO),
@@ -20,4 +21,13 @@ export class UpdateProjectDto extends IntersectionType(
"When true, anyone on the internet (including Google) would be able to see the project's Dashboard.",
})
public?: boolean
+
+ @ApiProperty({
+ required: false,
+ description: "When true, the incoming data will not be gathered for this project"})
+
+ @IsBoolean()
+ @IsOptional()
+ isArchived?: boolean
+
}
diff --git a/apps/production/src/project/project.controller.ts b/apps/production/src/project/project.controller.ts
index fa8181d30..6e6336c24 100644
--- a/apps/production/src/project/project.controller.ts
+++ b/apps/production/src/project/project.controller.ts
@@ -99,7 +99,6 @@ import {
FunnelCreateDTO,
FunnelUpdateDTO,
} from './dto'
-import { ProjectIdDto } from './dto/project-id.dto'
const PROJECTS_MAXIMUM = 50
@@ -1753,6 +1752,10 @@ export class ProjectController {
project.active = projectDTO.active
}
+ if (projectDTO.isArchived) {
+ project.isArchived = projectDTO.isArchived
+ }
+
if (projectDTO.origins) {
project.origins = _map(projectDTO.origins, _trim)
}
@@ -1874,83 +1877,4 @@ export class ProjectController {
}
}
- @ApiOperation({ summary: 'Archive project' })
- @ApiOkResponse({ type: Project })
- @ApiBearerAuth()
- @Post(':projectId/archive')
- @HttpCode(HttpStatus.OK)
- @Auth([], true, true)
- async archiveProject(
- @Param() params: ProjectIdDto,
- @CurrentUserId() userId: string,
- ) {
- const project = await this.projectService.findOneWhere(
- { id: params.projectId },
- { relations: ['admin'] },
- )
-
- if (!project) {
- throw new NotFoundException('Project not found.')
- }
-
- const user = await this.userService.findOneWithRelations(userId, [
- 'projects',
- ])
-
- if (!user) {
- throw new NotFoundException('User not found.')
- }
-
- this.projectService.allowedToManage(project, userId, user.roles)
-
- if (project.isArchived) {
- throw new ConflictException('Project is already archived.')
- }
-
- await this.projectService.updateProject(params.projectId, {
- isArchived: !project.isArchived,
- })
-
- return this.projectService.findOne(params.projectId)
- }
-
- @ApiOperation({ summary: 'Unarchive project' })
- @ApiNoContentResponse()
- @ApiBearerAuth()
- @Delete(':projectId/archive')
- @HttpCode(HttpStatus.NO_CONTENT)
- @Auth([], true, true)
- async unarchiveProject(
- @Param() params: ProjectIdDto,
- @CurrentUserId() userId: string,
- ) {
- const project = await this.projectService.findOneWhere(
- { id: params.projectId },
- { relations: ['admin'] },
- )
-
- if (!project) {
- throw new NotFoundException('Project not found.')
- }
-
- const user = await this.userService.findOneWithRelations(userId, [
- 'projects',
- ])
-
- if (!user) {
- throw new NotFoundException('User not found.')
- }
-
- if (!project.isArchived) {
- throw new ConflictException('Project is unarchived.')
- }
-
- this.projectService.allowedToManage(project, userId, user.roles)
-
- await this.projectService.updateProject(params.projectId, {
- isArchived: !project.isArchived,
- })
-
- return await this.projectService.findOne(params.projectId)
- }
}