diff --git a/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.html b/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.html new file mode 100644 index 0000000000000000000000000000000000000000..42f530582fa4dd4c9649bbf6b5f12cc20d2c5670 --- /dev/null +++ b/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.html @@ -0,0 +1,20 @@ +<h3>{{'worker-config.heading' | translate}}</h3> +<mat-dialog-content> + <label id="worker-config-group-label">{{'worker-config.label' | translate}}</label> + <br> + <mat-radio-group aria-labelledby="worker-config-group-label" [(ngModel)]="selection"> + <mat-radio-button [value]="'normal'"> + <small>{{'worker-config.normal' | translate}}</small> + </mat-radio-button> + <br> + <mat-radio-button [value]="'only-failed'"> + <small>{{'worker-config.only-failed' | translate}}</small> + </mat-radio-button> + </mat-radio-group> +</mat-dialog-content> +<app-dialog-action-buttons + [buttonsLabelSection]="'worker-config'" + [confirmButtonLabel]="'continue'" + [confirmButtonClickAction]="buildConfirmAction()" + [cancelButtonClickAction]="buildCancelAction()"> +</app-dialog-action-buttons> diff --git a/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.scss b/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.spec.ts b/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d7299044d7cb457c586f17ddaf4ade4ba509c44 --- /dev/null +++ b/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.spec.ts @@ -0,0 +1,26 @@ +/*import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WorkerConfigDialogComponent } from './worker-config-dialog.component'; + +describe('WorkerConfigDialogComponent', () => { + let component: WorkerConfigDialogComponent; + let fixture: ComponentFixture<WorkerConfigDialogComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ WorkerConfigDialogComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(WorkerConfigDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); + */ diff --git a/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.ts b/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b95295268f384684cd333eeb74cd243c45294c4 --- /dev/null +++ b/src/app/components/shared/_dialogs/worker-config-dialog/worker-config-dialog.component.ts @@ -0,0 +1,49 @@ +import { Component, OnInit } from '@angular/core'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { Room } from '../../../../models/room'; +import { WorkerDialogComponent } from '../worker-dialog/worker-dialog.component'; +import { LanguageService } from '../../../../services/util/language.service'; +import { TranslateService } from '@ngx-translate/core'; + +@Component({ + selector: 'app-worker-config-dialog', + templateUrl: './worker-config-dialog.component.html', + styleUrls: ['./worker-config-dialog.component.scss'] +}) +export class WorkerConfigDialogComponent implements OnInit { + + public selection = 'normal'; + + constructor(private dialogRef: MatDialogRef<WorkerConfigDialogComponent>, + protected langService: LanguageService, + private translateService: TranslateService) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); + } + + public static addTask(dialog: MatDialog, room: Room) { + dialog.open(WorkerConfigDialogComponent, { + width: '900px', + maxWidth: '100%' + }).afterClosed().subscribe(data => { + if (!data) { + return; + } + WorkerDialogComponent.addWorkTask(dialog, room, data === 'only-failed'); + }); + } + + ngOnInit(): void { + this.translateService.use(localStorage.getItem('currentLang')); + } + + buildConfirmAction() { + return () => { + this.dialogRef.close(this.selection); + }; + } + + buildCancelAction() { + return () => this.dialogRef.close(); + } + +} diff --git a/src/app/components/shared/_dialogs/worker-dialog/worker-dialog-task.ts b/src/app/components/shared/_dialogs/worker-dialog/worker-dialog-task.ts index 30778ca4cd9324909a88c076a3edefa5578a05e8..8298e161b3516dd5e71d37cf28a102b586f09b2e 100644 --- a/src/app/components/shared/_dialogs/worker-dialog/worker-dialog-task.ts +++ b/src/app/components/shared/_dialogs/worker-dialog/worker-dialog-task.ts @@ -89,7 +89,7 @@ export class WorkerDialogTask { this.patchToServer([], index, Language.auto); } else { this.statistics.failed++; - this.callSpacy(index + concurrentCallsPerTask); + this.patchToServer([], index, Language.auto); } } diff --git a/src/app/components/shared/_dialogs/worker-dialog/worker-dialog.component.ts b/src/app/components/shared/_dialogs/worker-dialog/worker-dialog.component.ts index f17042906d79db9bed8a98479a4a59b52fe8bd2c..13dfc7c5063776a8323006f55193fb1fbbc8f05f 100644 --- a/src/app/components/shared/_dialogs/worker-dialog/worker-dialog.component.ts +++ b/src/app/components/shared/_dialogs/worker-dialog/worker-dialog.component.ts @@ -8,7 +8,7 @@ import { WorkerDialogTask } from './worker-dialog-task'; import { LanguagetoolService } from '../../../../services/http/languagetool.service'; import { TranslateService } from '@ngx-translate/core'; import { LanguageService } from '../../../../services/util/language.service'; -import { Comment } from '../../../../models/comment'; +import { Comment, Language } from '../../../../models/comment'; import { RoomDataService } from '../../../../services/util/room-data.service'; @Component({ @@ -39,7 +39,7 @@ export class WorkerDialogComponent implements OnInit { return this.queuedRooms.has(roomId); } - static addWorkTask(dialog: MatDialog, room: Room): boolean { + static addWorkTask(dialog: MatDialog, room: Room, onlyFailed = false): boolean { if (!this.dialogRef) { this.dialogRef = dialog.open(WorkerDialogComponent, { width: '200px', @@ -61,7 +61,27 @@ export class WorkerDialogComponent implements OnInit { if (this.queuedRooms.has(room.id)) { return false; } - this.dialogRef.componentInstance.appendRoom(room, this.dialogRef.componentInstance.roomDataService.currentRoomData); + let comments = this.dialogRef.componentInstance.roomDataService.currentRoomData; + if (onlyFailed) { + comments = comments.filter(c => { + const isKeywordOkay = c.keywordsFromSpacy && c.keywordsFromSpacy.length > 0; + const isLanguageDefined = c.language !== Language.auto; + let isKeywordWellDefined = false; + if (isKeywordOkay) { + isKeywordWellDefined = c.keywordsFromSpacy.every(keyword => { + const keys = Object.keys(keyword); + return keys.length === 2 && + keys.indexOf('dep') >= 0 && + keys.indexOf('text') >= 0 && + Array.isArray(keyword.dep) && + typeof keyword.text === 'string' && + keyword.dep.every(str => typeof str === 'string'); + }); + } + return !(isKeywordOkay && isKeywordWellDefined && isLanguageDefined); + }); + } + this.dialogRef.componentInstance.appendRoom(room, comments); return true; } diff --git a/src/app/components/shared/header/header.component.ts b/src/app/components/shared/header/header.component.ts index 8bf64ce5745a23bb16723a140fbd32a84c50a12b..4a424a57c5283fddd906a0e0c4cd5a08fe3f3cec 100644 --- a/src/app/components/shared/header/header.component.ts +++ b/src/app/components/shared/header/header.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, Renderer2 } from '@angular/core'; import { AuthenticationService } from '../../../services/http/authentication.service'; import { NotificationService } from '../../../services/util/notification.service'; -import { Router, NavigationEnd } from '@angular/router'; +import { NavigationEnd, Router } from '@angular/router'; import { User } from '../../../models/user'; import { UserRole } from '../../../models/user-roles.enum'; import { Location } from '@angular/common'; @@ -24,11 +24,11 @@ import { TopicCloudFilterComponent } from '../_dialogs/topic-cloud-filter/topic- import { RoomService } from '../../../services/http/room.service'; import { Room } from '../../../models/room'; import { TagCloudMetaData } from '../../../services/util/tag-cloud-data.service'; -import { WorkerDialogComponent } from '../_dialogs/worker-dialog/worker-dialog.component'; import { WsRoomService } from '../../../services/websockets/ws-room.service'; import { TopicCloudAdminService } from '../../../services/util/topic-cloud-admin.service'; import { HeaderService } from '../../../services/util/header.service'; import { OnboardingService } from '../../../services/util/onboarding.service'; +import { WorkerConfigDialogComponent } from '../_dialogs/worker-config-dialog/worker-config-dialog.component'; @Component({ selector: 'app-header', @@ -47,10 +47,10 @@ export class HeaderComponent implements OnInit { commentsCountUsers = 0; commentsCountKeywords = 0; isAdminConfigEnabled = false; - private _subscriptionRoomService = null; toggleUserActivity = false; userActivity = 0; deviceType = localStorage.getItem('deviceType'); + private _subscriptionRoomService = null; constructor(public location: Location, private authenticationService: AuthenticationService, @@ -156,7 +156,7 @@ export class HeaderComponent implements OnInit { } } }); - this.moderationEnabled = (localStorage.getItem('moderationEnabled') === 'true') ? true : false; + this.moderationEnabled = localStorage.getItem('moderationEnabled') === 'true'; this._r.listen(document, 'keyup', (event) => { @@ -304,8 +304,7 @@ export class HeaderComponent implements OnInit { const dialogRef = this.dialog.open(QrCodeDialogComponent, { panelClass: 'screenDialog' }); - const url = this.getURL(); - dialogRef.componentInstance.data = url; + dialogRef.componentInstance.data = this.getURL(); dialogRef.componentInstance.key = this.shortId; dialogRef.afterClosed().subscribe(res => { Rescale.exitFullscreen(); @@ -379,6 +378,6 @@ export class HeaderComponent implements OnInit { } public startWorkerDialog() { - WorkerDialogComponent.addWorkTask(this.dialog, this.room); + WorkerConfigDialogComponent.addTask(this.dialog, this.room); } } diff --git a/src/app/components/shared/shared.module.ts b/src/app/components/shared/shared.module.ts index 7637d1bf80426a544fd9c61ea8c8aa2efac520bd..923347c6a6010d94acf509ea07fe15339f9e8568 100644 --- a/src/app/components/shared/shared.module.ts +++ b/src/app/components/shared/shared.module.ts @@ -54,6 +54,7 @@ import { ViewCommentDataComponent } from './view-comment-data/view-comment-data. import { DeepLDialogComponent } from './_dialogs/deep-ldialog/deep-ldialog.component'; import { ExplanationDialogComponent } from './_dialogs/explanation-dialog/explanation-dialog.component'; import { QuillInputDialogComponent } from './_dialogs/quill-input-dialog/quill-input-dialog.component'; +import { WorkerConfigDialogComponent } from './_dialogs/worker-config-dialog/worker-config-dialog.component'; @NgModule({ imports: [ @@ -113,7 +114,8 @@ import { QuillInputDialogComponent } from './_dialogs/quill-input-dialog/quill-i ViewCommentDataComponent, DeepLDialogComponent, ExplanationDialogComponent, - QuillInputDialogComponent + QuillInputDialogComponent, + WorkerConfigDialogComponent ], exports: [ RoomJoinComponent, diff --git a/src/assets/i18n/home/de.json b/src/assets/i18n/home/de.json index 77d9300d0a3701f27c9bbd67c84aefea7fbb5fa5..195b22ebc9221c8e5709729f25a81b3f39941bf8 100644 --- a/src/assets/i18n/home/de.json +++ b/src/assets/i18n/home/de.json @@ -133,7 +133,7 @@ "help": { "cancel": "Schließen", "cancel-description": "Schließt die Hilfe", - "title": "Hilfe" + "title": "Hilfe" }, "home-page": { "accessibility-create": "Erstellt eine neue Sitzung.", @@ -369,12 +369,20 @@ "add-successful": "Wort hinzugefügt", "remove-successful": "Wort entfernt" }, + "worker-config": { + "heading": "Fragen analysieren", + "label": "Wähle ein Analysemodus", + "normal": "Alle", + "only-failed": "Nicht analysierte Fragen", + "continue": "Weiter", + "cancel": "Abbrechen" + }, "worker-dialog": { "running": "Laufend", - "room-name" : "Raum", - "comments" : "Abgearbeitete Fragen", - "bad-spelled" : "Zu schlechte Rechtschreibung", - "failed" : "Fehler aufgetreten", + "room-name": "Raum", + "comments": "Abgearbeitete Fragen", + "bad-spelled": "Zu schlechte Rechtschreibung", + "failed": "Fehler aufgetreten", "inline-header": "Laufende Stichwort-Aktualisierungen" }, "topic-cloud-filter": { diff --git a/src/assets/i18n/home/en.json b/src/assets/i18n/home/en.json index 2bb8b409ac532535b0f576fa0c4804b028baafbf..b42e6f68113f1ccc94c8a4623bfb18caa0f69a95 100644 --- a/src/assets/i18n/home/en.json +++ b/src/assets/i18n/home/en.json @@ -371,6 +371,14 @@ "add-successful": "Word added", "remove-successful": "Word removed" }, + "worker-config": { + "heading": "Analyze questions", + "label": "Choose an analysis mode", + "normal": "All", + "only-failed": "Not analysed questions", + "continue": "Continue", + "cancel": "Cancel" + }, "worker-dialog": { "running": "Running", "room-name": "Session name",