use attributes from backend to get last opened file

This commit is contained in:
Dan Percic 2021-05-12 12:15:53 +03:00
parent 8a9436b376
commit 6a65cef349
5 changed files with 29 additions and 19 deletions

View File

@ -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({

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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<FileSta
private _routerEventsScrollPositionSub: Subscription;
private _fileChangedSub: Subscription;
private _lastScrollPosition: number;
private _lastOpenedFileId = '';
@ViewChild(CdkVirtualScrollViewport) private _scrollBar: CdkVirtualScrollViewport;
@ -69,7 +69,7 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
private readonly _translateService: TranslateService,
private readonly _fileDropOverlayService: FileDropOverlayService,
private readonly _appStateService: AppStateService,
private readonly _userPreferencesService: UserPreferenceService,
private readonly _userPreferenceControllerService: UserPreferenceControllerService,
protected readonly _injector: Injector
) {
super(_injector);
@ -81,7 +81,7 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
}
isLastOpenedFile(fileStatus: FileStatusWrapper): boolean {
return this._userPreferencesService.lastOpenedFileId === fileStatus.fileId;
return this._lastOpenedFileId === fileStatus.fileId;
}
protected get _filterComponents(): FilterComponent[] {
@ -102,6 +102,12 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
}
ngOnInit(): void {
this._userPreferenceControllerService.getAllUserAttributes().subscribe((attributes) => {
if (attributes === null || attributes === undefined) return;
const key = 'Project-Recent-' + this.activeProject.projectId;
this._lastOpenedFileId = attributes[key][0];
});
this._fileDropOverlayService.initFileDropHandling();
this.calculateData();

View File

@ -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();