Commit 70c4cff1 authored by Florent POITTEVIN's avatar Florent POITTEVIN
Browse files

feat: 1593 refacto download and send public download directly to browser

parent 626d4e34
......@@ -23,7 +23,6 @@ import {PreservationPlanningSipStateModel} from "@preservation-planning/sip/stor
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {ApiResourceNameEnum} from "@shared/enums/api-resource-name.enum";
import {AdminResourceApiEnum} from "@shared/enums/api.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {RoutesEnum} from "@shared/enums/routes.enum";
import {DownloadService} from "@shared/services/download.service";
......@@ -120,10 +119,7 @@ export class AdminMetadataTypeState extends ResourceState<AdminMetadataTypeState
ext = "json";
}
const fileName = "metadata_type_" + StringUtil.convertToSnakeCase(action.metadataType.name) + "." + ext;
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(`${this._urlResource}/${action.metadataType.resId}/${ApiResourceNameEnum.SCHEMA}`, fileName).subscribe(() => {
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, `${this._urlResource}/${action.metadataType.resId}/${ApiResourceNameEnum.SCHEMA}`, fileName);
}
@Action(AdminMetadataTypeAction.TestFile)
......
......@@ -41,7 +41,6 @@ import {defaultStatusHistoryInitValue} from "@shared/stores/status-history/statu
import {Observable} from "rxjs";
import {
catchError,
map,
tap,
} from "rxjs/operators";
import {
......@@ -51,7 +50,6 @@ import {
CompositionStateModel,
defaultCompositionStateInitValue,
defaultResourceStateInitValue,
HttpStatus,
isNullOrUndefined,
MappingObjectUtil,
MARK_AS_TRANSLATABLE,
......@@ -228,11 +226,9 @@ export class DepositDataFileState extends CompositionState<DepositDataFileStateM
}
@Action(DepositDataFileAction.Download)
download(ctx: StateContext<DepositDataFileStateModel>, action: DepositDataFileAction.Download): Observable<boolean> {
download(ctx: StateContext<DepositDataFileStateModel>, action: DepositDataFileAction.Download): void {
const url = `${this._urlResource}/${action.parentId}/${ApiResourceNameEnum.DATAFILE}/${action.dataFile.resId}/${ApiActionEnum.DL}`;
return this.downloadService.download(url, action.dataFile.fileName, action.dataFile.fileSize).pipe(
map(result => result === HttpStatus.OK),
);
this.downloadService.download(false, url, action.dataFile.fileName, action.dataFile.fileSize);
}
@Action(DepositDataFileAction.ChangeCurrentFolder)
......
......@@ -77,7 +77,6 @@ import {
Store,
} from "@ngxs/store";
import {ApiResourceNameEnum} from "@shared/enums/api-resource-name.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {PollingHelper} from "@shared/helpers/polling.helper";
import {DataFile} from "@shared/models/business/data-file.model";
import {FileListModel} from "@shared/models/business/file-list.model";
......@@ -886,19 +885,14 @@ export class DepositState extends ResourceLogoState<DepositStateModel, Deposit>
}
@Action(DepositAction.Download)
download(ctx: StateContext<DepositStateModel>, action: DepositAction.Download): Observable<boolean> {
download(ctx: StateContext<DepositStateModel>, action: DepositAction.Download): void {
let fileName = this._DEPOSIT_FILE_DOWNLOAD_PREFIX + action.id;
let url = `${this._urlResource}/${action.id}/${ApiActionEnum.DL}`;
if (isNotNullNorUndefined(action.fullFolderName)) {
url = url + `?${this._FOLDER_QUERY_PARAM}=${action.fullFolderName}`;
fileName = fileName + action.fullFolderName;
}
return this.downloadService.download(url, fileName + this._ZIP_EXTENSION).pipe(
map(result => {
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadedSuccessfully);
return result === HttpStatus.OK;
}),
);
this.downloadService.download(false, url, fileName + this._ZIP_EXTENSION);
}
@Action(DepositAction.ComputeModeTab)
......
......@@ -137,7 +137,7 @@ export class HomeDetailRoutable extends SharedAbstractPresentational implements
}
download(archive: Archive): void {
this._store.dispatch(new SharedArchiveAction.Download(archive.resId, archive.title, archive.size));
this._store.dispatch(new SharedArchiveAction.Download(archive));
}
addToCart(archive: Archive): void {
......
......@@ -214,7 +214,7 @@ export class HomeSearchRoutable extends SharedAbstractPresentational implements
}
download(archive: Archive): void {
this.store.dispatch(new SharedArchiveAction.Download(archive.resId, archive.title, archive.size));
this.store.dispatch(new SharedArchiveAction.Download(archive));
}
addToCart(archive: Archive): void {
......
......@@ -229,7 +229,7 @@ export class OrderMyOrderDetailEditRoutable extends SharedAbstractDetailEditComm
}
downloadArchive(archive: Archive): void {
this._store.dispatch(new SharedArchiveAction.Download(archive.resId, archive.title, archive.size));
this._store.dispatch(new SharedArchiveAction.Download(archive));
}
downloadOrder(): void {
......
......@@ -87,10 +87,7 @@ export class PreservationPlanningDipDataFileState extends CompositionState<Prese
@Action(PreservationPlanningDipDataFileAction.Download)
download(ctx: StateContext<PreservationPlanningDipDataFileStateModel>, action: PreservationPlanningDipDataFileAction.Download): void {
const url = `${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.DL}`;
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(url, action.dataFile.fileName, action.dataFile.fileSize).subscribe(() => {
this.notificationService.showSuccess(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, url, action.dataFile.fileName, action.dataFile.fileSize);
}
@Action(PreservationPlanningDipDataFileAction.Resume)
......
......@@ -31,7 +31,6 @@ import {
PreservationPlanningDipStatusHistoryStateModel,
} from "@preservation-planning/dip/stores/status-history/preservation-planning-dip-status-history.state";
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {
DepositRoutesEnum,
RoutesEnum,
......@@ -141,10 +140,7 @@ export class PreservationPlanningDipState extends ResourceState<PreservationPlan
@Action(PreservationPlanningDipAction.Download)
download(ctx: StateContext<PreservationPlanningDipStateModel>, action: PreservationPlanningDipAction.Download): void {
const fileName = "dip_" + action.id + ".zip";
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(`${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName).subscribe(() => {
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, `${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName);
}
@Action(PreservationPlanningDipAction.Resume)
......
......@@ -24,7 +24,6 @@ import {
PreservationPlanningSipCollectionStatusHistoryStateModel,
} from "@preservation-planning/sip/stores/collection/status-history/preservation-planning-sip-collection-status-history.state";
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {
AppRoutesEnum,
RoutesEnum,
......@@ -94,9 +93,6 @@ export class PreservationPlanningSipCollectionState extends CompositionState<Pre
downloadAip(ctx: StateContext<PreservationPlanningSipCollectionStateModel>, action: PreservationPlanningSipCollectionAction.DownloadAip): void {
// NOT WORK
const url = `${this._urlResource}/${action.parentId}/${this._resourceName}/${action.aip.resId}/${ApiActionEnum.DL}`;
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(url, action.aip.info.name, action.aip.archiveSize).subscribe(() => {
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, url, action.aip.info.name, action.aip.archiveSize);
}
}
......@@ -87,10 +87,7 @@ export class PreservationPlanningSipDataFileState extends CompositionState<Prese
@Action(PreservationPlanningSipDataFileAction.Download)
download(ctx: StateContext<PreservationPlanningSipDataFileStateModel>, action: PreservationPlanningSipDataFileAction.Download): void {
const url = `${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.DL}`;
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(url, action.dataFile.fileName, action.dataFile.fileSize).subscribe(() => {
this.notificationService.showSuccess(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, url, action.dataFile.fileName, action.dataFile.fileSize);
}
@Action(PreservationPlanningSipDataFileAction.Resume)
......
......@@ -27,7 +27,6 @@ import {
PreservationPlanningSipStatusHistoryStateModel,
} from "@preservation-planning/sip/stores/status-history/preservation-planning-sip-status-history.state";
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {Result} from "@shared/models/business/result.model";
import {DownloadService} from "@shared/services/download.service";
import {defaultStatusHistoryInitValue} from "@shared/stores/status-history/status-history.state";
......@@ -116,10 +115,7 @@ export class PreservationPlanningSipState extends ResourceState<PreservationPlan
@Action(PreservationPlanningSipAction.Download)
download(ctx: StateContext<PreservationPlanningSipStateModel>, action: PreservationPlanningSipAction.Download): void {
const fileName = "sip_" + action.id + ".zip";
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(`${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName).subscribe(() => {
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, `${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName);
}
@Action(PreservationPlanningSipAction.Resume)
......
......@@ -366,12 +366,13 @@ export class LabelTranslateEnum {
static fileDownloadStart: string = MARK_AS_TRANSLATABLE("general.notification.fileDownloadStart");
static fileDownloadedSuccessfully: string = MARK_AS_TRANSLATABLE("general.notification.fileDownloadedSuccessfully");
static fileDownloadFail: string = MARK_AS_TRANSLATABLE("general.notification.fileDownloadFail");
static fileDownloadForbidden: string = MARK_AS_TRANSLATABLE("general.notification.fileDownloadForbidden");
static resourceResumed: string = MARK_AS_TRANSLATABLE("general.notification.resourceResumed");
static unableResumedResource: string = MARK_AS_TRANSLATABLE("general.notification.unableResumedResource");
static objectCreated: string = MARK_AS_TRANSLATABLE("general.notification.objectCreated");
static objectUpdated: string = MARK_AS_TRANSLATABLE("general.notification.objectUpdated");
static objectDeleted: string = MARK_AS_TRANSLATABLE("general.notification.objectDeleted");
static notAllowToDownloadArchive: string = MARK_AS_TRANSLATABLE("general.notification.notAllowToDownloadArchive");
static storagionInjectNumber: string = MARK_AS_TRANSLATABLE("general.injected.storagionInjectNumber");
static seeInStoragionInjectNumber: string = MARK_AS_TRANSLATABLE("general.injected.seeInStoragionInjectNumber");
......
......@@ -13,7 +13,6 @@ import {
} from "@ngxs/store";
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {ApiResourceNameEnum} from "@shared/enums/api-resource-name.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {AipHelper} from "@shared/features/aip/helpers/aip.helper";
import {
......@@ -81,10 +80,7 @@ export class SharedAipCollectionState extends CompositionState<SharedAipCollecti
@Action(SharedAipCollectionAction.DownloadAip)
downloadAip(ctx: StateContext<SharedAipCollectionStateModel>, action: SharedAipCollectionAction.DownloadAip): void {
const url = `${this._urlResource}/${action.parentId}/${this._resourceName}/${action.aip.resId}/${ApiActionEnum.DL}`;
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(url, action.aip.info.name, action.aip.archiveSize).subscribe(() => {
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, url, action.aip.info.name, action.aip.archiveSize);
}
@Action(SharedAipCollectionAction.GoToAip)
......
......@@ -85,10 +85,7 @@ export class SharedAipDataFileState extends CompositionState<SharedAipDataFileSt
@Action(SharedAipDataFileAction.Download)
download(ctx: StateContext<SharedAipDataFileStateModel>, action: SharedAipDataFileAction.Download): void {
const url = `${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.DL}`;
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(url, action.dataFile.fileName, action.dataFile.fileSize).subscribe(() => {
this.notificationService.showSuccess(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, url, action.dataFile.fileName, action.dataFile.fileSize);
}
@Action(SharedAipDataFileAction.Resume)
......
......@@ -17,7 +17,6 @@ import {
} from "@ngxs/store";
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {
AppRoutesEnum,
......@@ -137,10 +136,7 @@ export class SharedAipState extends ResourceState<SharedAipStateModel, Aip> {
@Action(SharedAipAction.Download)
download(ctx: StateContext<SharedAipStateModel>, action: SharedAipAction.Download): void {
const fileName = "aip_" + action.id + ".zip";
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(`${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName).subscribe(() => {
this.notificationService.showSuccess(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, `${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName);
}
@OverrideDefaultAction()
......
import {HttpClient} from "@angular/common/http";
import {
HttpClient,
HttpHeaders,
} from "@angular/common/http";
import {Injectable} from "@angular/core";
import {environment} from "@environments/environment";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {saveAs} from "file-saver";
import {
from,
......@@ -11,6 +15,7 @@ import {
HttpStatus,
isNullOrUndefined,
isTrue,
NotificationService,
OAuth2Service,
} from "solidify-frontend";
import streamSaver from "streamsaver";
......@@ -21,9 +26,33 @@ import {WritableStream} from "web-streams-polyfill/ponyfill";
})
export class DownloadService {
constructor(private oauth2Service: OAuth2Service,
private httpClient: HttpClient) {}
private httpClient: HttpClient,
private readonly _notificationService: NotificationService) {}
download(isPublic: boolean, url: string, fileName: string, size?: number): void {
this._notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
if (isPublic) {
this.downloadBrowserNatif(url);
} else {
this.downloadWithMitm(url, fileName, size).pipe(
tap(result => {
if (result === HttpStatus.OK) {
this._notificationService.showSuccess(LabelTranslateEnum.fileDownloadedSuccessfully);
} else if (result === HttpStatus.FORBIDDEN) {
this._notificationService.showError(LabelTranslateEnum.fileDownloadForbidden);
} else {
this._notificationService.showSuccess(LabelTranslateEnum.fileDownloadFail);
}
}),
).subscribe();
}
}
downloadBrowserNatif(url: string): void {
window.open(url, "_self");
}
download(url: string, fileName: string, size?: number): Observable<number> {
downloadWithMitm(url: string, fileName: string, size?: number): Observable<number> {
if (isNullOrUndefined(streamSaver.WritableStream)) {
streamSaver.WritableStream = WritableStream;
}
......@@ -81,11 +110,11 @@ export class DownloadService {
// Prefer use download api to stream directly on disk
downloadInMemory(url: string, fileName: string, withSaveAs: boolean = true): Observable<Blob> {
// let headers = new HttpHeaders();
// headers = headers.set("Content-Disposition", "attachment; filename=" + fileName);
let headers = new HttpHeaders();
headers = headers.set("Content-Disposition", "attachment; filename=" + fileName);
return this.httpClient.get(url, {
// headers,
headers,
responseType: "blob",
}).pipe(tap((blobContent: Blob) => {
if (withSaveAs) {
......
......@@ -142,7 +142,7 @@ export namespace SharedArchiveAction {
export class Download extends BaseAction {
static readonly type: string = `[${state}] Download`;
constructor(public archiveResId: string, public archiveTitle: string, public archiveSize: number) {
constructor(public archive: Archive) {
super();
}
}
......@@ -151,10 +151,6 @@ export namespace SharedArchiveAction {
static readonly type: string = `[${state}] Download Start`;
}
export class DownloadSuccess extends BaseSubAction<DownloadStart> {
static readonly type: string = `[${state}] Download Success`;
}
export class DownloadFail extends BaseSubAction<DownloadStart> {
static readonly type: string = `[${state}] Download Fail`;
......
......@@ -296,14 +296,14 @@ export class SharedArchiveState extends ResourceState<SharedArchiveStateModel, A
startWith(0),
mergeMap(() => {
this._setIsPendingRequest(ctx, action, true);
return this._getDownloadStatus(ctx, action.archiveResId).pipe(
return this._getDownloadStatus(ctx, action.archive.resId).pipe(
tap(() => this._setIsPendingRequest(ctx, action, false)),
);
}),
tap((res: string) => {
if (res === StringUtil.stringEmpty) {
this._setIsPendingRequest(ctx, action, true);
this._prepareDownload(ctx, action.archiveResId).pipe(
this._prepareDownload(ctx, action.archive.resId).pipe(
tap(() => {
this._setIsPendingRequest(ctx, action, false);
}),
......@@ -311,7 +311,7 @@ export class SharedArchiveState extends ResourceState<SharedArchiveStateModel, A
if (e.status === HttpStatus.FORBIDDEN) {
this._setIsPendingRequest(ctx, action, false);
this._setIsPooling(ctx, action, false);
ctx.dispatch(new SharedArchiveAction.DownloadFail(action, LabelTranslateEnum.notAllowToDownloadArchive));
ctx.dispatch(new SharedArchiveAction.DownloadFail(action, LabelTranslateEnum.fileDownloadForbidden));
return;
}
return of(StringUtil.stringEmpty);
......@@ -370,31 +370,16 @@ export class SharedArchiveState extends ResourceState<SharedArchiveStateModel, A
@Action(SharedArchiveAction.DownloadStart)
downloadStart(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.DownloadStart): void {
const actionDownload = (action.parentAction as SharedArchiveAction.Download);
const fileName = actionDownload.archiveTitle + ".zip";
const fileSize = actionDownload.archiveSize;
this.downloadService.download(`${this._urlResource}/${actionDownload.archiveResId}/${ApiActionEnum.DL}`, fileName, fileSize)
.pipe(
tap((result) => {
if (result === HttpStatus.OK) {
ctx.dispatch(new SharedArchiveAction.DownloadSuccess(action));
} else {
ctx.dispatch(new SharedArchiveAction.DownloadFail(action, result === HttpStatus.FORBIDDEN ? LabelTranslateEnum.notAllowToDownloadArchive : undefined));
}
}),
)
.subscribe();
}
@Action(SharedArchiveAction.DownloadSuccess)
downloadSuccess(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.DownloadSuccess): void {
this.notificationService.showSuccess(MARK_AS_TRANSLATABLE("home.archive.browsing.download.notification.success"));
const archive = (action.parentAction as SharedArchiveAction.Download).archive;
const isPublic = archive.accessLevel === Enums.Deposit.AccessEnum.PUBLIC;
const fileName = archive.title + ".zip";
const fileSize = archive.size;
this.downloadService.download(isPublic, `${this._urlResource}/${archive.resId}/${ApiActionEnum.DL}`, fileName, fileSize);
}
@Action(SharedArchiveAction.DownloadFail)
downloadFail(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.DownloadFail): void {
this.notificationService.showError(action.customMessageToTranslate ?? MARK_AS_TRANSLATABLE("home.archive.browsing.download.notification.error"));
this.notificationService.showError(action.customMessageToTranslate ?? LabelTranslateEnum.fileDownloadFail);
}
private _getIsPooling(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.Download): boolean {
......@@ -422,7 +407,7 @@ export class SharedArchiveState extends ResourceState<SharedArchiveStateModel, A
}
private _isIncludedInList(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.Download, key: keyof SharedArchiveStateModel): boolean {
return (ctx.getState()[key] as string[]).includes(action.archiveResId);
return (ctx.getState()[key] as string[]).includes(action.archive.resId);
}
private _setInList(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.Download, key: keyof SharedArchiveStateModel, toAdd: boolean): void {
......@@ -435,16 +420,16 @@ export class SharedArchiveState extends ResourceState<SharedArchiveStateModel, A
private _addInList(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.Download, key: keyof SharedArchiveStateModel): void {
const list = ctx.getState()[key] as string[];
if (!list.includes(action.archiveResId)) {
if (!list.includes(action.archive.resId)) {
ctx.patchState({
[key]: [...list, action.archiveResId],
[key]: [...list, action.archive.resId],
});
}
}
private _removeInList(ctx: StateContext<SharedArchiveStateModel>, action: SharedArchiveAction.Download, key: keyof SharedArchiveStateModel): void {
const list = ctx.getState()[key] as string[];
const archiveId = action.archiveResId;
const archiveId = action.archive.resId;
const indexOf = list.indexOf(archiveId);
if (indexOf !== -1) {
const listPending = [...list];
......
......@@ -82,9 +82,7 @@ export class AppCartDipState extends ResourceState<AppCartDipStateModel, Dip> {
listDipDataFile._data.forEach(dipDataFile => {
size += dipDataFile.fileSize;
});
this.downloadService.download(`${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName, size).subscribe(() => {
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, `${this._urlResource}/${action.id}/${ApiActionEnum.DL}`, fileName, size);
}),
).subscribe();
ctx.dispatch(actionDownload);
......
......@@ -12,7 +12,6 @@ import {PreservationPlanningDipDataFileAction} from "@preservation-planning/dip/
import {ApiActionEnum} from "@shared/enums/api-action.enum";
import {ApiResourceNameEnum} from "@shared/enums/api-resource-name.enum";
import {AccessResourceApiEnum} from "@shared/enums/api.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {DownloadService} from "@shared/services/download.service";
import {
......@@ -58,9 +57,6 @@ export class AppCartDipDataFileState extends CompositionState<AppCartDipDataFile
@Action(PreservationPlanningDipDataFileAction.Download)
download(ctx: StateContext<AppCartDipDataFileStateModel>, action: PreservationPlanningDipDataFileAction.Download): void {
const url = `${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.DL}`;
this.notificationService.showInformation(LabelTranslateEnum.fileDownloadStart);
this.downloadService.download(url, action.dataFile.fileName, action.dataFile.fileSize).subscribe(() => {
this.notificationService.showSuccess(LabelTranslateEnum.fileDownloadedSuccessfully);
});
this.downloadService.download(false, url, action.dataFile.fileName, action.dataFile.fileSize);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment