From 6a65cef349e7a6e7200d133633b1b1e19bd8a329 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 12 May 2021 12:15:53 +0300 Subject: [PATCH] use attributes from backend to get last opened file --- .../src/app/modules/projects/projects.module.ts | 4 +++- .../file-preview-screen.component.ts | 7 +++++-- .../project-overview-screen.component.scss | 15 +++++++++++---- .../project-overview-screen.component.ts | 14 ++++++++++---- .../src/app/services/user-preference.service.ts | 8 -------- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/apps/red-ui/src/app/modules/projects/projects.module.ts b/apps/red-ui/src/app/modules/projects/projects.module.ts index af2361d8d..14532186e 100644 --- a/apps/red-ui/src/app/modules/projects/projects.module.ts +++ b/apps/red-ui/src/app/modules/projects/projects.module.ts @@ -36,6 +36,7 @@ import { AnnotationDrawService } from './services/annotation-draw.service'; import { AnnotationProcessingService } from './services/annotation-processing.service'; import { AnnotationRemoveActionsComponent } from './components/annotation-remove-actions/annotation-remove-actions.component'; import { DossierDictionaryDialogComponent } from './dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component'; +import { UserPreferenceControllerService } from '@redaction/red-ui-http'; const screens = [ProjectListingScreenComponent, ProjectOverviewScreenComponent, FilePreviewScreenComponent]; @@ -77,7 +78,8 @@ const services = [ ManualAnnotationService, PdfViewerDataService, AnnotationDrawService, - AnnotationProcessingService + AnnotationProcessingService, + UserPreferenceControllerService ]; @NgModule({ diff --git a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts index f81e9afeb..7163f7458 100644 --- a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts @@ -22,7 +22,7 @@ import { handleFilterDelta, processFilters } from '@shared/components/filter/uti import { UserPreferenceService } from '@services/user-preference.service'; import { UserService } from '@services/user.service'; import { FormBuilder, FormGroup } from '@angular/forms'; -import { FileManagementControllerService, StatusControllerService } from '@redaction/red-ui-http'; +import { FileManagementControllerService, StatusControllerService, UserPreferenceControllerService } from '@redaction/red-ui-http'; import { PdfViewerDataService } from '../../services/pdf-viewer-data.service'; import { download } from '@utils/file-download-utils'; import { ViewMode } from '@models/file/view-mode'; @@ -71,6 +71,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, readonly permissionsService: PermissionsService, readonly userPreferenceService: UserPreferenceService, readonly userService: UserService, + private readonly _userPreferenceControllerService: UserPreferenceControllerService, private readonly _changeDetectorRef: ChangeDetectorRef, private readonly _activatedRoute: ActivatedRoute, private readonly _dialogService: ProjectsDialogService, @@ -194,7 +195,9 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, ngOnInit(): void { this.displayPDFViewer = true; - this.userPreferenceService.lastOpenedFileId = this.fileId; + + const key = 'Project-Recent-' + this.projectId; + this._userPreferenceControllerService.savePreferences([this.fileId], key).toPromise().then(); this._subscribeToFileUpdates(); } diff --git a/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.scss b/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.scss index 69433738b..4f91ae3fe 100644 --- a/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.scss +++ b/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.scss @@ -129,9 +129,16 @@ cdk-virtual-scroll-viewport { border-left: 4px solid $red-1; } - &:hover { - > div { - background-color: rgba($red-1, 0.1); - } + > div { + animation: red-fading-background 3s 1; + } +} + +@keyframes red-fading-background { + 0% { + background-color: rgba($red-1, 0.1); + } + 100% { + background-color: inherit; } } diff --git a/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.ts b/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.ts index 7eec7cdda..cb102bda3 100644 --- a/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/projects/screens/project-overview-screen/project-overview-screen.component.ts @@ -14,7 +14,7 @@ import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { annotationFilterChecker, keyChecker, processFilters } from '@shared/components/filter/utils/filter-utils'; import { PermissionsService } from '@services/permissions.service'; import { UserService } from '@services/user.service'; -import { FileStatus } from '@redaction/red-ui-http'; +import { FileStatus, UserPreferenceControllerService } from '@redaction/red-ui-http'; import { Subscription, timer } from 'rxjs'; import { filter, tap } from 'rxjs/operators'; import { RedactionFilterSorter } from '@utils/sorters/redaction-filter-sorter'; @@ -26,7 +26,6 @@ import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { ProjectWrapper } from '@state/model/project.wrapper'; import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy'; -import { UserPreferenceService } from '@services/user-preference.service'; @Component({ selector: 'redaction-project-overview-screen', @@ -51,6 +50,7 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent { + if (attributes === null || attributes === undefined) return; + const key = 'Project-Recent-' + this.activeProject.projectId; + this._lastOpenedFileId = attributes[key][0]; + }); + this._fileDropOverlayService.initFileDropHandling(); this.calculateData(); diff --git a/apps/red-ui/src/app/services/user-preference.service.ts b/apps/red-ui/src/app/services/user-preference.service.ts index 695504a90..b77e13d58 100644 --- a/apps/red-ui/src/app/services/user-preference.service.ts +++ b/apps/red-ui/src/app/services/user-preference.service.ts @@ -12,14 +12,6 @@ export class UserPreferenceService { return false; } - set lastOpenedFileId(value: string) { - sessionStorage.setItem('redaction.last-opened-file', value); - } - - get lastOpenedFileId(): string { - return sessionStorage.getItem('redaction.last-opened-file') || ''; - } - toggleDevFeatures() { sessionStorage.setItem('redaction.enable-dev-features', `${!this.areDevFeaturesEnabled}`); window.location.reload();