move pages related models to red-domain
This commit is contained in:
parent
8316b97213
commit
7fd0272d16
@ -1,10 +1,10 @@
|
||||
import { RedactionLog, RedactionLogEntry, ViewedPages } from '@redaction/red-ui-http';
|
||||
import { RedactionLog, RedactionLogEntry } from '@redaction/red-ui-http';
|
||||
import { File } from './file';
|
||||
import { AnnotationWrapper } from './annotation.wrapper';
|
||||
import { RedactionLogEntryWrapper } from './redaction-log-entry.wrapper';
|
||||
import { ViewMode } from './view-mode';
|
||||
import * as moment from 'moment';
|
||||
import { User } from '@red/domain';
|
||||
import { IViewedPage, User } from '@red/domain';
|
||||
import { Dictionary } from '@models/dictionary';
|
||||
|
||||
export class AnnotationData {
|
||||
@ -17,7 +17,7 @@ export class FileDataModel {
|
||||
|
||||
hasChangeLog: boolean;
|
||||
|
||||
constructor(public file: File, public fileData: Blob, public redactionLog: RedactionLog, public viewedPages?: ViewedPages) {}
|
||||
constructor(public file: File, public fileData: Blob, public redactionLog: RedactionLog, public viewedPages?: IViewedPage[]) {}
|
||||
|
||||
getAnnotations(
|
||||
dictionaryData: { [p: string]: Dictionary },
|
||||
@ -112,7 +112,7 @@ export class FileDataModel {
|
||||
redactionLogEntry.changes.length >= 1 ? redactionLogEntry.changes[redactionLogEntry.changes.length - 1] : undefined;
|
||||
const page = redactionLogEntry.positions?.[0].page;
|
||||
|
||||
const viewedPage = this.viewedPages.pages.filter(p => p.page === page).pop();
|
||||
const viewedPage = this.viewedPages.filter(p => p.page === page).pop();
|
||||
|
||||
// page has been seen -> let's see if it's a change
|
||||
if (viewedPage) {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { PageRange } from '@redaction/red-ui-http';
|
||||
import { InputWithActionComponent, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { File } from '@models/file/file';
|
||||
import { ReanalysisService } from '@services/reanalysis.service';
|
||||
import { IPageRange } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-page-exclusion',
|
||||
@ -15,7 +15,7 @@ export class PageExclusionComponent implements OnChanges {
|
||||
@Input() file: File;
|
||||
@Output() readonly actionPerformed = new EventEmitter<string>();
|
||||
|
||||
excludedPagesRanges: PageRange[] = [];
|
||||
excludedPagesRanges: IPageRange[] = [];
|
||||
@ViewChild(InputWithActionComponent) private readonly _inputComponent: InputWithActionComponent;
|
||||
|
||||
constructor(
|
||||
@ -27,12 +27,12 @@ export class PageExclusionComponent implements OnChanges {
|
||||
|
||||
ngOnChanges(): void {
|
||||
const excludedPages = (this.file?.excludedPages || []).sort((p1, p2) => p1 - p2);
|
||||
this.excludedPagesRanges = excludedPages.reduce((ranges: PageRange[], page) => {
|
||||
this.excludedPagesRanges = excludedPages.reduce((ranges: IPageRange[], page) => {
|
||||
if (!ranges.length) {
|
||||
return [{ startPage: page, endPage: page }];
|
||||
}
|
||||
|
||||
if (page === ranges[ranges.length - 1].endPage + 1) {
|
||||
if (page === Number(ranges[ranges.length - 1].endPage) + 1) {
|
||||
ranges[ranges.length - 1].endPage = page;
|
||||
} else {
|
||||
ranges.push({ startPage: page, endPage: page });
|
||||
@ -73,7 +73,7 @@ export class PageExclusionComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
async includePagesRange(range: PageRange): Promise<void> {
|
||||
async includePagesRange(range: IPageRange): Promise<void> {
|
||||
this._loadingService.start();
|
||||
await this._reanalysisService
|
||||
.includePages(
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||
import { ViewedPages } from '@redaction/red-ui-http';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { ConfigService } from '@services/config.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { ViewedPagesService } from '../../shared/services/viewed-pages.service';
|
||||
import { IViewedPage } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-page-indicator',
|
||||
@ -15,7 +15,7 @@ import { ViewedPagesService } from '../../shared/services/viewed-pages.service';
|
||||
export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@Input() active: boolean;
|
||||
@Input() number: number;
|
||||
@Input() viewedPages: ViewedPages;
|
||||
@Input() viewedPages: IViewedPage[];
|
||||
@Input() activeSelection = false;
|
||||
|
||||
@Output() readonly pageSelected = new EventEmitter<number>();
|
||||
@ -33,7 +33,7 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
||||
) {}
|
||||
|
||||
get activePage() {
|
||||
return this.viewedPages?.pages?.find(p => p.page === this.number);
|
||||
return this.viewedPages?.find(p => p.page === this.number);
|
||||
}
|
||||
|
||||
get read() {
|
||||
@ -112,7 +112,7 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
||||
if (this.activePage) {
|
||||
this.activePage.hasChanges = false;
|
||||
} else {
|
||||
this.viewedPages?.pages?.push({ page: this.number, fileId: this._appStateService.activeFileId });
|
||||
this.viewedPages?.push({ page: this.number, fileId: this._appStateService.activeFileId });
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -121,8 +121,8 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this._viewedPagesService
|
||||
.removePage(this._dossiersService.activeDossierId, this._appStateService.activeFileId, this.number)
|
||||
.subscribe(() => {
|
||||
this.viewedPages?.pages?.splice(
|
||||
this.viewedPages?.pages?.findIndex(p => p.page === this.number),
|
||||
this.viewedPages?.splice(
|
||||
this.viewedPages?.findIndex(p => p.page === this.number),
|
||||
1,
|
||||
);
|
||||
});
|
||||
|
||||
@ -33,7 +33,7 @@ export class PdfViewerDataService {
|
||||
loadActiveFileData(): Observable<FileDataModel> {
|
||||
const file$ = this.downloadOriginalFile(this._appStateService.activeFile);
|
||||
const reactionLog$ = this.loadActiveFileRedactionLog().pipe(catchError(() => of({})));
|
||||
const viewedPages$ = this.getViewedPagesForActiveFile().pipe(catchError(() => of({})));
|
||||
const viewedPages$ = this.getViewedPagesForActiveFile();
|
||||
|
||||
return forkJoin([file$, reactionLog$, viewedPages$]).pipe(
|
||||
map(data => new FileDataModel(this._appStateService.activeFile, ...data)),
|
||||
@ -44,9 +44,9 @@ export class PdfViewerDataService {
|
||||
if (this._permissionsService.canMarkPagesAsViewed()) {
|
||||
return this._viewedPagesService
|
||||
.getViewedPages(this._dossiersService.activeDossierId, this._appStateService.activeFileId)
|
||||
.pipe(catchError(() => of({ pages: [] })));
|
||||
.pipe(catchError(() => of([])));
|
||||
}
|
||||
return of({ pages: [] });
|
||||
return of([]);
|
||||
}
|
||||
|
||||
downloadOriginalFile(file: File): Observable<any> {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { GenericService, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { ViewedPages, ViewedPagesRequest } from '@redaction/red-ui-http';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { IViewedPage, IViewedPagesRequest } from '@red/domain';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -11,7 +12,7 @@ export class ViewedPagesService extends GenericService<unknown> {
|
||||
}
|
||||
|
||||
@Validate()
|
||||
addPage(@RequiredParam() body: ViewedPagesRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
addPage(@RequiredParam() body: IViewedPagesRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
return this._post(body, `${this._defaultModelPath}/${dossierId}/${fileId}`);
|
||||
}
|
||||
|
||||
@ -22,6 +23,6 @@ export class ViewedPagesService extends GenericService<unknown> {
|
||||
|
||||
@Validate()
|
||||
getViewedPages(@RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
return this._getOne<ViewedPages>([dossierId, fileId]);
|
||||
return this._getOne<{ pages?: IViewedPage[] }>([dossierId, fileId]).pipe(map(res => res.pages));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { GenericService, List, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { PageExclusionRequest } from '@redaction/red-ui-http';
|
||||
import { IPageExclusionRequest } from '@red/domain';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -11,12 +11,12 @@ export class ReanalysisService extends GenericService<unknown> {
|
||||
}
|
||||
|
||||
@Validate()
|
||||
excludePages(@RequiredParam() body: PageExclusionRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
excludePages(@RequiredParam() body: IPageExclusionRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
return this._post(body, `exclude-pages/${dossierId}/${fileId}`);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
includePages(@RequiredParam() body: PageExclusionRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
includePages(@RequiredParam() body: IPageExclusionRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
return this._post(body, `include-pages/${dossierId}/${fileId}`);
|
||||
}
|
||||
|
||||
|
||||
@ -3,3 +3,4 @@ export * from './lib/search';
|
||||
export * from './lib/shared/types';
|
||||
export * from './lib/dossier-attributes';
|
||||
export * from './lib/users';
|
||||
export * from './lib/pages';
|
||||
|
||||
4
libs/red-domain/src/lib/pages/index.ts
Normal file
4
libs/red-domain/src/lib/pages/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export * from './page-range';
|
||||
export * from './viewed-page';
|
||||
export * from './viewed-pages.request';
|
||||
export * from './page-exclusion.request';
|
||||
@ -9,8 +9,9 @@
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { PageRange } from './pageRange';
|
||||
import { IPageRange } from './page-range';
|
||||
import { List } from '@iqser/common-ui';
|
||||
|
||||
export interface PageExclusionRequest {
|
||||
pageRanges?: Array<PageRange>;
|
||||
export interface IPageExclusionRequest {
|
||||
pageRanges: List<IPageRange>;
|
||||
}
|
||||
@ -10,7 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface PageRange {
|
||||
endPage?: number;
|
||||
export interface IPageRange {
|
||||
startPage?: number;
|
||||
endPage?: number;
|
||||
}
|
||||
@ -10,7 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface ViewedPage {
|
||||
export interface IViewedPage {
|
||||
fileId?: string;
|
||||
page?: number;
|
||||
userId?: string;
|
||||
@ -10,6 +10,6 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface ViewedPagesRequest {
|
||||
export interface IViewedPagesRequest {
|
||||
page?: number;
|
||||
}
|
||||
@ -35,8 +35,6 @@ export * from './manualAddResponse';
|
||||
export * from './manualRedactionEntry';
|
||||
export * from './notification.model';
|
||||
export * from './notificationResponse';
|
||||
export * from './pageExclusionRequest';
|
||||
export * from './pageRange';
|
||||
export * from './placeholdersResponse';
|
||||
export * from './point';
|
||||
export * from './prepareDownloadRequest';
|
||||
@ -53,7 +51,4 @@ export * from './smtp-configuration';
|
||||
export * from './sectionGrid';
|
||||
export * from './sectionRectangle';
|
||||
export * from './updateDictionary';
|
||||
export * from './viewedPage';
|
||||
export * from './viewedPages';
|
||||
export * from './viewedPagesRequest';
|
||||
export * from './watermarkModel';
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* API Documentation for Redaction Gateway
|
||||
* Description for redaction
|
||||
*
|
||||
* OpenAPI spec version: 1.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { ViewedPage } from './viewedPage';
|
||||
|
||||
export interface ViewedPages {
|
||||
pages?: Array<ViewedPage>;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user