move download stuff to red-domain

This commit is contained in:
Dan Percic 2021-10-29 13:30:36 +03:00
parent f12bb20b39
commit ff2f409079
15 changed files with 50 additions and 104 deletions

View File

@ -1,6 +1,6 @@
import { Component, forwardRef, Injector } from '@angular/core'; import { Component, forwardRef, Injector } from '@angular/core';
import { FileDownloadService } from '@upload-download/services/file-download.service'; import { FileDownloadService } from '@upload-download/services/file-download.service';
import { DownloadStatus } from '@upload-download/model/download-status'; import { DownloadStatus } from '@red/domain';
import { import {
CircleButtonTypes, CircleButtonTypes,
DefaultListingServicesTmp, DefaultListingServicesTmp,

View File

@ -1,15 +1,15 @@
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { import {
DownloadResponse, DownloadStatus,
DownloadStatusResponse, IDownloadResponse,
IDownloadStatus, IDownloadStatus,
PrepareDownloadRequest, IDownloadStatusResponse,
RemoveDownloadRequest, IPrepareDownloadRequest,
} from '@redaction/red-ui-http'; IRemoveDownloadRequest,
} from '@red/domain';
import { interval, Observable } from 'rxjs'; import { interval, Observable } from 'rxjs';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
import { map, mergeMap, tap } from 'rxjs/operators'; import { map, mergeMap, tap } from 'rxjs/operators';
import { DownloadStatus } from '../model/download-status';
import { KeycloakService } from 'keycloak-angular'; import { KeycloakService } from 'keycloak-angular';
import { UserService } from '@services/user.service'; import { UserService } from '@services/user.service';
import { EntitiesService, List, RequiredParam, Validate } from '@iqser/common-ui'; import { EntitiesService, List, RequiredParam, Validate } from '@iqser/common-ui';
@ -48,7 +48,7 @@ export class FileDownloadService extends EntitiesService<DownloadStatus, IDownlo
} }
getStatuses(): Observable<IDownloadStatus[]> { getStatuses(): Observable<IDownloadStatus[]> {
return super._getOne<DownloadStatusResponse>(['status']).pipe(map(res => res.downloadStatus)); return super._getOne<IDownloadStatusResponse>(['status']).pipe(map(res => res.downloadStatus));
} }
async performDownload(status: DownloadStatus) { async performDownload(status: DownloadStatus) {
@ -66,12 +66,12 @@ export class FileDownloadService extends EntitiesService<DownloadStatus, IDownlo
} }
@Validate() @Validate()
prepareDownload(@RequiredParam() body: PrepareDownloadRequest): Observable<DownloadResponse> { prepareDownload(@RequiredParam() body: IPrepareDownloadRequest): Observable<IDownloadResponse> {
return this._post(body, `${this._defaultModelPath}/prepare`); return this._post(body, `${this._defaultModelPath}/prepare`);
} }
@Validate() @Validate()
delete(@RequiredParam() body: RemoveDownloadRequest): Observable<unknown> { delete(@RequiredParam() body: IRemoveDownloadRequest): Observable<unknown> {
return super._post(body, `${this._defaultModelPath}/delete`); return super._post(body, `${this._defaultModelPath}/delete`);
} }
} }

View File

@ -12,3 +12,4 @@ export * from './lib/redaction-log';
export * from './lib/geometry'; export * from './lib/geometry';
export * from './lib/file-attributes'; export * from './lib/file-attributes';
export * from './lib/files'; export * from './lib/files';
export * from './lib/downloads';

View File

@ -1,21 +1,21 @@
import { DownloadStatusType, IDownloadStatus } from '@redaction/red-ui-http';
import { IListable, List } from '@iqser/common-ui'; 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 { export class DownloadStatus implements IDownloadStatus, IListable {
readonly storageId: string;
readonly creationDate?: string; readonly creationDate?: string;
readonly dossierId?: string; readonly dossierId?: string;
readonly downloadFileTypes?: List<DownloadFileType>; readonly downloadFileTypes?: List<DownloadFileType>;
readonly fileIds?: List; readonly fileIds?: List;
readonly fileSize?: number; readonly fileSize: number;
readonly filename?: string; readonly filename?: string;
readonly lastDownload?: string; readonly lastDownload?: string;
readonly mimeType?: string; readonly mimeType?: string;
readonly status?: DownloadStatusType; readonly status?: DownloadStatusType;
readonly storageId?: string;
readonly userId?: string; readonly userId?: string;
readonly size?: string; readonly size?: string;
inProgress: boolean; inProgress = false;
constructor(downloadStatus: IDownloadStatus) { constructor(downloadStatus: IDownloadStatus) {
this.creationDate = downloadStatus.creationDate; this.creationDate = downloadStatus.creationDate;
@ -32,7 +32,7 @@ export class DownloadStatus implements IDownloadStatus, IListable {
this.size = this._size; this.size = this._size;
} }
get id() { get id(): string {
return this.storageId; return this.storageId;
} }
@ -40,7 +40,7 @@ export class DownloadStatus implements IDownloadStatus, IListable {
return this.storageId; return this.storageId;
} }
get isReady() { get isReady(): boolean {
return this.status === 'READY'; return this.status === 'READY';
} }

View File

@ -0,0 +1,5 @@
import { IDownloadStatus } from './download-status';
export interface IDownloadStatusResponse {
downloadStatus?: IDownloadStatus[];
}

View File

@ -1,28 +1,17 @@
/** import { List } from '@iqser/common-ui';
* API Documentation for Redaction Gateway import { DownloadFileType } from '../shared';
* 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';
export interface IDownloadStatus { export interface IDownloadStatus {
readonly creationDate?: string; readonly creationDate?: string;
readonly dossierId?: string; readonly dossierId?: string;
readonly downloadFileTypes?: List<DownloadFileType>; readonly downloadFileTypes?: List<DownloadFileType>;
readonly fileIds?: List; readonly fileIds?: List;
readonly fileSize?: number; readonly fileSize: number;
readonly filename?: string; readonly filename?: string;
readonly lastDownload?: string; readonly lastDownload?: string;
readonly mimeType?: string; readonly mimeType?: string;
readonly status?: DownloadStatusType; readonly status?: DownloadStatusType;
readonly storageId?: string; readonly storageId: string;
readonly userId?: string; readonly userId?: string;
} }

View File

@ -0,0 +1,3 @@
export interface IDownloadResponse {
readonly storageId?: string;
}

View File

@ -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';

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
import { List } from '@iqser/common-ui';
export interface IRemoveDownloadRequest {
storageIds: List;
}

View File

@ -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;
}

View File

@ -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[];
}

View File

@ -4,9 +4,6 @@ export * from './colors';
export * from './createUserRequest'; export * from './createUserRequest';
export * from './digitalSignature'; export * from './digitalSignature';
export * from './digitalSignatureViewModel'; export * from './digitalSignatureViewModel';
export * from './downloadResponse';
export * from './downloadStatus';
export * from './downloadStatusResponse';
export * from './generalConfigurationModel'; export * from './generalConfigurationModel';
export * from './idRemoval'; export * from './idRemoval';
export * from './imageRecategorizationRequest'; export * from './imageRecategorizationRequest';
@ -14,8 +11,6 @@ export * from './licenseReport';
export * from './licenseReportRequest'; export * from './licenseReportRequest';
export * from './manualAddResponse'; export * from './manualAddResponse';
export * from './placeholdersResponse'; export * from './placeholdersResponse';
export * from './prepareDownloadRequest';
export * from './removeDownloadRequest';
export * from './removeRedactionRequest'; export * from './removeRedactionRequest';
export * from './reportData'; export * from './reportData';
export * from './reportTemplate'; export * from './reportTemplate';

View File

@ -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;
}

View File

@ -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<string>;
}