diff --git a/src/app/data/scenario.service.ts b/src/app/data/scenario.service.ts index 50ed8cb8..0b2bee6f 100644 --- a/src/app/data/scenario.service.ts +++ b/src/app/data/scenario.service.ts @@ -110,6 +110,14 @@ export class ScenarioService { ); } + public clone(scenarioId: string) { + return this.gargAdmin.post(`/copy/${scenarioId}`, null).pipe( + catchError((e: HttpErrorResponse) => { + return throwError(() => e.error); + }), + ) + } + public update(s: Scenario) { var steps = structuredClone(s.steps); // step by step, re-encode to b64 diff --git a/src/app/scenario/scenario.component.html b/src/app/scenario/scenario.component.html index 2005ed5f..10eef6fb 100644 --- a/src/app/scenario/scenario.component.html +++ b/src/app/scenario/scenario.component.html @@ -42,6 +42,7 @@

Scenarios

> Delete + } {{ s.id }} diff --git a/src/app/scenario/scenario.component.ts b/src/app/scenario/scenario.component.ts index 64cad99a..b9f55bd0 100644 --- a/src/app/scenario/scenario.component.ts +++ b/src/app/scenario/scenario.component.ts @@ -88,6 +88,20 @@ export class ScenarioComponent implements OnInit { }); } + cloneScenario(scenarioId: string) { + this.scenarioService.clone(scenarioId).subscribe({ + next: (_s: ServerResponse) => { + const alertMsg = 'Scenario cloned'; + this.alert.success(alertMsg, true, DEFAULT_ALERT_SUCCESS_DURATION); + this.refresh(); + }, + error: (e: HttpErrorResponse) => { + const alertMsg = 'Error cloning scenario: ' + e.error.message; + this.alert.danger(alertMsg, true, DEFAULT_ALERT_ERROR_DURATION); + }, + }) + } + deleteScenario(scenarioId: string) { this.scenarioService.delete(scenarioId).subscribe({ next: (_s: ServerResponse) => {