From ff2f409079551a149490f200799dc00c2579004a Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 29 Oct 2021 13:30:36 +0300 Subject: [PATCH] move download stuff to red-domain --- .../downloads-list-screen.component.ts | 2 +- .../services/file-download.service.ts | 18 ++++++++-------- libs/red-domain/src/index.ts | 1 + .../lib/downloads/download-status.model.ts | 14 ++++++------- .../lib/downloads/download-status.response.ts | 5 +++++ .../src/lib/downloads/download-status.ts} | 19 ++++------------- .../src/lib/downloads/download.response.ts | 3 +++ libs/red-domain/src/lib/downloads/index.ts | 6 ++++++ .../lib/downloads/prepare-download.request.ts | 9 ++++++++ .../lib/downloads/remove-download.request.ts | 5 +++++ .../src/lib/model/downloadResponse.ts | 15 ------------- .../src/lib/model/downloadStatusResponse.ts | 16 -------------- libs/red-ui-http/src/lib/model/models.ts | 5 ----- .../src/lib/model/prepareDownloadRequest.ts | 21 ------------------- .../src/lib/model/removeDownloadRequest.ts | 15 ------------- 15 files changed, 50 insertions(+), 104 deletions(-) rename apps/red-ui/src/app/modules/upload-download/model/download-status.ts => libs/red-domain/src/lib/downloads/download-status.model.ts (85%) create mode 100644 libs/red-domain/src/lib/downloads/download-status.response.ts rename libs/{red-ui-http/src/lib/model/downloadStatus.ts => red-domain/src/lib/downloads/download-status.ts} (56%) create mode 100644 libs/red-domain/src/lib/downloads/download.response.ts create mode 100644 libs/red-domain/src/lib/downloads/index.ts create mode 100644 libs/red-domain/src/lib/downloads/prepare-download.request.ts create mode 100644 libs/red-domain/src/lib/downloads/remove-download.request.ts delete mode 100644 libs/red-ui-http/src/lib/model/downloadResponse.ts delete mode 100644 libs/red-ui-http/src/lib/model/downloadStatusResponse.ts delete mode 100644 libs/red-ui-http/src/lib/model/prepareDownloadRequest.ts delete mode 100644 libs/red-ui-http/src/lib/model/removeDownloadRequest.ts diff --git a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts index fc39331e1..73cee8af0 100644 --- a/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts +++ b/apps/red-ui/src/app/components/downloads-list-screen/downloads-list-screen.component.ts @@ -1,6 +1,6 @@ import { Component, forwardRef, Injector } from '@angular/core'; import { FileDownloadService } from '@upload-download/services/file-download.service'; -import { DownloadStatus } from '@upload-download/model/download-status'; +import { DownloadStatus } from '@red/domain'; import { CircleButtonTypes, DefaultListingServicesTmp, diff --git a/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts b/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts index 205ac900a..770411ec7 100644 --- a/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts +++ b/apps/red-ui/src/app/modules/upload-download/services/file-download.service.ts @@ -1,15 +1,15 @@ import { Injectable, Injector } from '@angular/core'; import { - DownloadResponse, - DownloadStatusResponse, + DownloadStatus, + IDownloadResponse, IDownloadStatus, - PrepareDownloadRequest, - RemoveDownloadRequest, -} from '@redaction/red-ui-http'; + IDownloadStatusResponse, + IPrepareDownloadRequest, + IRemoveDownloadRequest, +} from '@red/domain'; import { interval, Observable } from 'rxjs'; import { ConfigService } from '@services/config.service'; import { map, mergeMap, tap } from 'rxjs/operators'; -import { DownloadStatus } from '../model/download-status'; import { KeycloakService } from 'keycloak-angular'; import { UserService } from '@services/user.service'; import { EntitiesService, List, RequiredParam, Validate } from '@iqser/common-ui'; @@ -48,7 +48,7 @@ export class FileDownloadService extends EntitiesService { - return super._getOne(['status']).pipe(map(res => res.downloadStatus)); + return super._getOne(['status']).pipe(map(res => res.downloadStatus)); } async performDownload(status: DownloadStatus) { @@ -66,12 +66,12 @@ export class FileDownloadService extends EntitiesService { + prepareDownload(@RequiredParam() body: IPrepareDownloadRequest): Observable { return this._post(body, `${this._defaultModelPath}/prepare`); } @Validate() - delete(@RequiredParam() body: RemoveDownloadRequest): Observable { + delete(@RequiredParam() body: IRemoveDownloadRequest): Observable { return super._post(body, `${this._defaultModelPath}/delete`); } } diff --git a/libs/red-domain/src/index.ts b/libs/red-domain/src/index.ts index 1d5fcf837..802122ea0 100644 --- a/libs/red-domain/src/index.ts +++ b/libs/red-domain/src/index.ts @@ -12,3 +12,4 @@ export * from './lib/redaction-log'; export * from './lib/geometry'; export * from './lib/file-attributes'; export * from './lib/files'; +export * from './lib/downloads'; diff --git a/apps/red-ui/src/app/modules/upload-download/model/download-status.ts b/libs/red-domain/src/lib/downloads/download-status.model.ts similarity index 85% rename from apps/red-ui/src/app/modules/upload-download/model/download-status.ts rename to libs/red-domain/src/lib/downloads/download-status.model.ts index 495d59daf..fabdb5fa4 100644 --- a/apps/red-ui/src/app/modules/upload-download/model/download-status.ts +++ b/libs/red-domain/src/lib/downloads/download-status.model.ts @@ -1,21 +1,21 @@ -import { DownloadStatusType, IDownloadStatus } from '@redaction/red-ui-http'; import { IListable, List } from '@iqser/common-ui'; -import { DownloadFileType } from '@red/domain'; +import { DownloadStatusType, IDownloadStatus } from './download-status'; +import { DownloadFileType } from '../shared'; export class DownloadStatus implements IDownloadStatus, IListable { + readonly storageId: string; readonly creationDate?: string; readonly dossierId?: string; readonly downloadFileTypes?: List; readonly fileIds?: List; - readonly fileSize?: number; + readonly fileSize: number; readonly filename?: string; readonly lastDownload?: string; readonly mimeType?: string; readonly status?: DownloadStatusType; - readonly storageId?: string; readonly userId?: string; readonly size?: string; - inProgress: boolean; + inProgress = false; constructor(downloadStatus: IDownloadStatus) { this.creationDate = downloadStatus.creationDate; @@ -32,7 +32,7 @@ export class DownloadStatus implements IDownloadStatus, IListable { this.size = this._size; } - get id() { + get id(): string { return this.storageId; } @@ -40,7 +40,7 @@ export class DownloadStatus implements IDownloadStatus, IListable { return this.storageId; } - get isReady() { + get isReady(): boolean { return this.status === 'READY'; } diff --git a/libs/red-domain/src/lib/downloads/download-status.response.ts b/libs/red-domain/src/lib/downloads/download-status.response.ts new file mode 100644 index 000000000..0244b5ad5 --- /dev/null +++ b/libs/red-domain/src/lib/downloads/download-status.response.ts @@ -0,0 +1,5 @@ +import { IDownloadStatus } from './download-status'; + +export interface IDownloadStatusResponse { + downloadStatus?: IDownloadStatus[]; +} diff --git a/libs/red-ui-http/src/lib/model/downloadStatus.ts b/libs/red-domain/src/lib/downloads/download-status.ts similarity index 56% rename from libs/red-ui-http/src/lib/model/downloadStatus.ts rename to libs/red-domain/src/lib/downloads/download-status.ts index 9622665de..fc5b8f28a 100644 --- a/libs/red-ui-http/src/lib/model/downloadStatus.ts +++ b/libs/red-domain/src/lib/downloads/download-status.ts @@ -1,28 +1,17 @@ -/** - * 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 { List } from '../red-types'; -import { DownloadFileType } from '@red/domain'; +import { List } from '@iqser/common-ui'; +import { DownloadFileType } from '../shared'; export interface IDownloadStatus { readonly creationDate?: string; readonly dossierId?: string; readonly downloadFileTypes?: List; readonly fileIds?: List; - readonly fileSize?: number; + readonly fileSize: number; readonly filename?: string; readonly lastDownload?: string; readonly mimeType?: string; readonly status?: DownloadStatusType; - readonly storageId?: string; + readonly storageId: string; readonly userId?: string; } diff --git a/libs/red-domain/src/lib/downloads/download.response.ts b/libs/red-domain/src/lib/downloads/download.response.ts new file mode 100644 index 000000000..d627fe509 --- /dev/null +++ b/libs/red-domain/src/lib/downloads/download.response.ts @@ -0,0 +1,3 @@ +export interface IDownloadResponse { + readonly storageId?: string; +} diff --git a/libs/red-domain/src/lib/downloads/index.ts b/libs/red-domain/src/lib/downloads/index.ts new file mode 100644 index 000000000..ef09c02fd --- /dev/null +++ b/libs/red-domain/src/lib/downloads/index.ts @@ -0,0 +1,6 @@ +export * from './download.response'; +export * from './download-status'; +export * from './download-status.model'; +export * from './download-status.response'; +export * from './prepare-download.request'; +export * from './remove-download.request'; diff --git a/libs/red-domain/src/lib/downloads/prepare-download.request.ts b/libs/red-domain/src/lib/downloads/prepare-download.request.ts new file mode 100644 index 000000000..cade875c9 --- /dev/null +++ b/libs/red-domain/src/lib/downloads/prepare-download.request.ts @@ -0,0 +1,9 @@ +/** + * Object containing information on which file and report types should be included in the download. + */ +import { List } from '@iqser/common-ui'; + +export interface IPrepareDownloadRequest { + readonly dossierId?: string; + readonly fileIds?: List; +} diff --git a/libs/red-domain/src/lib/downloads/remove-download.request.ts b/libs/red-domain/src/lib/downloads/remove-download.request.ts new file mode 100644 index 000000000..bef3953de --- /dev/null +++ b/libs/red-domain/src/lib/downloads/remove-download.request.ts @@ -0,0 +1,5 @@ +import { List } from '@iqser/common-ui'; + +export interface IRemoveDownloadRequest { + storageIds: List; +} diff --git a/libs/red-ui-http/src/lib/model/downloadResponse.ts b/libs/red-ui-http/src/lib/model/downloadResponse.ts deleted file mode 100644 index b875b7ac0..000000000 --- a/libs/red-ui-http/src/lib/model/downloadResponse.ts +++ /dev/null @@ -1,15 +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 DownloadResponse { - readonly storageId?: string; -} diff --git a/libs/red-ui-http/src/lib/model/downloadStatusResponse.ts b/libs/red-ui-http/src/lib/model/downloadStatusResponse.ts deleted file mode 100644 index a35b3942d..000000000 --- a/libs/red-ui-http/src/lib/model/downloadStatusResponse.ts +++ /dev/null @@ -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 { IDownloadStatus } from './downloadStatus'; - -export interface DownloadStatusResponse { - downloadStatus?: IDownloadStatus[]; -} diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index 545a18994..72342e10d 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -4,9 +4,6 @@ export * from './colors'; export * from './createUserRequest'; export * from './digitalSignature'; export * from './digitalSignatureViewModel'; -export * from './downloadResponse'; -export * from './downloadStatus'; -export * from './downloadStatusResponse'; export * from './generalConfigurationModel'; export * from './idRemoval'; export * from './imageRecategorizationRequest'; @@ -14,8 +11,6 @@ export * from './licenseReport'; export * from './licenseReportRequest'; export * from './manualAddResponse'; export * from './placeholdersResponse'; -export * from './prepareDownloadRequest'; -export * from './removeDownloadRequest'; export * from './removeRedactionRequest'; export * from './reportData'; export * from './reportTemplate'; diff --git a/libs/red-ui-http/src/lib/model/prepareDownloadRequest.ts b/libs/red-ui-http/src/lib/model/prepareDownloadRequest.ts deleted file mode 100644 index 6fe625402..000000000 --- a/libs/red-ui-http/src/lib/model/prepareDownloadRequest.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. - */ - -import { List } from '../red-types'; - -/** - * Object containing information on which file and report types should be included in the download. - */ -export interface PrepareDownloadRequest { - readonly dossierId?: string; - readonly fileIds?: List; -} diff --git a/libs/red-ui-http/src/lib/model/removeDownloadRequest.ts b/libs/red-ui-http/src/lib/model/removeDownloadRequest.ts deleted file mode 100644 index db24606fc..000000000 --- a/libs/red-ui-http/src/lib/model/removeDownloadRequest.ts +++ /dev/null @@ -1,15 +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 RemoveDownloadRequest { - storageIds?: Array; -}