From 1851e913c9627a529cd7f242965e945cd6029c1b Mon Sep 17 00:00:00 2001 From: kaw67872 <kawtar.laariche@iais.fraunhofer.de> Date: Mon, 3 Jun 2024 11:16:25 +0200 Subject: [PATCH] #22: Display dialog after successful onboarding model execution --- .../dashboard/sidebar/sidebar.component.scss | 2 +- .../confirm-action.component.html | 27 ++++++++++ .../confirm-action.component.scss | 0 .../confirm-action.component.spec.ts | 23 +++++++++ .../confirm-action.component.ts | 51 +++++++++++++++++++ .../shared/models/public-solution.model.ts | 2 + 6 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/app/shared/components/confirm-action/confirm-action.component.html create mode 100644 src/app/shared/components/confirm-action/confirm-action.component.scss create mode 100644 src/app/shared/components/confirm-action/confirm-action.component.spec.ts create mode 100644 src/app/shared/components/confirm-action/confirm-action.component.ts diff --git a/src/app/features/dashboard/sidebar/sidebar.component.scss b/src/app/features/dashboard/sidebar/sidebar.component.scss index 423ec43..2fda413 100644 --- a/src/app/features/dashboard/sidebar/sidebar.component.scss +++ b/src/app/features/dashboard/sidebar/sidebar.component.scss @@ -157,7 +157,7 @@ a { } .headerTxtSpan { - font-size: 14px; + font-size: 13px; font-weight: 600; color: #2e2f2f; opacity: 1; diff --git a/src/app/shared/components/confirm-action/confirm-action.component.html b/src/app/shared/components/confirm-action/confirm-action.component.html new file mode 100644 index 0000000..96024c5 --- /dev/null +++ b/src/app/shared/components/confirm-action/confirm-action.component.html @@ -0,0 +1,27 @@ +<mat-toolbar class="dialog-header"> + <div style="display: flex; align-items: center; padding: 0; flex: 1 1 auto"> + <h2>{{ title }}</h2> + </div> + <button + type="button" + mat-icon-button + [mat-dialog-close]="true" + class="close" + tabindex="-1" + > + <mat-icon aria-hidden="false" aria-label="Close icon">close</mat-icon> + </button> +</mat-toolbar> +<mat-dialog-content> + <div class="star-rating-container"> + <p> + {{ content }} + </p> + </div></mat-dialog-content +> +<mat-toolbar class="form-footer"> + <button mat-dialog-close mat-raised-button style="margin-right: auto"> + Cancel + </button> + <button color="primary" mat-raised-button (click)="onClickSecondAction()">{{secondAction}}</button> +</mat-toolbar> diff --git a/src/app/shared/components/confirm-action/confirm-action.component.scss b/src/app/shared/components/confirm-action/confirm-action.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/shared/components/confirm-action/confirm-action.component.spec.ts b/src/app/shared/components/confirm-action/confirm-action.component.spec.ts new file mode 100644 index 0000000..925f76b --- /dev/null +++ b/src/app/shared/components/confirm-action/confirm-action.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ConfirmActionComponent } from './confirm-action.component'; + +describe('ConfirmActionComponent', () => { + let component: ConfirmActionComponent; + let fixture: ComponentFixture<ConfirmActionComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ConfirmActionComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ConfirmActionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shared/components/confirm-action/confirm-action.component.ts b/src/app/shared/components/confirm-action/confirm-action.component.ts new file mode 100644 index 0000000..dbd208f --- /dev/null +++ b/src/app/shared/components/confirm-action/confirm-action.component.ts @@ -0,0 +1,51 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { + MAT_DIALOG_DATA, + MatDialogModule, + MatDialogRef, +} from '@angular/material/dialog'; +import { MatButtonModule } from '@angular/material/button'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatIconModule } from '@angular/material/icon'; + +@Component({ + selector: 'gp-confirm-action', + standalone: true, + imports: [ + CommonModule, + MatDialogModule, + MatButtonModule, + MatToolbarModule, + MatIconModule, + ], + templateUrl: './confirm-action.component.html', + styleUrl: './confirm-action.component.scss', +}) +export class ConfirmActionComponent implements OnInit { + title!: string; + content!: string; + secondAction!: string; + + constructor( + public dialogRef: MatDialogRef<ConfirmActionComponent>, + @Inject(MAT_DIALOG_DATA) public data: any, + ) {} + + ngOnInit(): void { + this.title = this.data.dataKey.title; + this.content = this.data.dataKey.content; + this.secondAction = this.data.dataKey.secondAction; + } + + onClickSecondAction() { + this.data.dataKey.action().subscribe({ + next: (res: any) => { + this.dialogRef.close(true); + }, + error: (err: any) => { + this.dialogRef.close(false); + }, + }); + } +} diff --git a/src/app/shared/models/public-solution.model.ts b/src/app/shared/models/public-solution.model.ts index c8c74f5..9ff3a6f 100644 --- a/src/app/shared/models/public-solution.model.ts +++ b/src/app/shared/models/public-solution.model.ts @@ -1,4 +1,5 @@ export interface PublicSolutionsRequestPayload { + userId?: string; modelTypeCodes?: string[]; active?: boolean; catalogIds?: string[]; @@ -15,6 +16,7 @@ export interface PublicSolutionsRequestPayload { size?: number; }; } + export interface Solution { name: string; ownerName: string; -- GitLab