From 382f590afbe4b4c01d19feafade79594660d5827 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Tue, 3 Nov 2020 23:39:25 +0200 Subject: [PATCH] new rule on file preview --- .../file-preview-screen.component.html | 7 +++- .../file-preview-screen.component.ts | 39 +++++++++++++++++-- .../project-listing-screen.component.html | 4 +- .../project-overview-screen.component.html | 10 ++--- .../project-overview-screen.component.ts | 11 +----- .../red-ui/src/app/state/app-state.service.ts | 10 +++++ apps/red-ui/src/assets/i18n/en.json | 4 +- 7 files changed, 64 insertions(+), 21 deletions(-) diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html index f95bc6c4a..60fdc9626 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html @@ -7,7 +7,12 @@
- {{ appStateService.activeFile.filename }} +  {{ appStateService.activeFile.filename }}
diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts index 4778f5077..9eb8482db 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts @@ -30,6 +30,8 @@ import { AnnotationDrawService } from '../service/annotation-draw.service'; import { AnnotationProcessingService } from '../service/annotation-processing.service'; import { FilterModel } from '../../../common/filter/model/filter.model'; import { tap } from 'rxjs/operators'; +import { NotificationService, NotificationType } from '../../../notification/notification.service'; +import { TranslateService } from '@ngx-translate/core'; const KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; @@ -46,6 +48,8 @@ export class FilePreviewScreenComponent implements OnInit { private readonly _activatedRoute: ActivatedRoute, private readonly _dialogService: DialogService, private readonly _router: Router, + private readonly _notificationService: NotificationService, + private readonly _translateService: TranslateService, private readonly _annotationProcessingService: AnnotationProcessingService, private readonly _annotationDrawService: AnnotationDrawService, private readonly _fileActionService: FileActionService, @@ -107,7 +111,9 @@ export class FilePreviewScreenComponent implements OnInit { loadingMessage: string; public ngOnInit(): void { - this._loadFileData().subscribe(() => {}); + this._loadFileData().subscribe(() => { + this._displayNewRuleToast(); + }); this.appStateService.fileStatusChanged.subscribe((fileStatus: FileStatus) => { if (fileStatus.fileId === this.fileId) { this._loadFileData().subscribe(() => { @@ -155,8 +161,8 @@ export class FilePreviewScreenComponent implements OnInit { ); } - public reanalyseFile($event: MouseEvent) { - $event.stopPropagation(); + public reanalyseFile($event?: MouseEvent) { + $event?.stopPropagation(); this.viewReady = false; this.loadingMessage = 'file-preview.reanalyse-file'; this._reanalysisControllerService @@ -510,4 +516,31 @@ export class FilePreviewScreenComponent implements OnInit { this._fileActionService.setApproved(this.appStateService.activeFile); } } + + private _displayNewRuleToast() { + if (this.appStateService.fileNotUpToDateWithDictionary()) { + this._notificationService.showToastNotification( + `${this._translateService.instant('project-overview.new-rule.toast.message-file')}`, + null, + NotificationType.WARNING, + { + disableTimeOut: true, + positionClass: 'toast-top-left', + actions: [ + { + title: this._translateService.instant( + 'project-overview.new-rule.toast.actions.reanalyse-file' + ), + action: () => this.reanalyseFile() + }, + { + title: this._translateService.instant( + 'project-overview.new-rule.toast.actions.later' + ) + } + ] + } + ); + } + } } diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html index 33f17af4a..1ed79bfc0 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html @@ -215,7 +215,7 @@
@@ -240,7 +240,7 @@
diff --git a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html index 2082cbf10..31fe90b49 100644 --- a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html +++ b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html @@ -171,7 +171,7 @@ {{ fileStatus.filename }} @@ -248,7 +248,7 @@ *ngIf=" userService.isManager(user) || appStateService.isActiveProjectOwner " - [matTooltip]="'project-overview.delete.action.label' | translate" + [matTooltip]="'project-overview.delete.action' | translate" [matTooltipPosition]="'above'" color="accent" mat-icon-button @@ -257,7 +257,7 @@