diff --git a/srv/src/entities/label.entity.ts b/srv/src/entities/label.entity.ts index 381134d..d4021c4 100644 --- a/srv/src/entities/label.entity.ts +++ b/srv/src/entities/label.entity.ts @@ -17,9 +17,13 @@ export class Label { @Column() authorId: ObjectID; - constructor(projectId: ObjectID, authorId: ObjectID, name: string) { + @Column() + authorClass: string; + + constructor(projectId: ObjectID, authorId: ObjectID, name: string, authorClass: string) { this.projectId = projectId; this.authorId = authorId; this.name = name; + this.authorClass = authorClass; } } diff --git a/srv/src/entities/labelcategory.entity.ts b/srv/src/entities/labelcategory.entity.ts index 045c3c0..4568755 100644 --- a/srv/src/entities/labelcategory.entity.ts +++ b/srv/src/entities/labelcategory.entity.ts @@ -20,10 +20,14 @@ export class LabelCategory { @Column() labels: Label[]; - constructor(projectId: ObjectID, authorId: ObjectID, name: string, labels: Label[]) { + @Column() + authorClass: string; + + constructor(projectId: ObjectID, authorId: ObjectID, name: string, labels: Label[], authorClass: string) { this.projectId = projectId; this.authorId = authorId; this.name = name; this.labels = labels; + this.authorClass = authorClass; } } diff --git a/srv/src/entities/project.entity.ts b/srv/src/entities/project.entity.ts index 93d5efe..9c0a40d 100644 --- a/srv/src/entities/project.entity.ts +++ b/srv/src/entities/project.entity.ts @@ -1,6 +1,7 @@ import { Column, Entity, ObjectIdColumn } from 'typeorm'; import { Directory } from './directory.entity'; import { ObjectID } from 'mongodb'; +import { User } from './user.entity'; @Entity() export class Project { @@ -12,10 +13,13 @@ export class Project { title: string; @Column() - ownerId: ObjectID; + ownerId: User; @Column() - memberIds: ObjectID[]; + supervisorIds: User[]; + + @Column() + contributorIds: User[]; @Column() description: string; diff --git a/srv/src/entities/segment.entity.ts b/srv/src/entities/segment.entity.ts index 65cee28..2f2147a 100644 --- a/srv/src/entities/segment.entity.ts +++ b/srv/src/entities/segment.entity.ts @@ -18,10 +18,14 @@ export class Segment { @Column() labelId: ObjectID; - constructor(labelId: ObjectID, authorId: ObjectID, start: number, end: number) { + @Column() + authorClass: string; + + constructor(labelId: ObjectID, authorId: ObjectID, start: number, end: number, authorClass: string) { this.labelId = labelId; this.authorId = authorId; this.start = start; this.end = end; + this.authorClass = authorClass; } } diff --git a/srv/src/labels/labels.gateway.ts b/srv/src/labels/labels.gateway.ts index ae7e948..d950e64 100644 --- a/srv/src/labels/labels.gateway.ts +++ b/srv/src/labels/labels.gateway.ts @@ -62,19 +62,18 @@ export class LabelsGateway { @SubscribeMessage('addLabel') async addLabel(socket: SocketIO.Socket, data) { const room = LabelsGateway.getProjectRoom(socket); - return await this.labelsService.createLabel(room, data.aid, data.cid) - .then(async (value: InsertResult) => { - const id = value.identifiers[0].id; - const newLabel: Label = await this.labelsService.getLabel(id); - socket.to(room).broadcast.emit('newLabels', newLabel); - return newLabel; + return await this.labelsService.createLabel(room, data.aid, data.cid, data.authorClass) + .then(async (value: Label) => { + value['categoryId'] = data.cid; + socket.to(room).broadcast.emit('newLabels', value); + return value; }); } @SubscribeMessage('addLabelCategory') async addLabelCategory(socket: SocketIO.Socket, data) { const room = LabelsGateway.getProjectRoom(socket); - return await this.labelsService.createLabelCategory(room, data.aid) + return await this.labelsService.createLabelCategory(room, data.aid, data.authorClass) .then(async (value: InsertResult) => { const id = value.identifiers[0].id; const newLabelCategory: LabelCategory = await this.labelsService.getLabelCategory(id); @@ -157,9 +156,10 @@ export class LabelsGateway { const authorId = ''; const start = data.start; const end = data.end; + const authorClass = data.authorClass; const hyperid = data.hyperid; return await this.segmentService - .createSegment(labelId, authorId, start, end) + .createSegment(labelId, authorId, start, end, authorClass) .then(() => { return false; }, () => { diff --git a/srv/src/labels/labels.service.ts b/srv/src/labels/labels.service.ts index 37cb6be..36aba14 100644 --- a/srv/src/labels/labels.service.ts +++ b/srv/src/labels/labels.service.ts @@ -12,18 +12,21 @@ export class LabelsService { private readonly labelCategoryRepository: MongoRepository) { } - async createLabel(projectId: string, authorId: string, categoryId: string): Promise { - let labelCategory = await this.labelCategoryRepository.findOne(categoryId); - const label = new Label(projectId, authorId, labelCategory.name+'_'+(labelCategory.labels.length + 1)); - return await this.labelRepository.insert(label); + async createLabel(projectId: string, authorId: string, categoryId: string, authorClass: string): Promise