add viewed pages service
This commit is contained in:
parent
ea44a716ab
commit
d4a2629e8f
@ -1,10 +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, ViewedPagesControllerService } from '@redaction/red-ui-http';
|
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';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'redaction-page-indicator',
|
selector: 'redaction-page-indicator',
|
||||||
@ -24,7 +25,7 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
private _subscription: Subscription;
|
private _subscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _viewedPagesControllerService: ViewedPagesControllerService,
|
private readonly _viewedPagesService: ViewedPagesService,
|
||||||
private readonly _appStateService: AppStateService,
|
private readonly _appStateService: AppStateService,
|
||||||
private readonly _dossiersService: DossiersService,
|
private readonly _dossiersService: DossiersService,
|
||||||
private readonly _configService: ConfigService,
|
private readonly _configService: ConfigService,
|
||||||
@ -105,7 +106,7 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
private _markPageRead() {
|
private _markPageRead() {
|
||||||
this._viewedPagesControllerService
|
this._viewedPagesService
|
||||||
.addPage({ page: this.number }, this._dossiersService.activeDossierId, this._appStateService.activeFileId)
|
.addPage({ page: this.number }, this._dossiersService.activeDossierId, this._appStateService.activeFileId)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
if (this.activePage) {
|
if (this.activePage) {
|
||||||
@ -117,7 +118,7 @@ export class PageIndicatorComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _markPageUnread() {
|
private _markPageUnread() {
|
||||||
this._viewedPagesControllerService
|
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?.pages?.splice(
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { forkJoin, Observable, of } from 'rxjs';
|
import { forkJoin, Observable, of } from 'rxjs';
|
||||||
import { catchError, map, tap } from 'rxjs/operators';
|
import { catchError, map, tap } from 'rxjs/operators';
|
||||||
import { ViewedPagesControllerService } from '@redaction/red-ui-http';
|
|
||||||
import { FileDataModel } from '@models/file/file-data.model';
|
import { FileDataModel } from '@models/file/file-data.model';
|
||||||
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';
|
||||||
@ -9,6 +8,7 @@ import { File } from '@models/file/file';
|
|||||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||||
import { FileManagementService } from '../shared/services/file-management.service';
|
import { FileManagementService } from '../shared/services/file-management.service';
|
||||||
import { RedactionLogService } from './redaction-log.service';
|
import { RedactionLogService } from './redaction-log.service';
|
||||||
|
import { ViewedPagesService } from '../shared/services/viewed-pages.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PdfViewerDataService {
|
export class PdfViewerDataService {
|
||||||
@ -18,7 +18,7 @@ export class PdfViewerDataService {
|
|||||||
private readonly _permissionsService: PermissionsService,
|
private readonly _permissionsService: PermissionsService,
|
||||||
private readonly _fileManagementService: FileManagementService,
|
private readonly _fileManagementService: FileManagementService,
|
||||||
private readonly _redactionLogService: RedactionLogService,
|
private readonly _redactionLogService: RedactionLogService,
|
||||||
private readonly _viewedPagesControllerService: ViewedPagesControllerService,
|
private readonly _viewedPagesService: ViewedPagesService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
loadActiveFileRedactionLog() {
|
loadActiveFileRedactionLog() {
|
||||||
@ -42,7 +42,7 @@ export class PdfViewerDataService {
|
|||||||
|
|
||||||
getViewedPagesForActiveFile() {
|
getViewedPagesForActiveFile() {
|
||||||
if (this._permissionsService.canMarkPagesAsViewed()) {
|
if (this._permissionsService.canMarkPagesAsViewed()) {
|
||||||
return this._viewedPagesControllerService
|
return this._viewedPagesService
|
||||||
.getViewedPages(this._dossiersService.activeDossierId, this._appStateService.activeFileId)
|
.getViewedPages(this._dossiersService.activeDossierId, this._appStateService.activeFileId)
|
||||||
.pipe(catchError(() => of({ pages: [] })));
|
.pipe(catchError(() => of({ pages: [] })));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { Injectable, Injector } from '@angular/core';
|
||||||
|
import { GenericService, RequiredParam, Validate } from '@iqser/common-ui';
|
||||||
|
import { ViewedPages, ViewedPagesRequest } from '@redaction/red-ui-http';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class ViewedPagesService extends GenericService<unknown> {
|
||||||
|
constructor(protected readonly _injector: Injector) {
|
||||||
|
super(_injector, 'viewedPages');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Validate()
|
||||||
|
addPage(@RequiredParam() body: ViewedPagesRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||||
|
return this._post(body, `${this._defaultModelPath}/${dossierId}/${fileId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Validate()
|
||||||
|
removePage(@RequiredParam() dossierId: string, @RequiredParam() fileId: string, @RequiredParam() page: number) {
|
||||||
|
return super.delete({}, `${this._defaultModelPath}/${dossierId}/${fileId}/${page}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Validate()
|
||||||
|
getViewedPages(@RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||||
|
return this._getOne<ViewedPages>([dossierId, fileId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,6 @@
|
|||||||
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
|
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
|
||||||
import { Configuration } from './configuration';
|
import { Configuration } from './configuration';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { ViewedPagesControllerService } from './api/viewedPagesController.service';
|
|
||||||
import { WatermarkControllerService } from './api/watermarkController.service';
|
import { WatermarkControllerService } from './api/watermarkController.service';
|
||||||
import { SearchControllerService } from './api/searchController.service';
|
import { SearchControllerService } from './api/searchController.service';
|
||||||
import { NotificationControllerService } from './api/notificationController.service';
|
import { NotificationControllerService } from './api/notificationController.service';
|
||||||
@ -10,7 +9,7 @@ import { NotificationControllerService } from './api/notificationController.serv
|
|||||||
imports: [],
|
imports: [],
|
||||||
declarations: [],
|
declarations: [],
|
||||||
exports: [],
|
exports: [],
|
||||||
providers: [ViewedPagesControllerService, WatermarkControllerService, SearchControllerService, NotificationControllerService],
|
providers: [WatermarkControllerService, SearchControllerService, NotificationControllerService],
|
||||||
})
|
})
|
||||||
export class ApiModule {
|
export class ApiModule {
|
||||||
constructor(@Optional() @SkipSelf() parentModule: ApiModule, @Optional() http: HttpClient) {
|
constructor(@Optional() @SkipSelf() parentModule: ApiModule, @Optional() http: HttpClient) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user