Commit cfca213b authored by Florent POITTEVIN's avatar Florent POITTEVIN
Browse files

fix: 1486 Treat result object api return for each action endpoint

parent 3ee42b8d
......@@ -126,12 +126,20 @@ export class DepositDataFileState extends CompositionState<DepositDataFileStateM
}
@Action(DepositDataFileAction.ResumeDataFile)
resume(ctx: StateContext<DepositDataFileStateModel>, action: DepositDataFileAction.ResumeDataFile): Observable<void> {
return this.apiService.post<void>(`${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.RESUME}`)
resume(ctx: StateContext<DepositDataFileStateModel>, action: DepositDataFileAction.ResumeDataFile): Observable<Result> {
return this.apiService.post<any, Result>(`${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.RESUME}`)
.pipe(
tap(() => {
this.notificationService.showInformation(LabelTranslateEnum.resourceResumed);
ctx.dispatch(new DepositDataFileAction.GetAll(action.parentId, undefined, true));
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
this.notificationService.showInformation(LabelTranslateEnum.resourceResumed);
ctx.dispatch(new DepositDataFileAction.GetAll(action.parentId, undefined, true));
} else {
this.notificationService.showError(LabelTranslateEnum.unableResumedResource);
}
}),
catchError(error => {
this.notificationService.showError(LabelTranslateEnum.unableResumedResource);
throw new SolidifyStateError(this, error);
}),
);
}
......@@ -477,8 +485,8 @@ export class DepositDataFileState extends CompositionState<DepositDataFileStateM
return this.httpClient.post<Result>(`${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.VALIDATE}`, null)
.pipe(
tap((result: Result) => {
if (!isNullOrUndefined(result) && result.status === Enums.Result.ActionStatusEnum.EXECUTED) {
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new DepositDataFileAction.ValidateSuccess(action));
} else {
ctx.dispatch(new DepositDataFileAction.ValidateFail(action, result));
......
......@@ -439,9 +439,15 @@ export class DepositState extends ResourceLogoState<DepositStateModel, Deposit>
if (isTrue(submissionWithApproval)) {
suffix = ApiActionEnum.SUBMIT_FOR_APPROVAL;
}
return this.apiService.post(this._urlResource + urlSeparator + action.deposit.resId + urlSeparator + suffix)
return this.apiService.post<any, Result>(this._urlResource + urlSeparator + action.deposit.resId + urlSeparator + suffix)
.pipe(
tap((deposit: Result) => ctx.dispatch(new DepositAction.SubmitSuccess(deposit))),
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new DepositAction.SubmitSuccess(result));
} else {
ctx.dispatch(new DepositAction.SubmitFail());
}
}),
catchError(error => {
ctx.dispatch(new DepositAction.SubmitFail());
throw new SolidifyStateError(this, error);
......@@ -462,9 +468,15 @@ export class DepositState extends ResourceLogoState<DepositStateModel, Deposit>
@Action(DepositAction.Approve)
approve(ctx: StateContext<DepositStateModel>, action: DepositAction.Approve): Observable<Result> {
return this.apiService.post<Result>(this._urlResource + urlSeparator + action.deposit.resId + urlSeparator + ApiActionEnum.APPROVE)
return this.apiService.post<any, Result>(this._urlResource + urlSeparator + action.deposit.resId + urlSeparator + ApiActionEnum.APPROVE)
.pipe(
tap(result => ctx.dispatch(new DepositAction.ApproveSuccess(result))),
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new DepositAction.ApproveSuccess(result));
} else {
ctx.dispatch(new DepositAction.ApproveFail());
}
}),
catchError(error => {
ctx.dispatch(new DepositAction.ApproveFail());
throw new SolidifyStateError(this, error);
......@@ -485,9 +497,15 @@ export class DepositState extends ResourceLogoState<DepositStateModel, Deposit>
@Action(DepositAction.Reject)
reject(ctx: StateContext<DepositStateModel>, action: DepositAction.Reject): Observable<Result> {
return this.apiService.post<Result>(`${this._urlResource + urlSeparator + action.deposit.resId + urlSeparator + ApiActionEnum.REJECT}?${this._DEPOSIT_REJECT_REASON}=${action.message}`)
return this.apiService.post<any, Result>(`${this._urlResource + urlSeparator + action.deposit.resId + urlSeparator + ApiActionEnum.REJECT}?${this._DEPOSIT_REJECT_REASON}=${action.message}`)
.pipe(
tap(deposit => ctx.dispatch(new DepositAction.RejectSuccess(deposit))),
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new DepositAction.RejectSuccess(result));
} else {
ctx.dispatch(new DepositAction.RejectFail());
}
}),
catchError(error => {
ctx.dispatch(new DepositAction.RejectFail());
throw new SolidifyStateError(this, error);
......
import {Injectable} from "@angular/core";
import {Enums} from "@enums";
import {Order} from "@models";
import {
Action,
......@@ -33,6 +34,7 @@ import {AccessResourceApiEnum} from "@shared/enums/api.enum";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {RoutesEnum} from "@shared/enums/routes.enum";
import {OrderArchive} from "@shared/models/business/order-archive.model";
import {Result} from "@shared/models/business/result.model";
import {defaultStatusHistoryInitValue} from "@shared/stores/status-history/status-history.state";
import {Observable} from "rxjs";
import {
......@@ -127,15 +129,19 @@ export class OrderAllOrderState extends ResourceState<OrderAllOrderStateModel, O
}
@Action(OrderAllOrderAction.Submit)
submit(ctx: StateContext<OrderAllOrderStateModel>, action: OrderAllOrderAction.Submit): Observable<string[]> {
submit(ctx: StateContext<OrderAllOrderStateModel>, action: OrderAllOrderAction.Submit): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post(`${this._urlResource}/${action.resId}/${ApiActionEnum.SUBMIT}`, null)
return this.apiService.post<any, Result>(`${this._urlResource}/${action.resId}/${ApiActionEnum.SUBMIT}`, null)
.pipe(
tap(() => {
ctx.dispatch(new OrderAllOrderAction.SubmitSuccess(action));
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new OrderAllOrderAction.SubmitSuccess(action));
} else {
ctx.dispatch(new OrderAllOrderAction.SubmitFail(action));
}
}),
catchError(error => {
ctx.dispatch(new OrderAllOrderAction.SubmitFail(action));
......@@ -160,15 +166,19 @@ export class OrderAllOrderState extends ResourceState<OrderAllOrderStateModel, O
}
@Action(OrderAllOrderAction.Resume)
resume(ctx: StateContext<OrderAllOrderStateModel>, action: OrderAllOrderAction.Resume): Observable<string[]> {
resume(ctx: StateContext<OrderAllOrderStateModel>, action: OrderAllOrderAction.Resume): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post(`${this._urlResource}/${action.resId}/${ApiActionEnum.RESUME}`, null)
return this.apiService.post<any, Result>(`${this._urlResource}/${action.resId}/${ApiActionEnum.RESUME}`, null)
.pipe(
tap(() => {
ctx.dispatch(new OrderAllOrderAction.ResumeSuccess(action));
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new OrderAllOrderAction.ResumeSuccess(action));
} else {
ctx.dispatch(new OrderAllOrderAction.ResumeFail(action));
}
}),
catchError(error => {
ctx.dispatch(new OrderAllOrderAction.ResumeFail(action));
......
import {Injectable} from "@angular/core";
import {Enums} from "@enums";
import {Order} from "@models";
import {
Action,
......@@ -29,6 +30,7 @@ import {AccessResourceApiEnum} from "@shared/enums/api.enum";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {RoutesEnum} from "@shared/enums/routes.enum";
import {OrderArchive} from "@shared/models/business/order-archive.model";
import {Result} from "@shared/models/business/result.model";
import {defaultStatusHistoryInitValue} from "@shared/stores/status-history/status-history.state";
import {Observable} from "rxjs";
import {
......@@ -120,15 +122,19 @@ export class OrderMyOrderState extends ResourceState<OrderMyOrderStateModel, Ord
}
@Action(OrderMyOrderAction.Submit)
submit(ctx: StateContext<OrderMyOrderStateModel>, action: OrderMyOrderAction.Submit): Observable<string[]> {
submit(ctx: StateContext<OrderMyOrderStateModel>, action: OrderMyOrderAction.Submit): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post(`${this._urlResource}/${action.resId}/${ApiActionEnum.SUBMIT}`, null)
return this.apiService.post<any, Result>(`${this._urlResource}/${action.resId}/${ApiActionEnum.SUBMIT}`, null)
.pipe(
tap(() => {
ctx.dispatch(new OrderMyOrderAction.SubmitSuccess(action));
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new OrderMyOrderAction.SubmitSuccess(action));
} else {
ctx.dispatch(new OrderMyOrderAction.SubmitFail(action));
}
}),
catchError(error => {
ctx.dispatch(new OrderMyOrderAction.SubmitFail(action));
......@@ -153,15 +159,19 @@ export class OrderMyOrderState extends ResourceState<OrderMyOrderStateModel, Ord
}
@Action(OrderMyOrderAction.Resume)
resume(ctx: StateContext<OrderMyOrderStateModel>, action: OrderMyOrderAction.Resume): Observable<string[]> {
resume(ctx: StateContext<OrderMyOrderStateModel>, action: OrderMyOrderAction.Resume): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post(`${this._urlResource}/${action.resId}/${ApiActionEnum.RESUME}`, null)
return this.apiService.post<any, Result>(`${this._urlResource}/${action.resId}/${ApiActionEnum.RESUME}`, null)
.pipe(
tap(() => {
ctx.dispatch(new OrderMyOrderAction.ResumeSuccess(action));
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new OrderMyOrderAction.ResumeSuccess(action));
} else {
ctx.dispatch(new OrderMyOrderAction.ResumeFail(action));
}
}),
catchError(error => {
ctx.dispatch(new OrderMyOrderAction.ResumeFail(action));
......
......@@ -7,6 +7,7 @@ import {ApiActionEnum} from "@app/shared/enums/api-action.enum";
import {ApiResourceNameEnum} from "@app/shared/enums/api-resource-name.enum";
import {AccessResourceApiEnum} from "@app/shared/enums/api.enum";
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {Enums} from "@enums";
import {
Action,
Actions,
......@@ -24,16 +25,21 @@ import {
PreservationPlanningDipDataFileStatusHistoryStateModel,
} from "@preservation-planning/dip/stores/data-file/status-history/preservation-planning-dip-data-file-status-history.state";
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";
import {Observable} from "rxjs";
import {tap} from "rxjs/operators";
import {
catchError,
tap,
} from "rxjs/operators";
import {
ApiService,
CompositionState,
CompositionStateModel,
defaultCompositionStateInitValue,
NotificationService,
SolidifyStateError,
} from "solidify-frontend";
export const defaultPreservationPlanningDipDataFileValue: () => PreservationPlanningDipDataFileStateModel = () =>
......@@ -88,12 +94,20 @@ export class PreservationPlanningDipDataFileState extends CompositionState<Prese
}
@Action(PreservationPlanningDipDataFileAction.Resume)
resume(ctx: StateContext<PreservationPlanningDipDataFileStateModel>, action: PreservationPlanningDipDataFileAction.Resume): Observable<void> {
return this.apiService.post<void>(`${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.RESUME}`)
resume(ctx: StateContext<PreservationPlanningDipDataFileStateModel>, action: PreservationPlanningDipDataFileAction.Resume): Observable<Result> {
return this.apiService.post<any, Result>(`${this._urlResource}/${action.parentId}/${this._resourceName}/${action.dataFile.resId}/${ApiActionEnum.RESUME}`)
.pipe(
tap(() => {
this.notificationService.showInformation(LabelTranslateEnum.resourceResumed);
ctx.dispatch(new PreservationPlanningDipDataFileAction.GetAll(action.parentId, undefined, true));
tap(result => {
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
this.notificationService.showInformation(LabelTranslateEnum.resourceResumed);
ctx.dispatch(new PreservationPlanningDipDataFileAction.GetAll(action.parentId, undefined, true));
} else {
this.notificationService.showError(LabelTranslateEnum.unableResumedResource);
}
}),
catchError(error => {
this.notificationService.showError(LabelTranslateEnum.unableResumedResource);
throw new SolidifyStateError(this, error);
}),
);
}
......
......@@ -2,6 +2,7 @@ import {HttpClient} from "@angular/common/http";
import {Injectable} from "@angular/core";
import {AccessResourceApiEnum} from "@app/shared/enums/api.enum";
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {Enums} from "@enums";
import {Dip} from "@models";
import {Navigate} from "@ngxs/router-plugin";
import {
......@@ -35,6 +36,7 @@ import {
DepositRoutesEnum,
RoutesEnum,
} from "@shared/enums/routes.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";
import {Observable} from "rxjs";
......@@ -146,14 +148,18 @@ export class PreservationPlanningDipState extends ResourceState<PreservationPlan
}
@Action(PreservationPlanningDipAction.Resume)
resume(ctx: StateContext<PreservationPlanningDipStateModel>, action: PreservationPlanningDipAction.Resume): Observable<string> {
resume(ctx: StateContext<PreservationPlanningDipStateModel>, action: PreservationPlanningDipAction.Resume): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.httpClient.post<string>(`${this._urlResource}/${action.id}/${ApiActionEnum.RESUME}`, null)
return this.httpClient.post<Result>(`${this._urlResource}/${action.id}/${ApiActionEnum.RESUME}`, null)
.pipe(
tap(result => {
ctx.dispatch(new PreservationPlanningDipAction.ResumeSuccess(action));
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new PreservationPlanningDipAction.ResumeSuccess(action));
} else {
ctx.dispatch(new PreservationPlanningDipAction.ResumeFail(action));
}
}),
catchError(error => {
ctx.dispatch(new PreservationPlanningDipAction.ResumeFail(action));
......
......@@ -93,22 +93,6 @@ export namespace PreservationPlanningJobExecutionAction {
static readonly type: string = `[${state}] Resume Fail`;
}
export class Start extends BaseAction {
static readonly type: string = `[${state}] Start`;
constructor(public parentId: string, public jobExecution: JobExecution) {
super();
}
}
export class StartSuccess extends BaseSubAction<Start> {
static readonly type: string = `[${state}] Start Success`;
}
export class StartFail extends BaseSubAction<Start> {
static readonly type: string = `[${state}] Start Fail`;
}
export class GetListReport extends BaseAction {
static readonly type: string = `[${state}] Get List Reports`;
......
import {Injectable} from "@angular/core";
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {Enums} from "@enums";
import {
Action,
Actions,
......@@ -24,6 +25,7 @@ import {ApiResourceNameEnum} from "@shared/enums/api-resource-name.enum";
import {PreservationPlanningResourceApiEnum} from "@shared/enums/api.enum";
import {JobExecutionReport} from "@shared/models/business/job-execution-report.model";
import {JobExecution} from "@shared/models/business/job-execution.model";
import {Result} from "@shared/models/business/result.model";
import {Observable} from "rxjs";
import {
catchError,
......@@ -103,15 +105,19 @@ export class PreservationPlanningJobExecutionState extends CompositionState<Pres
}
@Action(PreservationPlanningJobExecutionAction.Resume)
resume(ctx: StateContext<PreservationPlanningJobExecutionStateModel>, action: PreservationPlanningJobExecutionAction.Resume): Observable<string> {
resume(ctx: StateContext<PreservationPlanningJobExecutionStateModel>, action: PreservationPlanningJobExecutionAction.Resume): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post<string>(this._urlResource + urlSeparator + action.parentId + urlSeparator + ApiResourceNameEnum.PRES_JOB_EXECUTION + urlSeparator + action.jobExecutionId + urlSeparator + ApiActionEnum.RESUME)
return this.apiService.post<any, Result>(this._urlResource + urlSeparator + action.parentId + urlSeparator + ApiResourceNameEnum.PRES_JOB_EXECUTION + urlSeparator + action.jobExecutionId + urlSeparator + ApiActionEnum.RESUME)
.pipe(
tap(result => {
ctx.dispatch(new PreservationPlanningJobExecutionAction.ResumeSuccess(action));
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new PreservationPlanningJobExecutionAction.ResumeSuccess(action));
} else {
ctx.dispatch(new PreservationPlanningJobExecutionAction.ResumeFail(action));
}
}),
catchError(error => {
ctx.dispatch(new PreservationPlanningJobExecutionAction.ResumeFail(action));
......@@ -136,40 +142,6 @@ export class PreservationPlanningJobExecutionState extends CompositionState<Pres
this.notificationService.showError(MARK_AS_TRANSLATABLE("preservation.jobExecution.notification.resume.fail"));
}
@Action(PreservationPlanningJobExecutionAction.Start)
start(ctx: StateContext<PreservationPlanningJobExecutionStateModel>, action: PreservationPlanningJobExecutionAction.Start): Observable<string> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post<string>(this._urlResource + urlSeparator + action.parentId + urlSeparator + ApiResourceNameEnum.PRES_JOB_EXECUTION + urlSeparator + action.jobExecution.resId + urlSeparator + ApiActionEnum.START)
.pipe(
tap(result => {
ctx.dispatch(new PreservationPlanningJobExecutionAction.StartSuccess(action));
}),
catchError(error => {
ctx.dispatch(new PreservationPlanningJobExecutionAction.StartFail(action));
throw new SolidifyStateError(this, error);
}),
);
}
@Action(PreservationPlanningJobExecutionAction.StartSuccess)
startSuccess(ctx: StateContext<PreservationPlanningJobExecutionStateModel>, action: PreservationPlanningJobExecutionAction.StartSuccess): void {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter - 1,
});
this.notificationService.showSuccess(MARK_AS_TRANSLATABLE("preservation.jobExecution.notification.start.success"));
}
@Action(PreservationPlanningJobExecutionAction.StartFail)
startFail(ctx: StateContext<PreservationPlanningJobExecutionStateModel>, action: PreservationPlanningJobExecutionAction.StartFail): void {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter - 1,
});
this.notificationService.showError(MARK_AS_TRANSLATABLE("preservation.jobExecution.notification.start.fail"));
}
@OverrideDefaultAction()
@Action(PreservationPlanningJobExecutionAction.GetByIdSuccess)
getByIdSuccess(ctx: StateContext<PreservationPlanningJobExecutionStateModel>, action: PreservationPlanningJobExecutionAction.GetByIdSuccess): void {
......
......@@ -2,7 +2,10 @@ import {Injectable} from "@angular/core";
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {Enums} from "@enums";
import {environment} from "@environments/environment";
import {PreservationJob} from "@models";
import {
Collection,
PreservationJob,
} from "@models";
import {
Action,
Actions,
......@@ -27,6 +30,7 @@ import {RoutesEnum} from "@shared/enums/routes.enum";
import {JobExecution} from "@shared/models/business/job-execution.model";
import {JobRecurrence} from "@shared/models/business/job-recurrence.model";
import {JobType} from "@shared/models/business/job-type.model";
import {Result} from "@shared/models/business/result.model";
import {Observable} from "rxjs";
import {
catchError,
......@@ -118,14 +122,18 @@ export class PreservationPlanningJobState extends ResourceState<PreservationPlan
}
@Action(PreservationPlanningJobAction.Init)
init(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.Init): Observable<string> {
init(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.Init): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post<string>(this._urlResource + urlSeparator + ApiActionEnum.INIT).pipe(
return this.apiService.post<any, Result>(this._urlResource + urlSeparator + ApiActionEnum.INIT).pipe(
tap(result => {
ctx.dispatch(new PreservationPlanningJobAction.InitSuccess(action));
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new PreservationPlanningJobAction.InitSuccess(action));
} else {
ctx.dispatch(new PreservationPlanningJobAction.InitFail(action));
}
}),
catchError(error => {
ctx.dispatch(new PreservationPlanningJobAction.InitFail(action));
......@@ -151,7 +159,7 @@ export class PreservationPlanningJobState extends ResourceState<PreservationPlan
}
@Action(PreservationPlanningJobAction.VerifyBeforeStart)
verifyBeforeStart(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.VerifyBeforeStart): Observable<any> {
verifyBeforeStart(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.VerifyBeforeStart): Observable<Collection> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
......@@ -193,14 +201,18 @@ export class PreservationPlanningJobState extends ResourceState<PreservationPlan
}
@Action(PreservationPlanningJobAction.Start)
start(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.Start): Observable<string> {
start(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.Start): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post<string>(this._urlResource + urlSeparator + action.resId + urlSeparator + ApiActionEnum.START).pipe(
return this.apiService.post<any, Result>(this._urlResource + urlSeparator + action.resId + urlSeparator + ApiActionEnum.START).pipe(
tap(result => {
ctx.dispatch(new PreservationPlanningJobAction.StartSuccess(action));
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new PreservationPlanningJobAction.StartSuccess(action));
} else {
ctx.dispatch(new PreservationPlanningJobAction.StartFail(action));
}
}),
catchError(error => {
ctx.dispatch(new PreservationPlanningJobAction.StartFail(action));
......@@ -226,14 +238,18 @@ export class PreservationPlanningJobState extends ResourceState<PreservationPlan
}
@Action(PreservationPlanningJobAction.Resume)
resume(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.Resume): Observable<string> {
resume(ctx: StateContext<PreservationPlanningJobStateModel>, action: PreservationPlanningJobAction.Resume): Observable<Result> {
ctx.patchState({
isLoadingCounter: ctx.getState().isLoadingCounter + 1,
});
return this.apiService.post<string>(this._urlResource + urlSeparator + action.resId + urlSeparator + ApiActionEnum.RESUME).pipe(
return this.apiService.post<any, Result>(this._urlResource + urlSeparator + action.resId + urlSeparator + ApiActionEnum.RESUME).pipe(
tap(result => {
ctx.dispatch(new PreservationPlanningJobAction.ResumeSuccess(action));
if (result?.status === Enums.Result.ActionStatusEnum.EXECUTED) {
ctx.dispatch(new PreservationPlanningJobAction.ResumeSuccess(action));
} else {
ctx.dispatch(new PreservationPlanningJobAction.ResumeFail(action));
}
}),
catchError(error => {
ctx.dispatch(new PreservationPlanningJobAction.ResumeFail(action));
......
......@@ -7,6 +7,7 @@ import {ApiActionEnum} from "@app/shared/enums/api-action.enum";
import {ApiResourceNameEnum} from "@app/shared/enums/api-resource-name.enum";
import {IngestResourceApiEnum} from "@app/shared/enums/api.enum";
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {Enums} from "@enums";
import {
Action,
Actions,
......@@ -24,16 +25,21 @@ import {
SharedAipDataFileStatusHistoryStateModel,
} from "@preservation-planning/sip/stores/data-file/status-history/preservation-planning-sip-data-file-status-history.state";
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";
import {Observable} from "rxjs";
import {tap} from "rxjs/operators";
import {
catchError,
tap,
} from "rxjs/operators";
import {
ApiService,
CompositionState,
CompositionStateModel,
defaultCompositionStateInitValue,
NotificationService,
SolidifyStateError,
} from "solidify-frontend";
export const defaultPreservationPlanningSipDataFileValue: () => PreservationPlanningSipDataFileStateModel = () =>
......@@ -88,12 +94,20 @@ export class PreservationPlanningSipDataFileState extends CompositionState<Prese
}
@Action(PreservationPlanningSipDataFileAction.Resume)