From 522c849b1961079acca1c981bd31694a34ba4f59 Mon Sep 17 00:00:00 2001
From: Stefan Plociennik <stefan.plociennik@mni.thm.de>
Date: Mon, 28 Jun 2021 12:35:44 +0200
Subject: [PATCH] adds test input for profanity word

---
 .../topic-cloud-administration.component.html | 48 +++++++++++++++++
 .../topic-cloud-administration.component.scss |  8 +++
 .../topic-cloud-administration.component.ts   | 54 ++++++++++---------
 3 files changed, 86 insertions(+), 24 deletions(-)

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 671aa5d39..192ae5b4c 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
@@ -44,6 +44,54 @@
             <mat-slide-toggle *ngIf="profanityFilter" (change)="showMessage('partial-words-will-be-filtered', $event.checked)" [(ngModel)]="censorPartialWordsCheck">
               Teilwörter
             </mat-slide-toggle>
+
+            <mat-accordion>
+              <mat-expansion-panel class="color-background" (opened)="focusInput('test-profanity-input')">
+                <mat-expansion-panel-header class="color-background">
+                  <mat-panel-title>
+                    {{"topic-cloud-dialog.test-profanity" | translate}}
+                  </mat-panel-title>
+                </mat-expansion-panel-header>
+                <mat-form-field>
+                  <mat-label>{{"topic-cloud-dialog.word" | translate}}</mat-label>
+                  <input id="test-profanity-input" matInput [ngModel]="testProfanityWord" (ngModelChange)="testProfanity($event)">
+                </mat-form-field>
+                <p class="red testProfanity" *ngIf="wordIsProfanity">{{"topic-cloud-dialog.word-is-profanity" | translate}}</p>
+                <p class="green testProfanity" *ngIf="!wordIsProfanity">{{"topic-cloud-dialog.word-is-not-profanity" | translate}}</p>
+
+
+                <mat-accordion>
+                  <mat-expansion-panel class="color-background">
+                    <mat-expansion-panel-header class="color-background">
+                      <mat-panel-title>
+                        {{"topic-cloud-dialog.words-in-profanity" | translate}}   
+                      </mat-panel-title>
+                    </mat-expansion-panel-header>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/en" target="_blank">English</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/de" target="_blank">German</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/fr" target="_blank">French</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/ar" target="_blank">Arabic</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/ru" target="_blank">Russian</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/es" target="_blank">Spanish</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/it" target="_blank">Italian</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/nl" target="_blank">Netherlandish</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/tr" target="_blank">Turkish</a>
+                    <br>
+                    <a href="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/pt" target="_blank">Portuguese</a>
+                  </mat-expansion-panel>
+                </mat-accordion>
+                
+              </mat-expansion-panel>
+            </mat-accordion>
+
           </mat-card>
           <mat-card style="background: none;">
             <mat-slide-toggle [(ngModel)]="blacklistIsActive">
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 368a5c46a..5c4d5977a 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
@@ -29,6 +29,10 @@
   color: var(--red);
 }
 
+.green {
+  color: var(--green);
+}
+
 .primaryBackground {
   background-color: var(--primary);
 }
@@ -150,6 +154,10 @@ mat-dialog-content {
   height: 18px !important;
 }
 
+.testProfanity {
+  margin-top: 0px;
+}
+
 ::ng-deep .ng-animating div mat-accordion mat-expansion-panel mat-expansion-panel-header {
   height: 48px;
 }
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 70f6b4958..139a53fb7 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
@@ -59,6 +59,8 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
   private profanityFilter: boolean;
   private censorPartialWordsCheck: boolean;
   private censorLanguageSpecificCheck: boolean;
+  private testProfanityWord: string = undefined;
+  private wordIsProfanity: boolean = undefined;
 
   constructor(
     @Inject(MAT_DIALOG_DATA) public data: Data,
@@ -169,17 +171,17 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
       this.isLoading = false;
     });
     this.commentServiceSubscription = this.roomDataService.receiveUpdates([
-      {type: 'CommentCreated', finished: true},
-      {type: 'CommentDeleted'},
-      {type: 'CommentPatched', finished: true, updates: ['score']},
-      {type: 'CommentPatched', finished: true, updates: ['upvotes']},
-      {type: 'CommentPatched', finished: true, updates: ['downvotes']},
-      {type: 'CommentPatched', finished: true, updates: ['keywordsFromSpacy']},
-      {type: 'CommentPatched', finished: true, updates: ['keywordsFromQuestioner']},
-      {type: 'CommentPatched', finished: true, updates: ['ack']},
-      {type: 'CommentPatched', finished: true, updates: ['tag']},
-      {type: 'CommentPatched', subtype: 'ack'},
-      {finished: true}
+      { type: 'CommentCreated', finished: true },
+      { type: 'CommentDeleted' },
+      { type: 'CommentPatched', finished: true, updates: ['score'] },
+      { type: 'CommentPatched', finished: true, updates: ['upvotes'] },
+      { type: 'CommentPatched', finished: true, updates: ['downvotes'] },
+      { type: 'CommentPatched', finished: true, updates: ['keywordsFromSpacy'] },
+      { type: 'CommentPatched', finished: true, updates: ['keywordsFromQuestioner'] },
+      { type: 'CommentPatched', finished: true, updates: ['ack'] },
+      { type: 'CommentPatched', finished: true, updates: ['tag'] },
+      { type: 'CommentPatched', subtype: 'ack' },
+      { finished: true }
     ]).subscribe(update => {
       if (update.type === 'CommentCreated') {
         this.pushInKeywords(update.comment);
@@ -231,12 +233,12 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
     if (this.topicCloudAdminData) {
       this.considerVotes = this.topicCloudAdminData.considerVotes;
       this.profanityFilter = this.topicCloudAdminData.profanityFilter !== ProfanityFilter.deactivated;
-    if (this.topicCloudAdminData.profanityFilter === ProfanityFilter.all){
-      this.censorLanguageSpecificCheck = this.censorPartialWordsCheck = true;
-    } else if (this.profanityFilter){
-      this.censorLanguageSpecificCheck = this.topicCloudAdminData.profanityFilter === ProfanityFilter.languageSpecific;
-      this.censorPartialWordsCheck = this.topicCloudAdminData.profanityFilter === ProfanityFilter.partialWords;
-    }
+      if (this.topicCloudAdminData.profanityFilter === ProfanityFilter.all) {
+        this.censorLanguageSpecificCheck = this.censorPartialWordsCheck = true;
+      } else if (this.profanityFilter) {
+        this.censorLanguageSpecificCheck = this.topicCloudAdminData.profanityFilter === ProfanityFilter.languageSpecific;
+        this.censorPartialWordsCheck = this.topicCloudAdminData.profanityFilter === ProfanityFilter.partialWords;
+      }
       this.blacklistIsActive = this.topicCloudAdminData.blacklistIsActive;
       this.keywordORfulltext = KeywordOrFulltext[this.topicCloudAdminData.keywordORfulltext];
       this.wantedLabels = {
@@ -304,12 +306,12 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
 
   updateComment(updatedComment: Comment, changes: TSMap<string, any>, messageTranslate?: string) {
     this.commentService.patchComment(updatedComment, changes).subscribe(_ => {
-        if (messageTranslate) {
-          this.translateService.get('topic-cloud-dialog.' + messageTranslate).subscribe(msg => {
-            this.notificationService.show(msg);
-          });
-        }
-      },
+      if (messageTranslate) {
+        this.translateService.get('topic-cloud-dialog.' + messageTranslate).subscribe(msg => {
+          this.notificationService.show(msg);
+        });
+      }
+    },
       error => {
         this.translateService.get('topic-cloud-dialog.changes-gone-wrong').subscribe(msg => {
           this.notificationService.show(msg);
@@ -358,7 +360,7 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
   openConfirmDialog(msg: string, _confirmLabel: string, keyword: Keyword, mergeTarget?: Keyword) {
     const translationPart = 'topic-cloud-confirm-dialog.' + msg;
     const confirmDialogRef = this.confirmDialog.open(TopicCloudConfirmDialogComponent, {
-      data: {topic: keyword.keyword, message: translationPart, confirmLabel: _confirmLabel}
+      data: { topic: keyword.keyword, message: translationPart, confirmLabel: _confirmLabel }
     });
 
     confirmDialogRef.afterClosed().subscribe(result => {
@@ -467,6 +469,10 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy {
       this.wantedLabels.en = [];
     }
   }
+
+  testProfanity(word) {
+    this.wordIsProfanity = this.profanityFilterService.getProfanityList.includes(word.toLowerCase());
+  }
 }
 
 interface Keyword {
-- 
GitLab