Skip to content

Commit

Permalink
Merge branch 'test-frontend'
Browse files Browse the repository at this point in the history
  • Loading branch information
TineCrnugelj committed Apr 25, 2023
2 parents fff118a + f14b4db commit b8c3f69
Show file tree
Hide file tree
Showing 138 changed files with 12,782 additions and 2,239 deletions.
2 changes: 1 addition & 1 deletion backend/config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

# API docs
#DOCS=false
DOCS=true

# API docs path
#DOC_PATH=doc
Expand Down
2,763 changes: 1,252 additions & 1,511 deletions backend/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"compression": "^1.7.4",
"helmet": "^6.0.1",
"joi": "^17.8.3",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"mysql2": "^3.2.0",
"otplib": "^12.0.1",
"passport": "^0.6.0",
Expand Down
1 change: 0 additions & 1 deletion backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Module } from '@nestjs/common';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { ServeStaticModule } from '@nestjs/serve-static';
import { TypeOrmModule } from '@nestjs/typeorm';

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AuthModule } from './auth/auth.module';
Expand Down
6 changes: 6 additions & 0 deletions backend/src/custom-config/config.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ export const ConfigSchema: Joi.ObjectSchema = Joi.object().keys({
JWT_PUBLIC_KEY_PATH: Joi.string(),
JWT_PRIVATE_KEY_PATH: Joi.string(),
JWT_ACCESS_TOKEN_EXPIRE: Joi.allow(Joi.string(), Joi.number()).default('1h'),

/**
* Bussines logic validation parameters
*/
PERSON_HOURS_PER_DAY: Joi.number().min(0).default(8),
PERSON_MAX_LOAD_FACTOR: Joi.number().min(0).default(1.5),
});
1 change: 1 addition & 0 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async function bootstrap() {
.addTag('common-password', 'Common password')
.addTag('health', 'Healthcheck')
.addTag('user', 'User')
.addTag('planning-pocker', 'Story planning pocker')
.addTag('project', 'Project')
.addTag('sprint', 'Sprint')
.addTag('story', 'Story')
Expand Down
17 changes: 17 additions & 0 deletions backend/src/notification-comments/wallNotification.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { ProjectWallNotification } from '../project-wall-notification/project-wall-notification.entity';

@Entity()
export class NotificationComment {
@PrimaryGeneratedColumn({ unsigned: true })
id: number;

@Column({ type: 'text' })
comment: string;

@Column({ unsigned: true, nullable: true })
projectWallNotificationId: number;

@ManyToOne(type => ProjectWallNotification, notification => notification.comments, { onUpdate: 'CASCADE', onDelete: 'CASCADE' })
notifications: ProjectWallNotification;
}
30 changes: 30 additions & 0 deletions backend/src/project-wall-notification-comment/comment.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
import { User } from '../user/user.entity';
import { ProjectWallNotification } from '../project-wall-notification/project-wall-notification.entity';

@Entity()
export class ProjectWallNotificationComment {
@PrimaryGeneratedColumn({ unsigned: true })
id: number;

@Column({ length: 200 })
author: string;

@Column({ unsigned: true, type: 'int' })
projectWallNotificationId: number;

@Column({ unsigned: true, type: 'int' })
userId: number;

@ManyToOne(type => ProjectWallNotification, project => project.comments, { onUpdate: 'CASCADE', onDelete: 'CASCADE' })
projectWallNotification: ProjectWallNotification;

@Column({ type: 'text' })
content: string;

@Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
created: string;

@ManyToOne(type => User, user => user.projectWallNotificationComments)
user: User;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ApiProperty } from '@nestjs/swagger';
import * as Joi from 'joi';

export class CreateProjectWallNotificationCommentDto {

@ApiProperty({
example: 'Post content.',
description: 'Post content.',
minLength: 1,
type: String,
required: true
})
content: string;

@ApiProperty({
example: 'shanji',
description: 'Authors username',
minLength: 1,
maxLength: 200,
type: String,
required: true
})
author: string;

@ApiProperty({
description: 'User id.',
example: 1,
minimum: 1,
default: 1,
type: Number,
required: true
})
userId: number;
}

export const CreateProjectWallNotificationCommentSchema = Joi.object().keys({
content: Joi.string().min(1).required().default('Work on a project.'),
author: Joi.string().min(1).max(200).default('shanji'),
userId: Joi.number().min(1).required().default(1)
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class ProjectWallNotificationCommentDto {
id: number;
author: string;
projectWallNotificationId: number;
userId: number;
content: string;
created: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ProjectWallNotificationComment } from './comment.entity';
import { ProjectWallNotificationCommentService } from './project-wall-notification-comment.service';

@Module({
imports: [
TypeOrmModule.forFeature([
ProjectWallNotificationComment
]),
],
providers: [
ProjectWallNotificationCommentService
],
exports: [
ProjectWallNotificationCommentService
]
})
export class ProjectWallNotificationCommentModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ConflictException, Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { InjectEntityManager } from '@nestjs/typeorm';
import { DeepPartial, EntityManager, In, Not, QueryFailedError } from 'typeorm';
import { ProjectWallNotificationComment } from './comment.entity';
import { CreateProjectWallNotificationCommentDto } from './dto/create-notification-comment.dto';

@Injectable()
export class ProjectWallNotificationCommentService {
private readonly logger: Logger = new Logger(ProjectWallNotificationCommentService.name);

constructor(
private readonly configService: ConfigService,
@InjectEntityManager()
private readonly entityManager: EntityManager,
) { }

async getAll(): Promise<ProjectWallNotificationComment[]> {
return await this.entityManager.find(ProjectWallNotificationComment);
}

async createNotificationComment(projectWallNotification: CreateProjectWallNotificationCommentDto, notificationId: number, userId: number): Promise<void> {
await this.entityManager.insert(ProjectWallNotificationComment, this.createProjectWallNotificationObject(projectWallNotification, notificationId, userId));
}

async getProjectWallNotificationById(projectWallNotificationCommentId: number): Promise<ProjectWallNotificationComment> {
return await this.entityManager.findOneBy(ProjectWallNotificationComment, { id: projectWallNotificationCommentId });
}

async getProjectWallNotificationByProjectId(notificationId: number): Promise<ProjectWallNotificationComment[]> {
return await this.entityManager.findBy(ProjectWallNotificationComment, { projectWallNotificationId: notificationId });
}

async deleteProjectWallNotificationComment(commentId: number) {
return await this.entityManager.delete(ProjectWallNotificationComment, { id: commentId });
}

async deleteProjectWallNotificationByProjectId(notificationId: number) {
return await this.entityManager.delete(ProjectWallNotificationComment, { projectWallNotificationId: notificationId });
}

createProjectWallNotificationObject(projectWallNotificationComment: CreateProjectWallNotificationCommentDto, NotificationId: number, userId): ProjectWallNotificationComment {
let projectNotificationCommentObject = new ProjectWallNotificationComment();
projectNotificationCommentObject.author = projectWallNotificationComment.author;
projectNotificationCommentObject.content = projectWallNotificationComment.content;
projectNotificationCommentObject.projectWallNotificationId = NotificationId
projectNotificationCommentObject.userId = userId;
return projectNotificationCommentObject;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ApiProperty } from '@nestjs/swagger';
import * as Joi from 'joi';

export class CreateProjectWallNotificationDto {

@ApiProperty({
example: 'Title.',
description: 'Title.',
minLength: 1,
type: String,
required: true
})
title: string;

@ApiProperty({
example: 'Post content.',
description: 'Post content.',
minLength: 1,
type: String,
required: true
})
postContent: string;

@ApiProperty({
example: 'shanji',
description: 'Authors username',
minLength: 1,
maxLength: 200,
type: String,
required: true
})
author: string;

@ApiProperty({
description: 'User id.',
example: 1,
minimum: 1,
default: 1,
type: Number,
required: true
})
userId: number;
}

export const CreateProjectWallNotificationSchema = Joi.object().keys({
title: Joi.string().min(1).max(200).required().default('Work on a project.'),
postContent: Joi.string().min(1).required().default('Work on a project.'),
author: Joi.string().min(1).max(200).default('shanji'),
userId: Joi.number().min(1).required().default(1)
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ProjectWallNotificationCommentDto } from "../../project-wall-notification-comment/dto/project-wall-notification-comment.dto";

export class ProjectWallNotificationDto {
id: number;
author: string;
title: string;
projectId: number;
userId: number;
postContent?: string | null;
created: string;
comments: ProjectWallNotificationCommentDto[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
import { Project } from '../project/project.entity';
import { User } from '../user/user.entity';
import { ProjectWallNotificationComment } from '../project-wall-notification-comment/comment.entity';

@Entity()
export class ProjectWallNotification {
@PrimaryGeneratedColumn({ unsigned: true })
id: number;

@Column({ length: 200 })
author: string;

@Column({ length: 200 })
title: string;

@Column({ unsigned: true, type: 'int' })
projectId: number;

@Column({ unsigned: true, type: 'int' })
userId: number;

@ManyToOne(type => Project, project => project.wallNotifications, { onUpdate: 'CASCADE', onDelete: 'CASCADE' })
project: Project;

@Column({ type: 'text', nullable: true })
postContent?: string | null;

@Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
created: string;

@OneToMany(type => ProjectWallNotificationComment, comment => comment.projectWallNotification)
comments: ProjectWallNotificationComment[];

@ManyToOne(type => User, user => user.projectWallNotifications)
user: User;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ProjectWallNotification } from './project-wall-notification.entity';
import { ProjectWallNotificationService } from './project-wall-notification.service';
import { ProjectWallNotificationCommentModule } from '../project-wall-notification-comment/project-wall-notification-comment.module';

@Module({
imports: [
TypeOrmModule.forFeature([
ProjectWallNotification
]),
ProjectWallNotificationCommentModule
],
providers: [
ProjectWallNotificationService
],
exports: [
ProjectWallNotificationService
]
})
export class ProjectWallNotificationModule { }
Loading

0 comments on commit b8c3f69

Please sign in to comment.