diff --git a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts index 3b5f208488ca27f0b76f2d90ddb8ab0e1e35c491..3e4d7a1fa12f7180582e0d745977c08d81d55d57 100644 --- a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts +++ b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts @@ -23,7 +23,7 @@ export class CommentSettingsComponent implements OnInit { roomId: string; comments: Comment[]; - commentThreshold: number; + commentThreshold = -10; editRoom: Room; settingThreshold = false; enableCommentModeration = false; diff --git a/src/app/components/creator/room-creator-page/room-creator-page.component.html b/src/app/components/creator/room-creator-page/room-creator-page.component.html index 9c5cb821405d6665bd436b741b7b6673d4142c65..7c3a322e1f66488f58608a6bb1611038ac929af7 100644 --- a/src/app/components/creator/room-creator-page/room-creator-page.component.html +++ b/src/app/components/creator/room-creator-page/room-creator-page.component.html @@ -42,7 +42,7 @@ {{ room.description.trim() }} </h4> </mat-card-content> - <mat-grid-list cols="2" rowHeight="2:1"> + <mat-grid-list cols="{{viewModuleCount}}" rowHeight="2:1"> <mat-grid-tile> <button mat-icon-button routerLink="/creator/room/{{ room.shortId }}/comments"> @@ -51,7 +51,7 @@ <h3>{{ 'room-page.comments' | translate}}</h3> <!-- *ngIf="deviceType === 'desktop'" --> </button> </mat-grid-tile> - <mat-grid-tile> + <mat-grid-tile *ngIf="moderationEnabled"> <button mat-icon-button routerLink="/moderator/room/{{ room.shortId }}/moderator/comments"> <mat-icon matBadge="{{moderatorCommentCounter}}" matBadgeColor="primary" [ngClass]="{'desktop' : deviceType === 'desktop'}">gavel diff --git a/src/app/components/creator/room-creator-page/room-creator-page.component.ts b/src/app/components/creator/room-creator-page/room-creator-page.component.ts index 8f5a0bc142a518d65e644737ba145418012c59e8..0a64a29af2e1fd98456184b8afa661ab1dabf61e 100644 --- a/src/app/components/creator/room-creator-page/room-creator-page.component.ts +++ b/src/app/components/creator/room-creator-page/room-creator-page.component.ts @@ -27,6 +27,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni commentThreshold: number; updCommentThreshold: number; deviceType = localStorage.getItem('deviceType'); + viewModuleCount = 1; constructor(protected roomService: RoomService, protected notification: NotificationService, @@ -49,6 +50,12 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni }); } + afterRoomLoadHook() { + if (this.moderationEnabled) { + this.viewModuleCount = this.viewModuleCount + 1; + } + } + updateGeneralSettings() { this.room.name = this.updRoom.name; this.room.description = this.updRoom.description; @@ -58,13 +65,18 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni updateCommentSettings(settings: CommentSettingsDialog) { const commentExtension: TSMap<string, any> = new TSMap(); this.room.extensions = new TSMap(); + commentExtension.set('enableThreshold', settings.enableThreshold); + commentExtension.set('commentThreshold', settings.threshold); + commentExtension.set('enableModeration', settings.enableModeration); this.room.extensions.set('comments', commentExtension); - if (settings.enableThreshold) { - commentExtension.set('commentThreshold', settings.threshold); - } - if (settings.enableModeration) { - commentExtension.set('enableModeration', settings.enableModeration); + + if (this.moderationEnabled && !settings.enableModeration) { + this.viewModuleCount = this.viewModuleCount - 1; + } else if (!this.moderationEnabled && settings.enableModeration) { + this.viewModuleCount = this.viewModuleCount + 1; } + + this.moderationEnabled = settings.enableModeration; } resetThreshold(): void { @@ -116,9 +128,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni return; } else { if (result instanceof CommentSettingsDialog) { - if (!result.enableThreshold) { - this.resetThreshold(); - } + console.log(result); this.updateCommentSettings(result); this.saveChanges(); } diff --git a/src/app/components/moderator/room-moderator-page/room-moderator-page.component.html b/src/app/components/moderator/room-moderator-page/room-moderator-page.component.html index 7e17a030050fb4cb632d7d84702c962ac27f1f6a..a08b44fcacd107d42c290d003503552c51366a0c 100644 --- a/src/app/components/moderator/room-moderator-page/room-moderator-page.component.html +++ b/src/app/components/moderator/room-moderator-page/room-moderator-page.component.html @@ -20,7 +20,7 @@ <mat-card-content *ngIf="room.description" fxLayoutAlign="center"> <h4>{{room.description.trim()}}</h4> </mat-card-content> - <mat-grid-list cols="2" rowHeight="2:1"> + <mat-grid-list cols="{{viewModuleCount}}" rowHeight="2:1"> <mat-grid-tile> <button mat-icon-button routerLink="/moderator/room/{{ room.shortId }}/comments"> <mat-icon matBadge="{{commentCounter}}" matBadgeColor="primary" @@ -29,7 +29,7 @@ <h3>{{ 'room-page.public-stream' | translate}}</h3> <!-- *ngIf="deviceType === 'desktop'" --> </button> </mat-grid-tile> - <mat-grid-tile> + <mat-grid-tile *ngIf="moderationEnabled"> <button mat-icon-button routerLink="/moderator/room/{{ room.shortId }}/moderator/comments"> <mat-icon matBadge="{{moderatorCommentCounter}}" matBadgeColor="primary" [ngClass]="{'desktop' : deviceType === 'desktop'}">gavel diff --git a/src/app/components/moderator/room-moderator-page/room-moderator-page.component.ts b/src/app/components/moderator/room-moderator-page/room-moderator-page.component.ts index 503ef6c5f25a01e1d0277a857678112f6df545e3..1374b69277d4f4e86f4f42241870b1f898d996d4 100644 --- a/src/app/components/moderator/room-moderator-page/room-moderator-page.component.ts +++ b/src/app/components/moderator/room-moderator-page/room-moderator-page.component.ts @@ -21,6 +21,7 @@ export class RoomModeratorPageComponent extends RoomPageComponent implements OnI isLoading = true; deviceType = localStorage.getItem('deviceType'); moderatorCommentCounter: number; + viewModuleCount = 1; constructor(protected location: Location, @@ -36,6 +37,12 @@ export class RoomModeratorPageComponent extends RoomPageComponent implements OnI initializeRoom(id: string): void { this.roomService.getRoomByShortId(id).subscribe(room => { + if (this.room && this.room.extensions && this.room.extensions['comments']) { + if (this.room.extensions['comments'].enableModeration !== null) { + this.moderationEnabled = this.room.extensions['comments'].enableModeration; + this.viewModuleCount = this.viewModuleCount + 1; + } + } this.room = room; this.isLoading = false; this.commentService.countByRoomId(this.room.id, true) diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 94bde141474f4e0da302093befdbafd11771ffd2..c24f03cd938de5eb3dace51b4a4294ccf5fe3190 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -46,6 +46,8 @@ export class CommentListComponent implements OnInit { searchInput = ''; search = false; searchPlaceholder = ''; + moderationEnabled = false; + thresholdEnabled = false; constructor(private commentService: CommentService, private translateService: TranslateService, @@ -62,7 +64,17 @@ export class CommentListComponent implements OnInit { this.roomId = localStorage.getItem(`roomId`); const userId = this.user.id; this.userRole = this.user.role; - this.roomService.getRoom(this.roomId).subscribe( room => this.room = room); + this.roomService.getRoom(this.roomId).subscribe( room => { + this.room = room; + if (this.room && this.room.extensions && this.room.extensions['comments']) { + if (this.room.extensions['comments'].commentThreshold !== null) { + this.thresholdEnabled = true; + } + if (this.room.extensions['comments'].enableModeration !== null) { + this.moderationEnabled = this.room.extensions['comments'].enableModeration; + } + } + }); this.hideCommentsList = false; this.wsCommentService.getCommentStream(this.roomId).subscribe((message: Message) => { this.parseIncomingMessage(message); @@ -115,7 +127,7 @@ export class CommentListComponent implements OnInit { getComments(): void { this.isLoading = false; let commentThreshold = -10; - if (this.room && this.room.extensions && this.room.extensions['comments']) { + if (this.thresholdEnabled) { commentThreshold = this.room.extensions['comments'].commentThreshold; if (this.hideCommentsList) { this.filteredComments = this.filteredComments.filter( x => x.score >= commentThreshold ); diff --git a/src/app/components/shared/room-page/room-page.component.ts b/src/app/components/shared/room-page/room-page.component.ts index 90a826576bec3708ad1c7096fe93272ef4ab6d81..7e739e63768dbeeed2a035a9c1a15a7c05a8647f 100644 --- a/src/app/components/shared/room-page/room-page.component.ts +++ b/src/app/components/shared/room-page/room-page.component.ts @@ -16,6 +16,7 @@ export class RoomPageComponent implements OnInit { room: Room = null; isLoading = true; commentCounter: number; + protected moderationEnabled = false; constructor(protected roomService: RoomService, protected route: ActivatedRoute, @@ -31,10 +32,19 @@ export class RoomPageComponent implements OnInit { }); } + protected afterRoomLoadHook() { + + } + initializeRoom(id: string): void { this.roomService.getRoomByShortId(id).subscribe(room => { this.room = room; this.isLoading = false; + if (this.room && this.room.extensions && this.room.extensions['comments']) { + if (this.room.extensions['comments'].enableModeration !== null) { + this.moderationEnabled = this.room.extensions['comments'].enableModeration; + } + } this.commentService.countByRoomId(this.room.id, true) .subscribe(commentCounter => { this.commentCounter = commentCounter; @@ -48,6 +58,7 @@ export class RoomPageComponent implements OnInit { this.commentCounter = this.commentCounter - 1; } }); + this.afterRoomLoadHook(); }); }