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