RED-5908: viewed pages update

This commit is contained in:
Dan Percic 2023-01-07 17:24:05 +02:00
parent 8f9adabd80
commit aeaf748c61
9 changed files with 28 additions and 33 deletions

View File

@ -94,7 +94,6 @@
[active]="pageNumber === activeViewerPage"
[number]="pageNumber"
[showDottedIcon]="hasOnlyManualRedactionsAndIsExcluded(pageNumber)"
[viewedPages]="fileDataService.viewedPages"
></redaction-page-indicator>
</div>

View File

@ -40,7 +40,6 @@ import { PdfViewer } from '../../../pdf-viewer/services/pdf-viewer.service';
import { REDAnnotationManager } from '../../../pdf-viewer/services/annotation-manager.service';
import { AnnotationsListingService } from '../../services/annotations-listing.service';
import { REDDocumentViewer } from '../../../pdf-viewer/services/document-viewer.service';
import { UserPreferenceService } from '@users/user-preference.service';
import { SuggestionsService } from '../../services/suggestions.service';
const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape'];
@ -87,11 +86,11 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy
private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _annotationProcessingService: AnnotationProcessingService,
private readonly _viewModeService: ViewModeService,
private readonly _userPreferencesService: UserPreferenceService,
private readonly _suggestionsService: SuggestionsService,
) {
super();
// TODO: ngOnDetach is not called here, so we need to unsubscribe manually
this.addActiveScreenSubscription = this.pdf.currentPage$.subscribe(pageNumber => {
this._scrollViews();
this.scrollAnnotationsToPage(pageNumber, 'always');
@ -111,7 +110,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy
this.displayedAnnotations$ = this._displayedAnnotations$;
this.multiSelectInactive$ = this._multiSelectInactive$;
this.showExcludedPages$ = this._showExcludedPages$;
this.isEarmarks$ = this._isHighlights$;
this.isEarmarks$ = this._isEarmarks$;
this.title$ = this._title$;
}
@ -140,7 +139,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy
);
}
private get _isHighlights$(): Observable<boolean> {
private get _isEarmarks$(): Observable<boolean> {
return this.viewModeService.viewMode$.pipe(
tap(() => this._scrollViews()),
map(() => this.viewModeService.isEarmarks),

View File

@ -1,7 +1,7 @@
<div
*ngIf="componentContext$ | async"
(click)="pageSelected.emit(number)"
(dblclick)="toggleReadState()"
*ngIf="componentContext$ | async"
[class.active]="active"
[class.read]="read"
[id]="'quick-nav-page-' + number"

View File

@ -2,12 +2,11 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, In
import { PermissionsService } from '@services/permissions.service';
import { ConfigService } from '@services/config.service';
import { ViewedPagesService } from '@services/files/viewed-pages.service';
import { IViewedPage } from '@red/domain';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { firstValueFrom } from 'rxjs';
import { PageRotationService } from '../../../pdf-viewer/services/page-rotation.service';
import { ContextComponent } from '@iqser/common-ui';
import { tap } from 'rxjs/operators';
import { FileDataService } from '../../services/file-data.service';
interface PageIndicatorContext {
isRotated: boolean;
@ -24,7 +23,6 @@ export class PageIndicatorComponent extends ContextComponent<PageIndicatorContex
@Input() showDottedIcon = false;
@Input() number: number;
@Input() activeSelection = false;
@Input() viewedPages: IViewedPage[] = [];
@Output() readonly pageSelected = new EventEmitter<number>();
@ -38,13 +36,14 @@ export class PageIndicatorComponent extends ContextComponent<PageIndicatorContex
private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _permissionService: PermissionsService,
private readonly _stateService: FilePreviewStateService,
private readonly _fileDataService: FileDataService,
readonly pageRotationService: PageRotationService,
) {
super();
}
get activePage() {
return this.viewedPages.find(p => p.page === this.number);
return this._fileDataService.viewedPages.find(p => p.page === this.number);
}
get dossierId() {
@ -111,23 +110,19 @@ export class PageIndicatorComponent extends ContextComponent<PageIndicatorContex
}
private async _markPageRead() {
await firstValueFrom(this._viewedPagesService.addPage({ page: this.number }, this.dossierId, this.fileId));
await this._viewedPagesService.addPage({ page: this.number }, this.dossierId, this.fileId);
if (this.activePage) {
this.activePage.showAsUnseen = false;
} else {
this.viewedPages.push({ page: this.number, fileId: this.fileId });
this._fileDataService.viewedPages.push({ page: this.number, fileId: this.fileId });
}
this._setReadState();
}
private async _markPageUnread() {
const removePage$ = this._viewedPagesService.removePage(this.dossierId, this.fileId, this.number);
await firstValueFrom(removePage$);
this.viewedPages.splice(
this.viewedPages.findIndex(p => p.page === this.number),
1,
);
await this._viewedPagesService.removePage(this.dossierId, this.fileId, this.number);
const pageToDelete = this._fileDataService.viewedPages.findIndex(p => p.page === this.number);
this._fileDataService.viewedPages.splice(pageToDelete, 1);
this._setReadState();
}
}

View File

@ -509,13 +509,11 @@ export class FilePreviewScreenComponent
filters: processFilters(primaryFilters, annotationFilters),
});
const secondaryFilters = this._filterService.getGroup('secondaryFilters')?.filters;
const secondaryAnnotationFilters = this._annotationProcessingService.secondaryAnnotationFilters;
this._filterService.addFilterGroup({
slug: 'secondaryFilters',
filterTemplate: this._filterTemplate,
filters: processFilters(
secondaryFilters,
AnnotationProcessingService.secondaryAnnotationFilters(this._fileDataService.viewedPages),
),
filters: processFilters(secondaryFilters, secondaryAnnotationFilters),
});
this._logger.info(`[FILTERS] Rebuild time: ${new Date().getTime() - startTime} ms`);

View File

@ -4,7 +4,7 @@ import { SuperTypeSorter } from '../../../utils';
import { Filter, handleCheckedValue, IFilter, INestedFilter, NestedFilter } from '@iqser/common-ui';
import { annotationTypesTranslations } from '@translations/annotation-types-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { annotationDefaultColorConfig, IViewedPage } from '@red/domain';
import { annotationDefaultColorConfig } from '@red/domain';
import { FilePreviewStateService } from './file-preview-state.service';
import { FileDataService } from './file-data.service';
import { DefaultColorsService } from '@services/entity-services/default-colors.service';
@ -18,8 +18,7 @@ export class AnnotationProcessingService {
private readonly _defaultColorsService: DefaultColorsService,
) {}
static secondaryAnnotationFilters(viewedPages?: IViewedPage[]): INestedFilter[] {
const _viewedPages = viewedPages ? viewedPages.map(page => page.page) : [];
get secondaryAnnotationFilters(): INestedFilter[] {
return [
{
id: 'with-comments',
@ -43,7 +42,8 @@ export class AnnotationProcessingService {
label: _('filter-menu.unseen-pages'),
checked: false,
topLevelFilter: true,
checker: (annotation: AnnotationWrapper) => !_viewedPages.includes(annotation.pageNumber),
checker: (annotation: AnnotationWrapper) =>
!this._fileDataService.viewedPages.some(page => page.page === annotation.pageNumber),
},
{
id: 'pages-without-annotations',

View File

@ -152,7 +152,7 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
return;
}
this.viewedPages = await firstValueFrom(this._viewedPagesService.getViewedPages(file.dossierId, file.fileId));
this.viewedPages = await this._viewedPagesService.getViewedPages(file.dossierId, file.fileId);
}
#getVisibleAnnotations(annotations: AnnotationWrapper[], viewMode: ViewMode) {

View File

@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { GenericService, RequiredParam, Validate } from '@iqser/common-ui';
import { catchError, map } from 'rxjs/operators';
import { IViewedPage, IViewedPagesRequest } from '@red/domain';
import { of } from 'rxjs';
import { firstValueFrom, of } from 'rxjs';
@Injectable({
providedIn: 'root',
@ -12,19 +12,23 @@ export class ViewedPagesService extends GenericService<unknown> {
@Validate()
addPage(@RequiredParam() body: IViewedPagesRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
return this._post(body, `${this._defaultModelPath}/${dossierId}/${fileId}`);
const modelPath = `${this._defaultModelPath}/${dossierId}/${fileId}`;
return firstValueFrom(this._post(body, modelPath));
}
@Validate()
removePage(@RequiredParam() dossierId: string, @RequiredParam() fileId: string, @RequiredParam() page: number) {
return super.delete({}, `${this._defaultModelPath}/${dossierId}/${fileId}/${page}`);
const modelPath = `${this._defaultModelPath}/${dossierId}/${fileId}/${page}`;
return firstValueFrom(super.delete({}, modelPath));
}
@Validate()
getViewedPages(@RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
return this._getOne<{ pages?: IViewedPage[] }>([dossierId, fileId]).pipe(
const request = this._getOne<{ pages?: IViewedPage[] }>([dossierId, fileId]).pipe(
map(res => res.pages),
catchError(() => of([] as IViewedPage[])),
);
return firstValueFrom(request);
}
}

@ -1 +1 @@
Subproject commit b20d4e938cc5f172eda5a327ba9e0d2d4b6b4a4b
Subproject commit b60331ca0816d481adc29048874db97aa49ae8ce