From 223399d6ebb02a2fc8d64a3a18230a3580816fc6 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 29 Oct 2021 13:51:43 +0300 Subject: [PATCH] move reports to red domain --- .../license-information-screen.component.ts | 8 +-- .../reports/reports-screen.component.ts | 11 ++-- .../admin/services/licence-report.service.ts | 6 +-- .../add-dossier-dialog.component.ts | 5 +- ...edit-dossier-download-package.component.ts | 7 ++- .../app/services/report-template.service.ts | 5 +- libs/red-domain/src/index.ts | 1 + libs/red-domain/src/lib/reports/index.ts | 5 ++ .../src/lib/reports/license-report.request.ts | 8 +++ .../src/lib/reports/license-report.ts | 16 ++++++ .../red-domain/src/lib/reports/report-data.ts | 13 +++++ .../src/lib/reports/report-template.ts | 9 ++++ libs/red-domain/src/lib/reports/types.ts | 15 ++++++ .../src/lib/model/licenseReport.ts | 27 ---------- .../src/lib/model/licenseReportRequest.ts | 18 ------- libs/red-ui-http/src/lib/model/models.ts | 4 -- libs/red-ui-http/src/lib/model/reportData.ts | 52 ------------------- .../src/lib/model/reportTemplate.ts | 21 -------- 18 files changed, 88 insertions(+), 143 deletions(-) create mode 100644 libs/red-domain/src/lib/reports/index.ts create mode 100644 libs/red-domain/src/lib/reports/license-report.request.ts create mode 100644 libs/red-domain/src/lib/reports/license-report.ts create mode 100644 libs/red-domain/src/lib/reports/report-data.ts create mode 100644 libs/red-domain/src/lib/reports/report-template.ts create mode 100644 libs/red-domain/src/lib/reports/types.ts delete mode 100644 libs/red-ui-http/src/lib/model/licenseReport.ts delete mode 100644 libs/red-ui-http/src/lib/model/licenseReportRequest.ts delete mode 100644 libs/red-ui-http/src/lib/model/reportData.ts delete mode 100644 libs/red-ui-http/src/lib/model/reportTemplate.ts diff --git a/apps/red-ui/src/app/modules/admin/screens/license-information/license-information-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/license-information/license-information-screen.component.ts index 7e8c5843c..00006cde9 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license-information/license-information-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license-information/license-information-screen.component.ts @@ -1,5 +1,4 @@ import { Component, OnInit } from '@angular/core'; -import { LicenseReport } from '@redaction/red-ui-http'; import { ConfigService } from '@services/config.service'; import * as moment from 'moment'; import { TranslateService } from '@ngx-translate/core'; @@ -8,6 +7,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { UserService } from '@services/user.service'; import { RouterHistoryService } from '@services/router-history.service'; import { LicenseReportService } from '../../services/licence-report.service'; +import { ILicenseReport } from '@red/domain'; @Component({ selector: 'redaction-license-information-screen', @@ -24,9 +24,9 @@ export class LicenseInformationScreenComponent implements OnInit { }, ]; - currentInfo: LicenseReport = {}; - totalInfo: LicenseReport = {}; - unlicensedInfo: LicenseReport = {}; + currentInfo: ILicenseReport = {}; + totalInfo: ILicenseReport = {}; + unlicensedInfo: ILicenseReport = {}; totalLicensedNumberOfPages = 0; analysisPercentageOfLicense = 100; barChart: any[]; diff --git a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts index e691adcf4..24196c0c4 100644 --- a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts @@ -1,7 +1,7 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { AppStateService } from '@state/app-state.service'; -import { PlaceholdersResponse, ReportTemplate } from '@redaction/red-ui-http'; +import { PlaceholdersResponse } from '@redaction/red-ui-http'; import { download } from '@utils/file-download-utils'; import { ConfirmationDialogInput, LoadingService, Toaster } from '@iqser/common-ui'; import { PermissionsService } from '@services/permissions.service'; @@ -14,6 +14,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { AdminDialogService } from '../../services/admin-dialog.service'; import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service'; import { ReportTemplateService } from '@services/report-template.service'; +import { IReportTemplate } from '@red/domain'; interface Placeholder { placeholder: string; @@ -31,7 +32,7 @@ const placeholderTypes: PlaceholderType[] = ['generalPlaceholders', 'fileAttribu }) export class ReportsScreenComponent implements OnInit { placeholders: Placeholder[]; - availableTemplates: ReportTemplate[]; + availableTemplates: IReportTemplate[]; @ViewChild('fileInput') private _fileInput: ElementRef; @@ -57,7 +58,7 @@ export class ReportsScreenComponent implements OnInit { this._loadingService.loadWhile(this._uploadTemplate($event)); } - async download(template: ReportTemplate) { + async download(template: IReportTemplate) { this._loadingService.start(); try { const data = await this._reportTemplateService @@ -71,7 +72,7 @@ export class ReportsScreenComponent implements OnInit { } } - deleteTemplate(template: ReportTemplate) { + deleteTemplate(template: IReportTemplate) { this._dialogService.openDialog('confirm', null, null, () => { this._loadingService.loadWhile(this._deleteTemplate(template)); }); @@ -120,7 +121,7 @@ export class ReportsScreenComponent implements OnInit { this._fileInput.nativeElement.value = null; } - private async _deleteTemplate(template: ReportTemplate) { + private async _deleteTemplate(template: IReportTemplate) { await this._reportTemplateService.delete(template.dossierTemplateId, template.templateId).toPromise(); await this._loadReportTemplates(); } diff --git a/apps/red-ui/src/app/modules/admin/services/licence-report.service.ts b/apps/red-ui/src/app/modules/admin/services/licence-report.service.ts index 5ee5bd9eb..fa1be5312 100644 --- a/apps/red-ui/src/app/modules/admin/services/licence-report.service.ts +++ b/apps/red-ui/src/app/modules/admin/services/licence-report.service.ts @@ -1,15 +1,15 @@ import { Injectable, Injector } from '@angular/core'; import { GenericService, QueryParam, RequiredParam, Validate } from '@iqser/common-ui'; -import { LicenseReport, LicenseReportRequest } from '@redaction/red-ui-http'; +import { ILicenseReport, ILicenseReportRequest } from '@red/domain'; @Injectable() -export class LicenseReportService extends GenericService { +export class LicenseReportService extends GenericService { constructor(protected readonly _injector: Injector) { super(_injector, 'report'); } @Validate() - licenseReport(@RequiredParam() body: LicenseReportRequest, limit?: number, offset?: number) { + licenseReport(@RequiredParam() body: ILicenseReportRequest, limit?: number, offset?: number) { const queryParams: QueryParam[] = []; if (limit) { queryParams.push({ key: 'limit', value: limit }); diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/add-dossier-dialog/add-dossier-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/add-dossier-dialog/add-dossier-dialog.component.ts index 8d9d6080e..65acb031a 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/add-dossier-dialog/add-dossier-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/add-dossier-dialog/add-dossier-dialog.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; import { MatDialogRef } from '@angular/material/dialog'; -import { ReportTemplate } from '@redaction/red-ui-http'; +import { DownloadFileType, IDossierRequest, IDossierTemplate, IReportTemplate } from '@red/domain'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import * as moment from 'moment'; import { downloadTypesTranslations } from '../../../../translations/download-types-translations'; @@ -8,7 +8,6 @@ import { IconButtonTypes } from '@iqser/common-ui'; import { DossiersService } from '@services/entity-services/dossiers.service'; import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service'; import { ReportTemplateService } from '@services/report-template.service'; -import { DownloadFileType, IDossierRequest, IDossierTemplate } from '@red/domain'; @Component({ templateUrl: './add-dossier-dialog.component.html', @@ -69,7 +68,7 @@ export class AddDossierDialogComponent { return this.dossierForm.invalid; } - reportTemplateValueMapper = (reportTemplate: ReportTemplate) => reportTemplate.templateId; + reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId; async saveDossier(addMembers = false) { const savedDossier = await this._dossiersService.createOrUpdate(this._formToObject()).toPromise(); diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/download-package/edit-dossier-download-package.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/download-package/edit-dossier-download-package.component.ts index c9ef6f225..dc9931e08 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/download-package/edit-dossier-download-package.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/download-package/edit-dossier-download-package.component.ts @@ -1,7 +1,6 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { ReportTemplate } from '@redaction/red-ui-http'; +import { Dossier, DownloadFileType, IReportTemplate } from '@red/domain'; import { FormBuilder, FormGroup } from '@angular/forms'; -import { Dossier, DownloadFileType } from '@red/domain'; import { EditDossierSectionInterface } from '../edit-dossier-section.interface'; import { downloadTypesTranslations } from '../../../../../translations/download-types-translations'; import { DossiersService } from '@services/entity-services/dossiers.service'; @@ -18,7 +17,7 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS key: type, label: downloadTypesTranslations[type], })); - availableReportTypes: ReportTemplate[] = []; + availableReportTypes: IReportTemplate[] = []; @Input() dossier: Dossier; @Output() readonly updateDossier = new EventEmitter(); @@ -62,7 +61,7 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS return this.dossierForm?.invalid; } - reportTemplateValueMapper = (reportTemplate: ReportTemplate) => reportTemplate.templateId; + reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId; async ngOnInit() { this.availableReportTypes = diff --git a/apps/red-ui/src/app/services/report-template.service.ts b/apps/red-ui/src/app/services/report-template.service.ts index 9f24f9f50..d59f2a264 100644 --- a/apps/red-ui/src/app/services/report-template.service.ts +++ b/apps/red-ui/src/app/services/report-template.service.ts @@ -1,8 +1,9 @@ import { Injectable, Injector } from '@angular/core'; import { GenericService, HeadersConfiguration, RequiredParam, Validate } from '@iqser/common-ui'; -import { PlaceholdersResponse, ReportTemplate } from '@redaction/red-ui-http'; +import { PlaceholdersResponse } from '@redaction/red-ui-http'; import { Observable } from 'rxjs'; import { HttpResponse } from '@angular/common/http'; +import { IReportTemplate } from '@red/domain'; @Injectable({ providedIn: 'root', @@ -35,7 +36,7 @@ export class ReportTemplateService extends GenericService { @Validate() getAvailableReportTemplates(@RequiredParam() dossierTemplateId: string) { - return this.getAll(`${this._defaultModelPath}/${dossierTemplateId}`); + return this.getAll(`${this._defaultModelPath}/${dossierTemplateId}`); } @Validate() diff --git a/libs/red-domain/src/index.ts b/libs/red-domain/src/index.ts index 802122ea0..0ce6beffa 100644 --- a/libs/red-domain/src/index.ts +++ b/libs/red-domain/src/index.ts @@ -13,3 +13,4 @@ export * from './lib/geometry'; export * from './lib/file-attributes'; export * from './lib/files'; export * from './lib/downloads'; +export * from './lib/reports'; diff --git a/libs/red-domain/src/lib/reports/index.ts b/libs/red-domain/src/lib/reports/index.ts new file mode 100644 index 000000000..4626c6c39 --- /dev/null +++ b/libs/red-domain/src/lib/reports/index.ts @@ -0,0 +1,5 @@ +export * from './report-data'; +export * from './report-template'; +export * from './types'; +export * from './license-report.request'; +export * from './license-report'; diff --git a/libs/red-domain/src/lib/reports/license-report.request.ts b/libs/red-domain/src/lib/reports/license-report.request.ts new file mode 100644 index 000000000..f12577f42 --- /dev/null +++ b/libs/red-domain/src/lib/reports/license-report.request.ts @@ -0,0 +1,8 @@ +import { List } from '@iqser/common-ui'; + +export interface ILicenseReportRequest { + dossierIds?: List; + endDate?: Date; + requestId?: string; + startDate?: Date; +} diff --git a/libs/red-domain/src/lib/reports/license-report.ts b/libs/red-domain/src/lib/reports/license-report.ts new file mode 100644 index 000000000..d0095cdca --- /dev/null +++ b/libs/red-domain/src/lib/reports/license-report.ts @@ -0,0 +1,16 @@ +import { IReportData } from './report-data'; + +export interface ILicenseReport { + data?: IReportData[]; + endDate?: Date; + limit?: number; + numberOfAnalyses?: number; + numberOfAnalyzedFiles?: number; + numberOfAnalyzedPages?: number; + numberOfDossiers?: number; + numberOfOcrFiles?: number; + numberOfOcrPages?: number; + offset?: number; + requestId?: string; + startDate?: Date; +} diff --git a/libs/red-domain/src/lib/reports/report-data.ts b/libs/red-domain/src/lib/reports/report-data.ts new file mode 100644 index 000000000..3172a586c --- /dev/null +++ b/libs/red-domain/src/lib/reports/report-data.ts @@ -0,0 +1,13 @@ +import { ReportStatus } from './types'; + +export interface IReportData { + addedDate?: Date; + analysisCount?: number; + deletedDate?: Date; + dossier?: string; + fileName?: string; + lastUpdatedDate?: Date; + numberOfAnalyzedPages?: number; + numberOfOcrPages?: number; + status?: ReportStatus; +} diff --git a/libs/red-domain/src/lib/reports/report-template.ts b/libs/red-domain/src/lib/reports/report-template.ts new file mode 100644 index 000000000..815b31cc8 --- /dev/null +++ b/libs/red-domain/src/lib/reports/report-template.ts @@ -0,0 +1,9 @@ +export interface IReportTemplate { + activeByDefault?: boolean; + dossierTemplateId?: string; + fileName?: string; + multiFileReport?: boolean; + storageId?: string; + templateId?: string; + uploadDate?: string; +} diff --git a/libs/red-domain/src/lib/reports/types.ts b/libs/red-domain/src/lib/reports/types.ts new file mode 100644 index 000000000..c01f2da55 --- /dev/null +++ b/libs/red-domain/src/lib/reports/types.ts @@ -0,0 +1,15 @@ +export const ReportStatuses = { + APPROVED: 'APPROVED', + DELETED: 'DELETED', + ERROR: 'ERROR', + FULLREPROCESS: 'FULLREPROCESS', + OCR_PROCESSING: 'OCR_PROCESSING', + PROCESSING: 'PROCESSING', + REPROCESS: 'REPROCESS', + UNASSIGNED: 'UNASSIGNED', + UNDER_APPROVAL: 'UNDER_APPROVAL', + UNDER_REVIEW: 'UNDER_REVIEW', + UNPROCESSED: 'UNPROCESSED', +} as const; + +export type ReportStatus = keyof typeof ReportStatuses; diff --git a/libs/red-ui-http/src/lib/model/licenseReport.ts b/libs/red-ui-http/src/lib/model/licenseReport.ts deleted file mode 100644 index 4a483e07e..000000000 --- a/libs/red-ui-http/src/lib/model/licenseReport.ts +++ /dev/null @@ -1,27 +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 { ReportData } from './reportData'; - -export interface LicenseReport { - data?: Array; - endDate?: Date; - limit?: number; - numberOfAnalyses?: number; - numberOfAnalyzedFiles?: number; - numberOfAnalyzedPages?: number; - numberOfDossiers?: number; - numberOfOcrFiles?: number; - numberOfOcrPages?: number; - offset?: number; - requestId?: string; - startDate?: Date; -} diff --git a/libs/red-ui-http/src/lib/model/licenseReportRequest.ts b/libs/red-ui-http/src/lib/model/licenseReportRequest.ts deleted file mode 100644 index 24f552f0c..000000000 --- a/libs/red-ui-http/src/lib/model/licenseReportRequest.ts +++ /dev/null @@ -1,18 +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. - */ - -export interface LicenseReportRequest { - dossierIds?: Array; - endDate?: Date; - requestId?: string; - startDate?: Date; -} diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index 94cabeb21..15132039e 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -6,11 +6,7 @@ export * from './digitalSignatureViewModel'; export * from './generalConfigurationModel'; export * from './idRemoval'; export * from './imageRecategorizationRequest'; -export * from './licenseReport'; -export * from './licenseReportRequest'; export * from './placeholdersResponse'; -export * from './reportData'; -export * from './reportTemplate'; export * from './rules'; export * from './smtp-configuration'; export * from './watermarkModel'; diff --git a/libs/red-ui-http/src/lib/model/reportData.ts b/libs/red-ui-http/src/lib/model/reportData.ts deleted file mode 100644 index 1be0f479b..000000000 --- a/libs/red-ui-http/src/lib/model/reportData.ts +++ /dev/null @@ -1,52 +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. - */ - -export interface ReportData { - addedDate?: Date; - analysisCount?: number; - deletedDate?: Date; - dossier?: string; - fileName?: string; - lastUpdatedDate?: Date; - numberOfAnalyzedPages?: number; - numberOfOcrPages?: number; - status?: ReportData.StatusEnum; -} - -export namespace ReportData { - export type StatusEnum = - | 'APPROVED' - | 'DELETED' - | 'ERROR' - | 'FULLREPROCESS' - | 'INDEXING' - | 'OCR_PROCESSING' - | 'PROCESSING' - | 'REPROCESS' - | 'UNASSIGNED' - | 'UNDER_APPROVAL' - | 'UNDER_REVIEW' - | 'UNPROCESSED'; - export const StatusEnum = { - APPROVED: 'APPROVED' as StatusEnum, - DELETED: 'DELETED' as StatusEnum, - ERROR: 'ERROR' as StatusEnum, - FULLREPROCESS: 'FULLREPROCESS' as StatusEnum, - OCR_PROCESSING: 'OCR_PROCESSING' as StatusEnum, - PROCESSING: 'PROCESSING' as StatusEnum, - REPROCESS: 'REPROCESS' as StatusEnum, - UNASSIGNED: 'UNASSIGNED' as StatusEnum, - UNDER_APPROVAL: 'UNDER_APPROVAL' as StatusEnum, - UNDER_REVIEW: 'UNDER_REVIEW' as StatusEnum, - UNPROCESSED: 'UNPROCESSED' as StatusEnum, - }; -} diff --git a/libs/red-ui-http/src/lib/model/reportTemplate.ts b/libs/red-ui-http/src/lib/model/reportTemplate.ts deleted file mode 100644 index 362155b99..000000000 --- a/libs/red-ui-http/src/lib/model/reportTemplate.ts +++ /dev/null @@ -1,21 +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. - */ - -export interface ReportTemplate { - activeByDefault?: boolean; - dossierTemplateId?: string; - fileName?: string; - multiFileReport?: boolean; - storageId?: string; - templateId?: string; - uploadDate?: string; -}