From a62b7e7d3791c668c3b3c00716737652302ac1f1 Mon Sep 17 00:00:00 2001
From: Phan Huy Tran
Date: Wed, 15 Jan 2025 09:28:45 +0100
Subject: [PATCH 1/2] Fix employeedetails opened from qualification details not
showing any skills
---
.../details/details.component.html | 22 ++++++++++---------
.../details/details.component.ts | 21 +++++++++++++++---
src/app/services/employee-api.service.ts | 4 ++++
3 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/src/app/qualification/details/details.component.html b/src/app/qualification/details/details.component.html
index 33cbe2b..3197fa6 100644
--- a/src/app/qualification/details/details.component.html
+++ b/src/app/qualification/details/details.component.html
@@ -1,20 +1,22 @@
- Employees with {{ qualification.skill }}
+ {{ qualification.skill }} Developers
-
+
@if (employees$ | async; as employees) {
@if (employees.length === 0) {
No employees found with this qualification.
} @else {
- @for (employee of employees; track employee.id) {
-
- {{ employee.firstName }} {{ employee.lastName }}
-
- }
+
}
}
diff --git a/src/app/qualification/details/details.component.ts b/src/app/qualification/details/details.component.ts
index 593eeb1..1857aaf 100644
--- a/src/app/qualification/details/details.component.ts
+++ b/src/app/qualification/details/details.component.ts
@@ -12,6 +12,14 @@ import {AsyncPipe} from "@angular/common";
import {MatButton} from "@angular/material/button";
import {Employee} from "../../employee/Employee";
import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/details/details.component";
+import EmployeeApiService from "../../services/employee-api.service";
+
+interface QualificationEmployee {
+ id: number;
+ lastName: string;
+ firstName: string;
+}
+
@Component({
selector: 'app-details',
@@ -27,6 +35,7 @@ import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/detai
})
export class DetailsComponent {
private qualificationService = inject(QualificationService);
+ private employeeService = inject(EmployeeApiService);
private dialogRef: MatDialogRef = inject(MatDialogRef);
private dialog: MatDialog = inject(MatDialog);
@@ -37,9 +46,15 @@ export class DetailsComponent {
this.dialogRef.close();
}
- openEmployeeDetailsModal(employee: Employee) {
- this.dialog.open(EmployeeDetailsComponent, {
- data: employee
+ openEmployeeDetailsModal(id: number | undefined) {
+ if (!id) {
+ throw new Error("ID must not be undefined");
+ }
+
+ this.employeeService.getById(id).subscribe(employee => {
+ this.dialog.open(EmployeeDetailsComponent, {
+ data: employee
+ });
});
}
}
diff --git a/src/app/services/employee-api.service.ts b/src/app/services/employee-api.service.ts
index 16aded1..b8e6d8b 100644
--- a/src/app/services/employee-api.service.ts
+++ b/src/app/services/employee-api.service.ts
@@ -12,6 +12,10 @@ export default class EmployeeApiService {
private static readonly BASE_URL = 'http://localhost:8089';
+ public getById(id: number): Observable {
+ return this.http.get(`${EmployeeApiService.BASE_URL}/employees/${id}`)
+ }
+
public deleteById(id: number): Observable {
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`)
}
--
2.47.2
From 8af2086d6c11671579042644c2c6663246116ef8 Mon Sep 17 00:00:00 2001
From: Phan Huy Tran
Date: Wed, 15 Jan 2025 09:29:50 +0100
Subject: [PATCH 2/2] Remove dead code
---
src/app/qualification/details/details.component.ts | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/app/qualification/details/details.component.ts b/src/app/qualification/details/details.component.ts
index 1857aaf..9a2246d 100644
--- a/src/app/qualification/details/details.component.ts
+++ b/src/app/qualification/details/details.component.ts
@@ -1,6 +1,7 @@
import {Component, inject} from '@angular/core';
import {
- MAT_DIALOG_DATA, MatDialog,
+ MAT_DIALOG_DATA,
+ MatDialog,
MatDialogActions,
MatDialogContent,
MatDialogRef,
@@ -10,17 +11,9 @@ import QualificationService from "../../services/qualification.service";
import {Qualification} from "../Qualification";
import {AsyncPipe} from "@angular/common";
import {MatButton} from "@angular/material/button";
-import {Employee} from "../../employee/Employee";
import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/details/details.component";
import EmployeeApiService from "../../services/employee-api.service";
-interface QualificationEmployee {
- id: number;
- lastName: string;
- firstName: string;
-}
-
-
@Component({
selector: 'app-details',
imports: [
--
2.47.2