diff --git a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html index 35c0f0bf072e914cff48b411e4e84c62bfeaf805..4681fb59a72181f610e00b2641d79d0ce621da93 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html +++ b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.html @@ -11,7 +11,7 @@ <mat-label class="color-on-surface"> {{"topic-cloud-dialog.select-choice" | translate}} </mat-label> - <mat-radio-group class="radio-button-group" [(ngModel)]="keywordORfulltext"> + <mat-radio-group class="radio-button-group" (change)=(updateKeywords()) [(ngModel)]="keywordORfulltext"> <mat-radio-button checked="true" [value]="keywordOrFulltextENUM[0]" class="radio-button-item"> {{"topic-cloud-dialog.keyword" | translate}} </mat-radio-button> @@ -27,81 +27,86 @@ <mat-slide-toggle [(ngModel)]="considerVotes"> {{'topic-cloud-dialog.consider-votes' | translate}} </mat-slide-toggle> - <mat-slide-toggle (change)="refreshAllLists()" [(ngModel)]="profanityFilter"> - {{'topic-cloud-dialog.profanity' | translate}} - </mat-slide-toggle> - <mat-slide-toggle [(ngModel)]="blacklistIsActive"> - {{'topic-cloud-dialog.hide-blacklist-words' | translate}} - </mat-slide-toggle> + <div *ngIf="isCreatorOrMod"> + <mat-slide-toggle (change)="refreshAllLists()" [(ngModel)]="profanityFilter"> + {{'topic-cloud-dialog.profanity' | translate}} + </mat-slide-toggle> + <mat-slide-toggle [(ngModel)]="blacklistIsActive"> + {{'topic-cloud-dialog.hide-blacklist-words' | translate}} + </mat-slide-toggle> + </div> <mat-accordion class="new-profanity-word" multi> - <mat-expansion-panel class="color-background" (opened)="enterProfanityWord=true; focusInput('bad-word-input')" - (closed)="enterProfanityWord = false"> - <mat-expansion-panel-header class="color-background"> - <mat-panel-title> - {{'topic-cloud-dialog.edit-profanity-list' | translate}} - </mat-panel-title> - </mat-expansion-panel-header> + <div *ngIf="isCreatorOrMod"> + <mat-expansion-panel class="color-background" (opened)="enterProfanityWord=true; focusInput('bad-word-input')" + (closed)="enterProfanityWord = false"> + <mat-expansion-panel-header class="color-background"> + <mat-panel-title> + {{'topic-cloud-dialog.edit-profanity-list' | translate}} + </mat-panel-title> + </mat-expansion-panel-header> - <mat-form-field> - <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> - <input matInput id="bad-word-input" [(ngModel)]="newProfanityWord"> - </mat-form-field> + <mat-form-field> + <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> + <input matInput id="bad-word-input" [(ngModel)]="newProfanityWord"> + </mat-form-field> - <button mat-stroked-button color="primary" class="margin-left" (click)="addProfanityWord()"> - {{'topic-cloud-dialog.add-word' | translate}} - </button> + <button mat-stroked-button class="margin-left color-on-background" (click)="addProfanityWord()"> + {{'topic-cloud-dialog.add-word' | translate}} + </button> + + <mat-list role="list" *ngIf="showProfanityList" class="margin-bottom"> + <mat-list-item class="color-on-surface" *ngFor="let word of getProfanityList()" role="listitem">{{word}} + <button style="margin-left: auto" mat-icon-button class="red" + (click)="removeWordFromProfanityList(word)"> + <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> + </button> + </mat-list-item> + </mat-list> - <mat-list role="list" *ngIf="showProfanityList" class="margin-bottom"> - <mat-list-item class="color-on-surface" *ngFor="let word of getProfanityList()" role="listitem">{{word}} - <button style="margin-left: auto" mat-icon-button class="red" (click)="removeWordFromProfanityList(word)"> - <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> + <div> + <button mat-raised-button *ngIf="getProfanityList().length > 0" class="primaryBackground" + (click)="showProfanityList=!showProfanityList"> + {{showProfanityList ? ('topic-cloud-dialog.hide-profanity-list' | translate) : + ('topic-cloud-dialog.show-profanity-list' | translate)}} </button> - </mat-list-item> - </mat-list> - - <div> - <button mat-raised-button *ngIf="getProfanityList().length > 0" class="primaryBackground" - (click)="showProfanityList=!showProfanityList"> - {{showProfanityList ? ('topic-cloud-dialog.hide-profanity-list' | translate) : - ('topic-cloud-dialog.show-profanity-list' | translate)}} - </button> - </div> - </mat-expansion-panel> + </div> + </mat-expansion-panel> - <mat-expansion-panel class="color-background margin-bottom" - (opened)="enterBlacklistWord = true; focusInput('blacklist-word-input')" - (closed)="enterBlacklistWord = false"> - <mat-expansion-panel-header class="color-background"> - <mat-panel-title> - {{'topic-cloud-dialog.edit-blacklist-list' | translate}} - </mat-panel-title> - </mat-expansion-panel-header> + <mat-expansion-panel class="color-background margin-bottom" + (opened)="enterBlacklistWord = true; focusInput('blacklist-word-input')" + (closed)="enterBlacklistWord = false"> + <mat-expansion-panel-header class="color-background"> + <mat-panel-title> + {{'topic-cloud-dialog.edit-blacklist-list' | translate}} + </mat-panel-title> + </mat-expansion-panel-header> - <mat-form-field> - <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> - <input matInput id="blacklist-word-input" [(ngModel)]="newBlacklistWord"> - </mat-form-field> + <mat-form-field> + <mat-label>{{'topic-cloud-dialog.enter-word' | translate}}</mat-label> + <input matInput id="blacklist-word-input" [(ngModel)]="newBlacklistWord"> + </mat-form-field> - <button mat-stroked-button color="primary" class="margin-left" (click)="addBlacklistWord()"> - {{'topic-cloud-dialog.add-word' | translate}} - </button> - <mat-list role="list" *ngIf="showBlacklistWordList && blacklist.length > 0" class="margin-bottom"> - <mat-list-item class="color-on-surface" *ngFor="let word of blacklist" role="listitem">{{word}} - <button style="margin-left: auto" mat-icon-button class="red" (click)="removeWordFromBlacklist(word)"> - <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> - </button> - </mat-list-item> - </mat-list> - - <div> - <button mat-raised-button class="primaryBackground" *ngIf="blacklist.length > 0" - (click)="showBlacklistWordList=!showBlacklistWordList"> - {{showBlacklistWordList ? ('topic-cloud-dialog.hide-blacklist' | translate) : - ('topic-cloud-dialog.show-blacklist' | translate)}} + <button mat-stroked-button class="margin-left color-on-background" (click)="addBlacklistWord()"> + {{'topic-cloud-dialog.add-word' | translate}} </button> - </div> - </mat-expansion-panel> + <mat-list role="list" *ngIf="showBlacklistWordList && blacklist.length > 0" class="margin-bottom"> + <mat-list-item class="color-on-surface" *ngFor="let word of blacklist" role="listitem">{{word}} + <button style="margin-left: auto" mat-icon-button class="red" (click)="removeWordFromBlacklist(word)"> + <mat-icon mat-list-icon style="margin-bottom: 6px;">delete</mat-icon> + </button> + </mat-list-item> + </mat-list> + + <div> + <button mat-raised-button class="primaryBackground" *ngIf="blacklist.length > 0" + (click)="showBlacklistWordList=!showBlacklistWordList"> + {{showBlacklistWordList ? ('topic-cloud-dialog.hide-blacklist' | translate) : + ('topic-cloud-dialog.show-blacklist' | translate)}} + </button> + </div> + </mat-expansion-panel> + </div> <mat-expansion-panel class="color-background"> <mat-expansion-panel-header class="color-background"> <mat-panel-title> @@ -113,7 +118,7 @@ <mat-tab label="{{'topic-cloud-dialog.german' | translate}}"> <mat-selection-list *ngIf="wantedLabels" [(ngModel)]="wantedLabels.de"> - <mat-option class="color-on-surface" (click)="selectAllDE(); allSelectedDE = !allSelectedDE"> + <mat-option class="color-on-surface" (click)="selectAllDE()"> <mat-label> <mat-icon>playlist_add_check</mat-icon> {{'topic-cloud-dialog.select-all' | translate}} @@ -128,7 +133,7 @@ <mat-tab label="{{'topic-cloud-dialog.english' | translate}}"> <mat-selection-list *ngIf="wantedLabels" [(ngModel)]="wantedLabels.en"> - <mat-option class="color-on-surface" (click)="selectAllEN(); allSelectedEN = !allSelectedEN"> + <mat-option class="color-on-surface" (click)="selectAllEN()"> <mat-label> <mat-icon>playlist_add_check</mat-icon> {{'topic-cloud-dialog.select-all' | translate}} @@ -151,7 +156,7 @@ <mat-icon>search</mat-icon> </mat-label> <div style="margin-left: 10px; margin-top: 6px;"> - <mat-form-field [ngClass]="{'search': searchMode}"> + <mat-form-field [ngClass]="{'search': searchMode, 'smallerInput': deviceType === 'mobile'}"> <input #searchBox class="searchBox" (input)="searchKeyword()" [(ngModel)]="searchedKeyword" matInput type="text" placeholder="{{'topic-cloud-dialog.keyword-search' | translate}}"> <button *ngIf="searchedKeyword" (click)="searchedKeyword = ''; searchMode = false;" mat-button matSuffix @@ -162,15 +167,15 @@ </div> <div fxLayoutAlign="center center" style="margin-left: auto; font-weight: bold;"> - <mat-icon svgIcon="hashtag" - [ngClass]="{'animation-blink': searchMode}" - class="oldtypo-h2 comment_tag-icon"></mat-icon> - <p [ngClass]="{'animation-blink': searchMode}">{{searchMode ? filteredKeywords.length : + <mat-icon [ngClass]="{'animation-blink': searchMode}" class="oldtypo-h2 comment_tag-icon" + matTooltip="{{'topic-cloud-dialog.keyword-counter' | translate}}">tag</mat-icon> + <p [ngClass]="{'animation-blink': searchMode}" matTooltip="{{'topic-cloud-dialog.keyword-counter' | translate}}"> + {{searchMode ? filteredKeywords.length : keywords.length}}</p> </div> <div class="margin-left vertical-center"> <button [ngClass]="{'animation-blink': sortMode!=='alphabetic'}" mat-icon-button [matMenuTriggerFor]="sortMenu"> - <mat-icon>sort</mat-icon> + <mat-icon matTooltip="{{'topic-cloud-dialog.sort' | translate}}">sort</mat-icon> </button> </div> </div> @@ -217,34 +222,36 @@ [isCollapsed]="!panelOpenState" [profanityFilter]="profanityFilter"></app-topic-dialog-comment> </div> - <!-- Only visible when not editing --> - <div *ngIf="!edit" align="end"> - <mat-divider></mat-divider> - - <button class="margin-right" mat-icon-button style="align-self:flex-end;" (click)="editKeyword(i)"> - <mat-icon class="primary">edit</mat-icon> - </button> - <button class="margin-right" mat-icon-button style="align-self:flex-end;" - (click)="openConfirmDialog('delete-message','delete',keyword)"> - <mat-icon class="red">delete</mat-icon> - </button> - </div> + <div *ngIf="isCreatorOrMod"> + <!-- Only visible when not editing --> + <div *ngIf="!edit" align="end"> + <mat-divider></mat-divider> + <button class="margin-right" mat-icon-button style="align-self:flex-end;" (click)="editKeyword(i)"> + <mat-icon class="primary" matTooltip="{{'topic-cloud-dialog.edit' | translate}}">edit</mat-icon> + </button> + <button class="margin-right" mat-icon-button style="align-self:flex-end;" + (click)="openConfirmDialog('delete-message','delete',keyword)"> + <mat-icon class="red" matTooltip="{{'topic-cloud-dialog.delete' | translate}}">delete</mat-icon> + </button> + </div> - <!-- Only visible when editing --> - <div *ngIf="edit"> - <mat-divider></mat-divider> - <mat-form-field> - <mat-label>{{'topic-cloud-dialog.edit-keyword-tip' | translate}}</mat-label> - <input matInput id="{{'edit-input'+i}}" [(ngModel)]="newKeyword"> - </mat-form-field> - <!-- TODO: textinput and buttons in one row --> - <div align="end"> - <button mat-raised-button class="redBackground margin-right" - (click)="cancelEdit()">{{'topic-cloud-dialog.cancel' | translate}}</button> - <button mat-raised-button class="primaryBackground" (click)="confirmEdit(keyword)">{{'topic-cloud-dialog.save' - | translate}}</button> + <!-- Only visible when editing --> + <div *ngIf="edit"> + <mat-divider></mat-divider> + <mat-form-field> + <mat-label>{{'topic-cloud-dialog.edit-keyword-tip' | translate}}</mat-label> + <input matInput id="{{'edit-input'+i}}" [(ngModel)]="newKeyword"> + </mat-form-field> + <!-- TODO: textinput and buttons in one row --> + <div align="end"> + <button mat-raised-button class="redBackground margin-right" + (click)="cancelEdit()">{{'topic-cloud-dialog.cancel' | translate}}</button> + <button mat-raised-button class="primaryBackground" + (click)="confirmEdit(keyword)">{{'topic-cloud-dialog.save' + | translate}}</button> + </div> </div> </div> </mat-expansion-panel> </mat-accordion> -</mat-dialog-content> +</mat-dialog-content> \ No newline at end of file diff --git a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.scss b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.scss index c283bcb67cc19596c035738be223da967e7815ce..d725531488544c006202dcd5dae899b9fd729d18 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.scss +++ b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.scss @@ -62,6 +62,10 @@ mat-list-item:hover { color: var(--on-surface); } +.color-on-background { + color: var(--on-background); +} + .search { box-sizing: border-box; padding: 0 10px 0 5px; @@ -74,6 +78,10 @@ mat-list-item:hover { transition: width 300ms linear; } +.smallerInput{ + max-width: 100px; +} + label { color: var(--on-surface) } diff --git a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts index 4540506808389e7cdfe49e046a9a3562d4b4b4d9..4150e7ab4b9bcc8cecfb1c5a1cb2358842cd08b9 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts +++ b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts @@ -37,14 +37,13 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { sortMode = 'alphabetic'; searchedKeyword = undefined; searchMode = false; + deviceType: string; filteredKeywords: Keyword[] = []; showProfanityList = false; showBlacklistWordList = false; showSettingsPanel = false; keywordORfulltext: string = undefined; userRole: UserRole; - allSelectedDE = true; - allSelectedEN = true; spacyLabels: Labels; wantedLabels: { de: string[]; @@ -70,14 +69,15 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { } ngOnInit(): void { - this.wsCommentServiceService.getCommentStream(localStorage.getItem('roomId')).subscribe(_ => this.initKeywords()); + this.deviceType = localStorage.getItem('deviceType'); + this.wsCommentServiceService.getCommentStream(localStorage.getItem('roomId')).subscribe(_ => this.updateKeywords()); this.blacklistSubscription = this.topicCloudAdminService.getBlacklist().subscribe(list => this.blacklist = list); - this.isCreatorOrMod = this.data ? (this.data.user.role !== UserRole.PARTICIPANT) : true; + this.isCreatorOrMod = this.data.user.role !== UserRole.PARTICIPANT; this.translateService.use(localStorage.getItem('currentLang')); this.spacyLabels = spacyLabels; this.wantedLabels = undefined; this.setDefaultAdminData(); - this.initKeywords(); + this.updateKeywords(); } ngOnDestroy(){ @@ -87,11 +87,21 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { } } - initKeywords(){ + updateKeywords(){ this.commentService.getFilteredComments(localStorage.getItem('roomId')).subscribe(comments => { this.keywords = []; comments.map(comment => { - const keywords = this.keywordORfulltext === KeywordOrFulltext[0] ? comment.keywordsFromQuestioner : comment.keywordsFromSpacy; + let keywords = comment.keywordsFromQuestioner; + if (this.keywordORfulltext === KeywordOrFulltext[KeywordOrFulltext.keyword]){ + keywords = comment.keywordsFromSpacy; + } else if (this.keywordORfulltext === KeywordOrFulltext[KeywordOrFulltext.both]){ + keywords = comment.keywordsFromQuestioner.concat(comment.keywordsFromSpacy); + } + + if (!keywords){ + keywords = []; + } + keywords.map(_keyword => { const existingKey = this.checkIfKeywordExists(_keyword); if (existingKey){ @@ -348,24 +358,24 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { } selectAllDE() { - if (this.allSelectedDE) { - this.wantedLabels.de = [] - } else { + if (this.wantedLabels.de.length < this.spacyLabels.de.length) { this.wantedLabels.de = []; this.spacyLabels.de.forEach(label => { this.wantedLabels.de.push(label.tag); }); + } else { + this.wantedLabels.de = []; } } selectAllEN() { - if (this.allSelectedEN) { + if (this.wantedLabels.en.length < this.spacyLabels.en.length) { this.wantedLabels.en = []; this.spacyLabels.en.forEach(label => { this.wantedLabels.en.push(label.tag); }); } else { - this.wantedLabels.en = [] + this.wantedLabels.en = []; } } } diff --git a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts index 73b5b508b750e6094a9fe7492bffe5c3b29d7d75..0b9fabd09ec1d5f346d5053781666fd1eb650de9 100644 --- a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts +++ b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts @@ -6,7 +6,7 @@ import { TopicCloudAdminService } from '../../../../services/util/topic-cloud-ad templateUrl: './topic-dialog-comment.component.html', styleUrls: ['./topic-dialog-comment.component.scss'] }) -export class TopicDialogCommentComponent implements OnInit, OnChanges { +export class TopicDialogCommentComponent implements OnInit { @Input() question: string; @Input() keyword: string ; @@ -15,29 +15,27 @@ export class TopicDialogCommentComponent implements OnInit, OnChanges { @Input() profanityFilter = true; public badWords = []; - questionWithProfinity: string = undefined; + questionWithoutProfanity: string = undefined; public shortQuestion: string; + public parts: string[]; + public partsWithoutProfanity: string[]; constructor(private topicCloudAdminService: TopicCloudAdminService) { } - ngOnChanges(changes: SimpleChanges) { - } - get partsOfQuestion() { if (this.profanityFilter) { - const question = this.topicCloudAdminService.filterProfanityWords(this.question); - return question - .slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters) - .split(new RegExp(this.keyword,'i')); + return this.partsWithoutProfanity; } else { - return this.question - .slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters) - .split(new RegExp(this.keyword,'i')); + return this.parts; } } ngOnInit(): void { - this.questionWithProfinity = this.topicCloudAdminService.filterProfanityWords(this.question); + this.questionWithoutProfanity = this.topicCloudAdminService.filterProfanityWords(this.question); + this.partsWithoutProfanity = this.questionWithoutProfanity.slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters) + .split(new RegExp(this.keyword,'i')); + this.parts = this.question.slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters) + .split(new RegExp(this.keyword,'i')); } } diff --git a/src/app/services/util/topic-cloud-admin.service.ts b/src/app/services/util/topic-cloud-admin.service.ts index 6fe470befa0fb87ad3aa1aab50fb33a888f56fcb..2eb50526ba23d6c965d51cbb8444d610682d1469 100644 --- a/src/app/services/util/topic-cloud-admin.service.ts +++ b/src/app/services/util/topic-cloud-admin.service.ts @@ -46,7 +46,7 @@ export class TopicCloudAdminService { }, considerVotes: false, profanityFilter: true, - blacklistIsActive: false, + blacklistIsActive: true, keywordORfulltext: KeywordOrFulltext.keyword }; } @@ -56,35 +56,25 @@ export class TopicCloudAdminService { setAdminData(_adminData: TopicCloudAdminData) { localStorage.setItem(this.adminKey, JSON.stringify(_adminData)); this.getBlacklist().subscribe(list => { - _adminData.blacklist = this.getCustomProfanityList().concat(list).concat(this.profanityWords); + _adminData.blacklist = []; + if (_adminData.profanityFilter){ + _adminData.blacklist = this.getCustomProfanityList().concat(this.profanityWords); + } + if (_adminData.blacklistIsActive){ + _adminData.blacklist.concat(list); + } this.adminData.next(_adminData); }); } getBlacklist(): Observable<string[]> { - // TODO: add watcher for another moderators this.getRoom().subscribe(room => { - this.blacklist.next(JSON.parse(room.blacklist)); + const list = room.blacklist ? JSON.parse(room.blacklist) : []; + this.blacklist.next(list); }); return this.blacklist.asObservable(); } - filterProfanityWords(str: string): string { - let questionWithProfanity = str; - this.profanityWords.concat(this.getCustomProfanityList()).map((word) => { - questionWithProfanity = questionWithProfanity - .toLowerCase() - .includes(word.toLowerCase()) - ? this.replaceString( - questionWithProfanity.toLowerCase(), - word.toLowerCase(), - this.generateCensoredWord(word.length) - ) - : questionWithProfanity; - }); - return questionWithProfanity; - } - getCustomProfanityList(): string[] { const list = localStorage.getItem(this.profanityKey); return list ? list.split(',') : []; @@ -123,8 +113,10 @@ export class TopicCloudAdminService { if (word !== undefined) { this.getRoom().subscribe(room => { const newlist = JSON.parse(room.blacklist); - newlist.push(word); - this.updateBlacklist(newlist, room); + if (!newlist.includes(word)){ + newlist.push(word.toLowerCase()); + } + this.updateBlacklist(newlist, room, 'add-successful'); }); } } @@ -135,22 +127,24 @@ export class TopicCloudAdminService { if (room.blacklist.length > 0){ const newlist = JSON.parse(room.blacklist); newlist.splice(newlist.indexOf(word, 0), 1); - this.updateBlacklist(newlist, room); + this.updateBlacklist(newlist, room, 'remove-successful'); } }); } } - updateBlacklist(list: string[], room: Room){ + updateBlacklist(list: string[], room: Room, msg?: string) { room.blacklist = JSON.stringify(list); - this.updateRoom(room); + this.updateRoom(room, msg); } - updateRoom(updatedRoom: Room){ + updateRoom(updatedRoom: Room, message?: string) { this.roomService.updateRoom(updatedRoom).subscribe(_ => { - this.translateService.get('topic-cloud.changes-successful').subscribe(msg => { + if (!message) { + message = 'changes-successful'; + } + this.translateService.get('topic-cloud.' + message).subscribe(msg => { this.notificationService.show(msg); - /* update blacklist for subscribers */ this.blacklist.next(JSON.parse(updatedRoom.blacklist)); }); }, @@ -162,7 +156,7 @@ export class TopicCloudAdminService { } getDefaultSpacyTagsDE(): string[] { - let tags: string[] = []; + const tags: string[] = []; spacyLabels.de.forEach(label => { tags.push(label.tag); }); @@ -170,15 +164,31 @@ export class TopicCloudAdminService { } getDefaultSpacyTagsEN(): string[] { - let tags: string[] = []; + const tags: string[] = []; spacyLabels.en.forEach(label => { tags.push(label.tag); }); return tags; } + filterProfanityWords(str: string): string { + let questionWithProfanity = str; + this.profanityWords.concat(this.getCustomProfanityList()).map((word) => { + questionWithProfanity = questionWithProfanity + .toLowerCase() + .includes(word.toLowerCase()) + ? this.replaceString( + questionWithProfanity, + word, + this.generateCensoredWord(word.length) + ) + : questionWithProfanity; + }); + return questionWithProfanity; + } + private replaceString(str: string, search: string, replace: string) { - return str.split(search).join(replace); + return str.replace(new RegExp(search, 'gi'), replace); } private generateCensoredWord(count: number) { diff --git a/src/assets/i18n/home/de.json b/src/assets/i18n/home/de.json index 33ec19d02e982e9a88488ed9071dae8c0feea975..906537b363f858b60693f8782296f768936fe710 100644 --- a/src/assets/i18n/home/de.json +++ b/src/assets/i18n/home/de.json @@ -314,7 +314,9 @@ "session": "Raum" }, "topic-cloud": { - "changes-gone-wrong": "Etwas ist schief gelaufen!", - "changes-successful": "Änderungen gespeichert." + "changes-gone-wrong": "Etwas ist schiefgelaufen!", + "changes-successful": "Änderungen gespeichert.", + "add-successful": "Wort hinzugefügt", + "remove-successful": "Wort entfernt" } } diff --git a/src/assets/i18n/home/en.json b/src/assets/i18n/home/en.json index 2c6b9e93e1f6a502e9946db05131bf9059fb761e..42b2108121a06f8cfa3ca7a2f40c197ceb30a52c 100644 --- a/src/assets/i18n/home/en.json +++ b/src/assets/i18n/home/en.json @@ -319,6 +319,8 @@ }, "topic-cloud": { "changes-gone-wrong": "Something went wrong!", - "changes-successful": "Successfully updated." + "changes-successful": "Successfully updated.", + "add-successful": "Word added", + "remove-successful": "Word removed" } } diff --git a/src/assets/i18n/participant/de.json b/src/assets/i18n/participant/de.json index 2d04591fd98f0df1cf2b96374dabf459991974e0..a3efc8b1d106470ec9fbdecec193c75e40bf3de8 100644 --- a/src/assets/i18n/participant/de.json +++ b/src/assets/i18n/participant/de.json @@ -290,7 +290,9 @@ "changes-gone-wrong": "Etwas ist schiefgelaufen", "english": "Englisch", "german": "Deutsch", - "select-all": "Alle auswählen" + "select-all": "Alle auswählen", + "keyword-counter": "Anzahl der Themen", + "sort": "Sortieren" }, "topic-cloud-confirm-dialog": { "cancel": "Abbrechen", diff --git a/src/assets/i18n/participant/en.json b/src/assets/i18n/participant/en.json index a0bb21f5a38e39f39030f3dac711d2201b764469..c0bea49f45398eec81c16ddb51f6233a6ff8d592 100644 --- a/src/assets/i18n/participant/en.json +++ b/src/assets/i18n/participant/en.json @@ -296,7 +296,9 @@ "changes-gone-wrong": "somthing has gone wrong", "english": "English", "german": "German", - "select-all": "Select all" + "select-all": "Select all", + "keyword-counter": "Topic count", + "sort": "Sort" }, "topic-cloud-confirm-dialog":{ "cancel": "Cancel",