Commit 6e71cd32 authored by Florent Poittevin's avatar Florent Poittevin Committed by Alicia.DeDiosFuente
Browse files

Fpo/add upload into solidify

parent 2ce7911d
......@@ -2,8 +2,8 @@ import {Enums} from "@src/app/enums";
import {DataTestEnum} from "@src/app/shared/enums/data-test.enum";
import {HttpVerbEnum} from "@src/app/shared/enums/http-verb.enum";
import {ModuleLoadedEnum} from "@src/app/shared/enums/module-loaded.enum";
import {Guid} from "@src/app/shared/models/guid.model";
import {
Guid,
HttpStatus,
isNotNullNorUndefined,
} from "solidify-frontend";
......
......@@ -204,7 +204,7 @@ export class AdminFundingAgenciesState extends ResourceState<AdminFundingAgencie
if (deleteSubResourceWithSuccess) {
super.delete(ctx, action).subscribe();
} else {
super.deleteFail(ctx, action);
super.deleteFail(ctx, action as any);
}
}),
);
......
......@@ -8,7 +8,6 @@ import {
HttpEventType,
} from "@angular/common/http";
import {Injectable} from "@angular/core";
import {UploadEventModel} from "@deposit/models/upload-event.model";
import {Enums} from "@enums";
import {MetadataType} from "@models";
import {
......@@ -47,6 +46,7 @@ import {
SolidifyStateError,
StoreUtil,
StringUtil,
UploadEventModel,
} from "solidify-frontend";
export interface AdminMetadataTypeStateModel extends ResourceStateModel<MetadataType> {
......
......@@ -37,7 +37,7 @@ export class AdminOaiSetFormPresentational extends AbstractFormPresentational<Oa
return IconNameEnum;
}
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltipOnInput;
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltip;
constructor(protected readonly _changeDetectorRef: ChangeDetectorRef,
protected readonly _elementRef: ElementRef,
......
......@@ -29,7 +29,7 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AdminOrganizationalUnitAdditionalFieldsFormPresentational extends AbstractFormPresentational<AdditionalFieldsForm> {
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltipOnInput;
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltip;
formDefinition: FormComponentFormDefinition = new FormComponentFormDefinition();
listFormType: KeyValue[] = Enums.FormDescription.LanguageEnumTranslate;
......
......@@ -90,7 +90,7 @@ export class AdminOrganizationalUnitFormPresentational extends AbstractFormPrese
}
private readonly KEY_SOURCE: keyof ResearchDomain = "source";
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltipOnInput;
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltip;
formDefinition: FormComponentFormDefinition = new FormComponentFormDefinition();
organizationalUnitActionNameSpace: ResourceLogoNameSpace = AdminOrganizationalUnitAction;
......
......@@ -21,7 +21,7 @@ import {
import {ModeDepositTabEnum} from "@deposit/enums/mode-deposit-tab.enum";
import {DepositDataFileHelper} from "@deposit/helpers/deposit-data-file.helper";
import {DepositDataFile} from "@deposit/models/deposit-data-file.model";
import {FileUploadWrapper} from "@deposit/models/file-upload-wrapper.model";
import {DlcmFileUploadWrapper} from "@deposit/models/dlcm-file-upload-wrapper.model";
import {DepositDataFileAction} from "@deposit/stores/data-file/deposit-data-file.action";
import {DepositDataFileState} from "@deposit/stores/data-file/deposit-data-file.state";
import {
......@@ -33,6 +33,7 @@ import {
DepositStateModel,
} from "@deposit/stores/deposit.state";
import {DepositOrganizationalUnitState} from "@deposit/stores/organizational-unit/deposit-organizational-unit.state";
import {DepositUploadAction} from "@deposit/stores/upload/deposit-upload.action";
import {Enums} from "@enums";
import {Deposit} from "@models";
import {Navigate} from "@ngxs/router-plugin";
......@@ -494,15 +495,15 @@ export class DepositFileContainer extends AbstractDetailEditRoutable<Deposit, De
} as DepositFileUploadDialogData,
});
this.subscribe(dialogRef.afterClosed().pipe(
filter((listFilesUploadWrapper: FileUploadWrapper[]) => isNonEmptyArray(listFilesUploadWrapper)),
tap((listFilesUploadWrapper: FileUploadWrapper[]) => {
filter((listFilesUploadWrapper: DlcmFileUploadWrapper[]) => isNonEmptyArray(listFilesUploadWrapper)),
tap((listFilesUploadWrapper: DlcmFileUploadWrapper[]) => {
listFilesUploadWrapper.forEach(f => this.upload(f));
}),
));
}
upload($event: FileUploadWrapper): void {
this._store.dispatch(new DepositAction.UploadDataFile(this._resId, $event));
upload($event: DlcmFileUploadWrapper): void {
this._store.dispatch(new DepositUploadAction.UploadFile(this._resId, $event));
}
selectAndResumeAll(): void {
......
......@@ -25,20 +25,15 @@ import {
import {DepositFormPresentational} from "@deposit/components/presentationals/deposit-form/deposit-form.presentational";
import {ModeDepositTabEnum} from "@deposit/enums/mode-deposit-tab.enum";
import {DepositDataFile} from "@deposit/models/deposit-data-file.model";
import {FileUploadWrapper} from "@deposit/models/file-upload-wrapper.model";
import {UploadFileStatus} from "@deposit/models/upload-file-status.model";
import {DlcmFileUploadWrapper} from "@deposit/models/dlcm-file-upload-wrapper.model";
import {DepositCollectionAction} from "@deposit/stores/collection/deposit-collection.action";
import {DepositCollectionState} from "@deposit/stores/collection/deposit-collection.state";
import {DepositDataFileAction} from "@deposit/stores/data-file/deposit-data-file.action";
import {DepositDataFileState} from "@deposit/stores/data-file/deposit-data-file.state";
import {
DepositAction,
depositActionNameSpace,
} from "@deposit/stores/deposit.action";
import {
DepositState,
DepositStateModel,
} from "@deposit/stores/deposit.state";
import {depositActionNameSpace} from "@deposit/stores/deposit.action";
import {DepositStateModel} from "@deposit/stores/deposit.state";
import {DepositUploadAction} from "@deposit/stores/upload/deposit-upload.action";
import {DepositUploadState} from "@deposit/stores/upload/deposit-upload.state";
import {Enums} from "@enums";
import {Deposit} from "@models";
import {
......@@ -64,6 +59,7 @@ import {
isNullOrUndefined,
MemoizedUtil,
QueryParameters,
UploadFileStatus,
} from "solidify-frontend";
@Component({
......@@ -73,7 +69,7 @@ import {
})
export class DepositUploadContainer extends AbstractDetailEditRoutable<Deposit, DepositStateModel> implements OnInit {
queryParametersObs: Observable<QueryParameters> = MemoizedUtil.queryParameters(this._store, DepositDataFileState);
uploadStatusObs: Observable<UploadFileStatus[]> = MemoizedUtil.select(this._store, DepositState, state => state.uploadStatus);
uploadStatusObs: Observable<UploadFileStatus<DepositDataFile>[]> = MemoizedUtil.select(this._store, DepositUploadState, state => state.uploadStatus);
@Select(AppState.currentOrgUnitPerson) currentPersonObs: Observable<PersonRole>;
......@@ -123,20 +119,20 @@ export class DepositUploadContainer extends AbstractDetailEditRoutable<Deposit,
this._resId = this._route.snapshot.parent.paramMap.get(AppRoutesEnum.paramIdWithoutPrefixParam);
}
upload($event: FileUploadWrapper): void {
this._store.dispatch(new DepositAction.UploadDataFile(this._resId, $event));
upload($event: DlcmFileUploadWrapper): void {
this._store.dispatch(new DepositUploadAction.UploadFile(this._resId, $event));
}
uploadArchive($event: FileUploadWrapper): void {
this._store.dispatch(new DepositAction.UploadDataFile(this._resId, $event, true));
uploadArchive($event: DlcmFileUploadWrapper): void {
this._store.dispatch(new DepositUploadAction.UploadFile(this._resId, $event, true));
}
retry($event: UploadFileStatus): void {
this._store.dispatch(new DepositAction.RetrySendDataFile(this._resId, $event));
retry($event: UploadFileStatus<DepositDataFile>): void {
this._store.dispatch(new DepositUploadAction.RetrySendFile(this._resId, $event));
}
cancel($event: UploadFileStatus): void {
this._store.dispatch(new DepositAction.MarkAsCancelDataFileSending(this._resId, $event));
cancel($event: UploadFileStatus<DepositDataFile>): void {
this._store.dispatch(new DepositUploadAction.MarkAsCancelFileSending(this._resId, $event));
}
resume($event: DepositDataFile): void {
......@@ -160,8 +156,8 @@ export class DepositUploadContainer extends AbstractDetailEditRoutable<Deposit,
} as DepositFileUploadDialogData,
});
this.subscribe(dialogRef.afterClosed().pipe(
filter((listFilesUploadWrapper: FileUploadWrapper[]) => isNonEmptyArray(listFilesUploadWrapper)),
tap((listFilesUploadWrapper: FileUploadWrapper[]) => {
filter((listFilesUploadWrapper: DlcmFileUploadWrapper[]) => isNonEmptyArray(listFilesUploadWrapper)),
tap((listFilesUploadWrapper: DlcmFileUploadWrapper[]) => {
listFilesUploadWrapper.forEach(f => this.upload(f));
}),
));
......@@ -175,8 +171,8 @@ export class DepositUploadContainer extends AbstractDetailEditRoutable<Deposit,
} as DepositFileUploadArchiveDialogData,
});
this.subscribe(dialogRef.afterClosed().pipe(
filter((fileUploadWrapper: FileUploadWrapper) => !isNullOrUndefined(fileUploadWrapper)),
tap((fileUploadWrapper: FileUploadWrapper) => {
filter((fileUploadWrapper: DlcmFileUploadWrapper) => !isNullOrUndefined(fileUploadWrapper)),
tap((fileUploadWrapper: DlcmFileUploadWrapper) => {
this.uploadArchive(fileUploadWrapper);
}),
));
......
......@@ -9,7 +9,7 @@ import {
MAT_DIALOG_DATA,
MatDialogRef,
} from "@angular/material/dialog";
import {FileUploadWrapper} from "@app/features/deposit/models/file-upload-wrapper.model";
import {DlcmFileUploadWrapper} from "@deposit/models/dlcm-file-upload-wrapper.model";
import {AbstractDepositFileUploadDialog} from "@deposit/components/dialogs/abstract-deposit-file-upload/abstract-deposit-file-upload.dialog";
import {Enums} from "@enums";
import {
......@@ -59,8 +59,8 @@ export class DepositFileUploadArchiveDialog extends AbstractDepositFileUploadDia
}
onSubmit(): void {
const base = this.form.value as FileUploadWrapper;
const fileUploadWrapper = {} as FileUploadWrapper;
const base = this.form.value as DlcmFileUploadWrapper;
const fileUploadWrapper = {} as DlcmFileUploadWrapper;
Object.assign(fileUploadWrapper, base);
fileUploadWrapper.file = this.archiveToUpload;
this._dialogRef.close(fileUploadWrapper);
......
......@@ -9,7 +9,7 @@ import {
MAT_DIALOG_DATA,
MatDialogRef,
} from "@angular/material/dialog";
import {FileUploadWrapper} from "@app/features/deposit/models/file-upload-wrapper.model";
import {DlcmFileUploadWrapper} from "@deposit/models/dlcm-file-upload-wrapper.model";
import {
AbstractDepositFileUploadDialog,
AbstractDepositFileUploadFormComponentFormDefinition,
......@@ -96,10 +96,10 @@ export class DepositFileUploadDialog extends AbstractDepositFileUploadDialog imp
}
onSubmit(): void {
const base = this.form.value as FileUploadWrapper;
const listFilesUploadWrapper: FileUploadWrapper[] = [];
const base = this.form.value as DlcmFileUploadWrapper;
const listFilesUploadWrapper: DlcmFileUploadWrapper[] = [];
this.filesToUpload.forEach((f: FileWrapper) => {
const fileUploadWrapper = {} as FileUploadWrapper;
const fileUploadWrapper = {} as DlcmFileUploadWrapper;
Object.assign(fileUploadWrapper, base);
fileUploadWrapper.file = f.file;
listFilesUploadWrapper.push(fileUploadWrapper);
......
......@@ -5,17 +5,17 @@ import {
Output,
} from "@angular/core";
import {MatDialog} from "@angular/material/dialog";
import {FileUploadStatusEnum} from "@app/features/deposit/enums/file-upload-status.enum";
import {DepositDataFile} from "@app/features/deposit/models/deposit-data-file.model";
import {UploadFileStatus} from "@app/features/deposit/models/upload-file-status.model";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {
BehaviorSubject,
Observable,
} from "rxjs";
import {
FileUploadStatusEnum,
isNullOrUndefined,
ObservableUtil,
UploadFileStatus,
} from "solidify-frontend";
@Component({
......@@ -29,7 +29,7 @@ export class DepositFilePresentational extends SharedAbstractPresentational {
depositDataFile: DepositDataFile;
@Input()
uploadStatus: UploadFileStatus;
uploadStatus: UploadFileStatus<DepositDataFile>;
@Input()
isLoadingHistory: boolean;
......@@ -37,13 +37,13 @@ export class DepositFilePresentational extends SharedAbstractPresentational {
@Input()
readonly: boolean;
private readonly _cancelBS: BehaviorSubject<UploadFileStatus | undefined> = new BehaviorSubject<UploadFileStatus | undefined>(undefined);
private readonly _cancelBS: BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined> = new BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined>(undefined);
@Output("cancelChange")
readonly cancelObs: Observable<UploadFileStatus | undefined> = ObservableUtil.asObservable(this._cancelBS);
readonly cancelObs: Observable<UploadFileStatus<DepositDataFile> | undefined> = ObservableUtil.asObservable(this._cancelBS);
private readonly _retryBS: BehaviorSubject<UploadFileStatus | undefined> = new BehaviorSubject<UploadFileStatus | undefined>(undefined);
private readonly _retryBS: BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined> = new BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined>(undefined);
@Output("retryChange")
readonly retryObs: Observable<UploadFileStatus | undefined> = ObservableUtil.asObservable(this._retryBS);
readonly retryObs: Observable<UploadFileStatus<DepositDataFile> | undefined> = ObservableUtil.asObservable(this._retryBS);
private readonly _resumeBS: BehaviorSubject<DepositDataFile | undefined> = new BehaviorSubject<DepositDataFile | undefined>(undefined);
@Output("resumeChange")
......
......@@ -6,16 +6,19 @@ import {
Output,
} from "@angular/core";
import {MatDialog} from "@angular/material/dialog";
import {FileUploadStatusEnum} from "@app/features/deposit/enums/file-upload-status.enum";
import {FileUploadWrapper} from "@app/features/deposit/models/file-upload-wrapper.model";
import {UploadFileStatus} from "@app/features/deposit/models/upload-file-status.model";
import {DepositDataFile} from "@deposit/models/deposit-data-file.model";
import {DlcmFileUploadWrapper} from "@deposit/models/dlcm-file-upload-wrapper.model";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {Guid} from "@app/shared/models/guid.model";
import {
BehaviorSubject,
Observable,
} from "rxjs";
import {ObservableUtil} from "solidify-frontend";
import {
FileUploadStatusEnum,
Guid,
ObservableUtil,
UploadFileStatus,
} from "solidify-frontend";
@Component({
selector: "dlcm-deposit-files-upload-in-progress",
......@@ -25,23 +28,23 @@ import {ObservableUtil} from "solidify-frontend";
})
export class DepositFilesUploadInProgressPresentational extends SharedAbstractPresentational implements OnInit {
@Input()
listFilesUploading: UploadFileStatus[];
listFilesUploading: UploadFileStatus<DepositDataFile>[];
private readonly _cancelBS: BehaviorSubject<UploadFileStatus | undefined> = new BehaviorSubject<UploadFileStatus | undefined>(undefined);
private readonly _cancelBS: BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined> = new BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined>(undefined);
@Output("cancelChange")
readonly cancelObs: Observable<UploadFileStatus | undefined> = ObservableUtil.asObservable(this._cancelBS);
readonly cancelObs: Observable<UploadFileStatus<DepositDataFile> | undefined> = ObservableUtil.asObservable(this._cancelBS);
private readonly _retryBS: BehaviorSubject<UploadFileStatus | undefined> = new BehaviorSubject<UploadFileStatus | undefined>(undefined);
private readonly _retryBS: BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined> = new BehaviorSubject<UploadFileStatus<DepositDataFile> | undefined>(undefined);
@Output("retryChange")
readonly retryObs: Observable<UploadFileStatus | undefined> = ObservableUtil.asObservable(this._retryBS);
readonly retryObs: Observable<UploadFileStatus<DepositDataFile> | undefined> = ObservableUtil.asObservable(this._retryBS);
private readonly _uploadBS: BehaviorSubject<FileUploadWrapper | undefined> = new BehaviorSubject<FileUploadWrapper | undefined>(undefined);
private readonly _uploadBS: BehaviorSubject<DlcmFileUploadWrapper | undefined> = new BehaviorSubject<DlcmFileUploadWrapper | undefined>(undefined);
@Output("uploadChange")
readonly uploadObs: Observable<FileUploadWrapper | undefined> = ObservableUtil.asObservable(this._uploadBS);
readonly uploadObs: Observable<DlcmFileUploadWrapper | undefined> = ObservableUtil.asObservable(this._uploadBS);
private readonly _uploadArchiveBS: BehaviorSubject<FileUploadWrapper | undefined> = new BehaviorSubject<FileUploadWrapper | undefined>(undefined);
private readonly _uploadArchiveBS: BehaviorSubject<DlcmFileUploadWrapper | undefined> = new BehaviorSubject<DlcmFileUploadWrapper | undefined>(undefined);
@Output("uploadArchiveChange")
readonly uploadArchiveObs: Observable<FileUploadWrapper | undefined> = ObservableUtil.asObservable(this._uploadArchiveBS);
readonly uploadArchiveObs: Observable<DlcmFileUploadWrapper | undefined> = ObservableUtil.asObservable(this._uploadArchiveBS);
constructor(private dialog: MatDialog) {
super();
......@@ -95,15 +98,15 @@ export class DepositFilesUploadInProgressPresentational extends SharedAbstractPr
return this.listFilesUploading.filter(f => f.status === FileUploadStatusEnum.inProgress).length;
}
cancel(uploadStatus: UploadFileStatus): void {
cancel(uploadStatus: UploadFileStatus<DepositDataFile>): void {
this._cancelBS.next(uploadStatus);
}
retry(uploadStatus: UploadFileStatus): void {
retry(uploadStatus: UploadFileStatus<DepositDataFile>): void {
this._retryBS.next(uploadStatus);
}
trackByFn(index: number, item: UploadFileStatus): Guid {
trackByFn(index: number, item: UploadFileStatus<DepositDataFile>): Guid {
return item.guid;
}
}
......@@ -176,7 +176,7 @@ export class DepositFormPresentational extends AbstractFormPresentational<Deposi
defaultLicenseId: string;
commonValueLicenseId: string[];
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltipOnInput;
readonly TIME_BEFORE_DISPLAY_TOOLTIP: number = environment.timeBeforeDisplayTooltip;
get userApplicationRoleEnum(): typeof Enums.UserApplicationRole.UserApplicationRoleEnum {
return Enums.UserApplicationRole.UserApplicationRoleEnum;
......
......@@ -35,6 +35,7 @@ import {DepositDataFileStatusHistoryState} from "@deposit/stores/data-file/statu
import {DepositOrganizationalUnitAdditionalFieldsFormState} from "@deposit/stores/organizational-unit/additional-fields-form/deposit-organizational-unit-additional-fields-form.state";
import {DepositOrganizationalUnitState} from "@deposit/stores/organizational-unit/deposit-organizational-unit.state";
import {DepositStatusHistoryState} from "@deposit/stores/status-history/deposit-status-history.state";
import {DepositUploadState} from "@deposit/stores/upload/deposit-upload.state";
import {TranslateModule} from "@ngx-translate/core";
import {NgxsModule} from "@ngxs/store";
import {ModuleLoadedEnum} from "@shared/enums/module-loaded.enum";
......@@ -80,6 +81,7 @@ const presentationals = [
];
const states = [
DepositState,
DepositUploadState,
DepositDataFileState,
DepositPeopleState,
DepositStatusHistoryState,
......
export enum FileUploadStatusEnum {
started = "started",
inProgress = "inProgress",
completed = "completed",
canceled = "canceled",
inError = "inError",
}
import {FileUploadStatusEnum} from "@app/features/deposit/enums/file-upload-status.enum";
import {DepositDataFile} from "@app/features/deposit/models/deposit-data-file.model";
import {FileUploadWrapper} from "@app/features/deposit/models/file-upload-wrapper.model";
import {UploadEventModel} from "@app/features/deposit/models/upload-event.model";
import {UploadFileStatus} from "@app/features/deposit/models/upload-file-status.model";
import {DepositStateModel} from "@app/features/deposit/stores/deposit.state";
import {Guid} from "@app/shared/models/guid.model";
import {DepositDataFileState} from "@deposit/stores/data-file/deposit-data-file.state";
import {Enums} from "@enums";
import {
StateContext,
Store,
} from "@ngxs/store";
import {Store} from "@ngxs/store";
import {
MappingObjectUtil,
MemoizedUtil,
......@@ -28,93 +18,6 @@ export class DataFileUploadHelper {
Enums.DataFile.StatusEnum.CLEANING,
];
static addToUploadStatus(ctx: StateContext<DepositStateModel>, fileUploadWrapper: FileUploadWrapper, isArchive: boolean): UploadFileStatus {
const uploadFileStatus = this.createNewUploadFileStatus(fileUploadWrapper, isArchive);
ctx.patchState({
uploadStatus: [
...ctx.getState().uploadStatus,
uploadFileStatus,
],
});
return uploadFileStatus;
}
private static createNewUploadFileStatus(fileUploadWrapper: FileUploadWrapper, isArchive: boolean): UploadFileStatus {
return {
guid: Guid.MakeNew(),
fileUploadWrapper: fileUploadWrapper,
status: FileUploadStatusEnum.started,
progressPercentage: 0,
isArchive: isArchive,
} as UploadFileStatus;
}
static updateInProgressUploadFileStatus(ctx: StateContext<DepositStateModel>, uploadFileStatus: UploadFileStatus, event: UploadEventModel): void {
uploadFileStatus.status = FileUploadStatusEnum.inProgress;
uploadFileStatus.progressPercentage = this.getUploadProgress(event);
this.updateUploadFileStatus(ctx, uploadFileStatus);
}
static getUploadProgress(event: UploadEventModel): number {
return Math.round(100 * event.loaded / event.total);
}
static updateCompletedUploadFileStatus(ctx: StateContext<DepositStateModel>, uploadFileStatus: UploadFileStatus, depositDataFile: DepositDataFile): void {
uploadFileStatus.progressPercentage = 100;
uploadFileStatus.status = FileUploadStatusEnum.completed;
uploadFileStatus.result = depositDataFile;
this.updateUploadFileStatus(ctx, uploadFileStatus);
setTimeout(() => {
this.removeToUploadStatus(ctx, uploadFileStatus);
}, 5000);
}
static updateErrorUploadFileStatus(ctx: StateContext<DepositStateModel>, uploadFileStatus: UploadFileStatus, messageToTranslate: string): void {
uploadFileStatus.status = FileUploadStatusEnum.inError;
uploadFileStatus.errorMessageToTranslate = messageToTranslate;
this.updateUploadFileStatus(ctx, uploadFileStatus);
}
static updateCancelUploadFileStatus(ctx: StateContext<DepositStateModel>, uploadFileStatus: UploadFileStatus): void {
uploadFileStatus.status = FileUploadStatusEnum.canceled;
this.updateUploadFileStatus(ctx, uploadFileStatus);
}
static updateUploadFileStatus(ctx: StateContext<DepositStateModel>, uploadFileStatus: UploadFileStatus): void {
const uploadStatus = [...ctx.getState().uploadStatus];
const index = this.getIndexCurrentUploadFileStatus(ctx, uploadFileStatus.guid);
if (index !== -1 && index < uploadStatus.length) {
uploadStatus[index] = uploadFileStatus;
ctx.patchState({
uploadStatus,
});
}
}
static removeToUploadStatus(ctx: StateContext<DepositStateModel>, uploadFileStatus: UploadFileStatus): void {
const uploadStatus = [...ctx.getState().uploadStatus];
const index = this.getIndexCurrentUploadFileStatus(ctx, uploadFileStatus.guid);
if (index !== -1 && index < uploadStatus.length) {
uploadStatus.splice(index, 1);
ctx.patchState({
uploadStatus,
});
}
}
static getCurrentUploadFileStatus(ctx: StateContext<DepositStateModel>, guid: Guid): UploadFileStatus | null {
const index = this.getIndexCurrentUploadFileStatus(ctx, guid);
if (index !== -1) {
return Object.assign({}, ctx.getState().uploadStatus[index]);
}
return null;
}
private static getIndexCurrentUploadFileStatus(ctx: StateContext<DepositStateModel>, guid: Guid): number {
const uploadStatus = ctx.getState().uploadStatus;
return uploadStatus.findIndex(u => u.guid === guid);
}
static numberFiles(store: Store): number {
const listCurrentStatus = MemoizedUtil.selectSnapshot(store, DepositDataFileState, state => state.listCurrentStatus);
let pendingCounter = 0;
......
import {Enums} from "@enums";
import {FileUploadWrapper} from "solidify-frontend";
export interface FileUploadWrapper {
export interface DlcmFileUploadWrapper extends FileUploadWrapper {
subDirectory: string;
dataCategory: Enums.DataFile.DataCategoryEnum;
dataType: Enums.DataFile.DataTypeEnum;
metadataType: string;
file: File;
}
import {
HttpEventType,
HttpHeaders,
} from "@angular/common/http";
export interface UploadEventModel {
headers?: HttpHeaders;
ok?: boolean;
status?: number;
statusText?: string;
type: HttpEventType;
url?: string;
loaded?: number;
total?: number;
body?: any;
}
import {FileUploadStatusEnum} from "@app/features/deposit/enums/file-upload-status.enum";
import {DepositDataFile} from "@app/features/deposit/models/deposit-data-file.model";
import {FileUploadWrapper} from "@app/features/deposit/models/file-upload-wrapper.model";
import {Guid} from "@app/shared/models/guid.model";