diff --git a/angular.json b/angular.json index 2cbf973..954709f 100644 --- a/angular.json +++ b/angular.json @@ -93,8 +93,5 @@ } } } - }, - "cli": { - "analytics": false } } diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 0300bf6..c9981e2 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -6,7 +6,6 @@ import { QualifikatonBearbeitenViewComponent } from "./components/qualifikaton-b import { MitarbeiterBearbeitenViewComponent } from "./components/mitarbeiter-bearbeiten-view/mitarbeiter-bearbeiten-view.component"; import { AuthGuard } from "./service/auth.service"; import { MitarbeiterErstellenComponent } from "./components/mitarbeiter-erstellen/mitarbeiter-erstellen.component"; -import { QualifikationsverwaltungComponent } from "./components/qualifikationsverwaltung/qualifikationsverwaltung.component"; export const routes: Routes = [ { @@ -28,11 +27,6 @@ export const routes: Routes = [ component: MitarbeiterBearbeitenViewComponent, canActivate: [AuthGuard], }, - { - path: "qualifikationsverwaltung", - component: QualifikationsverwaltungComponent, - canActivate: [AuthGuard], - }, { path: "mitarbeiterdetails", component: EmployeeDetailComponent, diff --git a/src/app/components/qualifikation-form/qualifikation-form.component.html b/src/app/components/qualifikation-form/qualifikation-form.component.html index a6652d1..a881a16 100644 --- a/src/app/components/qualifikation-form/qualifikation-form.component.html +++ b/src/app/components/qualifikation-form/qualifikation-form.component.html @@ -1,6 +1,6 @@
- +
@if (errorMessages['name']) { diff --git a/src/app/components/qualifikation-form/qualifikation-form.component.ts b/src/app/components/qualifikation-form/qualifikation-form.component.ts index 21ccf24..608ac05 100644 --- a/src/app/components/qualifikation-form/qualifikation-form.component.ts +++ b/src/app/components/qualifikation-form/qualifikation-form.component.ts @@ -76,10 +76,6 @@ export class QualifikationFormComponent { } } - returnToSkillList() { - this.router.navigate(["qualifikationsverwaltung"]); - } - updateEmployeeLists() { if (this.skill.id != -1) { this.employeeService.getAllEmployees().subscribe(employees => { @@ -109,7 +105,7 @@ export class QualifikationFormComponent { } for (const employee of this.addableEmployees) { - this.employeeService.removeSkillFromEmployee(this.skill.id, employee.id); + this.employeeService.removeSkillFromEmployee(this.skill.id, employee); } this.skill.skill = this.skillForm.get("name")?.value; diff --git a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.css b/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.css deleted file mode 100644 index 3d3b957..0000000 --- a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.css +++ /dev/null @@ -1,90 +0,0 @@ -body { - font-family: sans-serif; - margin: 0; - padding: 20px; - background-color: #f0f0f0; -} - -.container { - width: 100%; - margin: 0 auto; - background-color: #fff; - padding: 20px; -} - -h1 { - font-size: 2rem; - margin-bottom: 20px; -} - -.search-bar { - display: flex; - margin-bottom: 10px; - align-items: center; -} - -.search-bar input[type="text"] { - padding: 8px; - border: 1px solid #ccc; - border-radius: 3px; - flex-grow: 1; - margin-right: 10px; -} - -.search-bar button { - padding: 10px 15px; - background-color: #007bff; - color: #fff; - border: none; - border-radius: 3px; - cursor: pointer; -} - -.add-button { - background-color: #07af16; - color: #fff; - padding: 10px 15px; - border: none; - border-radius: 3px; - cursor: pointer; - float: left; - margin-bottom: 10px; -} - -.employee-table { - width: 100%; - border-collapse: collapse; - margin-top: 20px; -} - -.employee-table th, -.employee-table td { - padding: 12px 15px; - border: 1px solid #ddd; - text-align: left; -} - -.employee-table th { - background-color: #f0f0f0; - font-weight: bold; -} - -.sortable { - cursor: pointer; -} - -.logout-button { - background-color: transparent; - border: none; - cursor: pointer; - border-radius: 50%; - width: 30px; - height: 30px; - display: flex; - float: right; -} - -.logout-button img { - width: 20px; - height: 20px; -} diff --git a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.html b/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.html deleted file mode 100644 index e09d23c..0000000 --- a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.html +++ /dev/null @@ -1,47 +0,0 @@ -
-
- -

Qualifications

-
- -
- - -

Search for a propertiy of a Qualification. eg. Name

- - -
- - - - - - - - - - @if (skills) { - @for (skill of skills; track skill) { - - - - - } - } - -
NameActions
{{ skill.skill }} - - -
-
diff --git a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.spec.ts b/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.spec.ts deleted file mode 100644 index 537fe1a..0000000 --- a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { QualifikationsverwaltungComponent } from './qualifikationsverwaltung.component'; - -describe('QualifikationsverwaltungComponent', () => { - let component: QualifikationsverwaltungComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [QualifikationsverwaltungComponent] - }) - .compileComponents(); - - fixture = TestBed.createComponent(QualifikationsverwaltungComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.ts b/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.ts deleted file mode 100644 index cfe298b..0000000 --- a/src/app/components/qualifikationsverwaltung/qualifikationsverwaltung.component.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Component } from '@angular/core'; -import { QualificationGetDTO } from '../../models/skill'; -import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; -import { SkillService } from '../../service/skill.service'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'app-qualifikationsverwaltung', - standalone: true, - imports: [ReactiveFormsModule], - templateUrl: './qualifikationsverwaltung.component.html', - styleUrl: './qualifikationsverwaltung.component.css' -}) -export class QualifikationsverwaltungComponent { - skills: Array = []; - public searchForm!: FormGroup; - - constructor(private skillService: SkillService, private router: Router) {} - - submit() { - const searchTerm = this.searchForm.get("search")?.value || ''; - - this.skillService.getAllSkills().subscribe(skills => { - let foundSkills: Array = []; - for (const skill of skills) { - if ( - skill.skill.toLowerCase().includes(searchTerm.toLowerCase()) || - searchTerm == '' - ) { - foundSkills.push(skill); - } - } - - this.skills = foundSkills; - }); - } - - editSkill(id: number) { - this.router.navigate([`/qualifikationbearbeiten/${id}`]); - } - - createSkill() { - this.router.navigate(['/qualifikationerstellen']); - } - - deleteSkill(id: number) { - this.skillService.deleteSkill(id); - this.skills = this.skills.filter(skill => skill.id != id); - } - - ngOnInit(): void { - this.searchForm = new FormGroup({ - search: new FormControl(''), - }); - this.skillService.getAllSkills().subscribe(skills => this.skills = skills); - } -} diff --git a/src/app/service/employee.service.ts b/src/app/service/employee.service.ts index fe1d9db..caaf5e1 100644 --- a/src/app/service/employee.service.ts +++ b/src/app/service/employee.service.ts @@ -54,15 +54,13 @@ export class EmployeeService { return this.http.get(`${SkillService.BASE_URL}/employees/${id}`); } - removeSkillFromEmployee(skillId: number, employeeId: number) { - this.getEmployeeById(employeeId).subscribe(employee => { - let employeePut = this.responseDtoToPutDto(employee); - if (employeePut.skillSet.indexOf(skillId) != 1) { - employeePut.skillSet = employeePut.skillSet.filter(skill => skill != skillId); - } + removeSkillFromEmployee(skillId: number, employee: EmployeeResponseDTO) { + let employeePut = this.responseDtoToPutDto(employee); + if (employeePut.skillSet.indexOf(skillId) != 1) { + employeePut.skillSet = employeePut.skillSet.filter(skill => skill != skillId); + } - this.http.put(`${SkillService.BASE_URL}/employees/${employee.id}`, employeePut).subscribe(); - }); + this.http.put(`${SkillService.BASE_URL}/employees/${employee.id}`, employeePut).subscribe(); } addSkillToEmployee(skillId: number, employee: EmployeeResponseDTO) { diff --git a/src/app/service/skill.service.ts b/src/app/service/skill.service.ts index b9ac3a6..9e0beb1 100644 --- a/src/app/service/skill.service.ts +++ b/src/app/service/skill.service.ts @@ -3,21 +3,11 @@ import { Injectable } from "@angular/core"; import { EmployeesForAQualificationDTO, QualificationGetDTO, QualificationPostDTO } from "../models/skill"; import { Observable } from "rxjs"; import { EmployeeNameDataDTO } from "../models/mitarbeiter"; -import { EmployeeService } from "./employee.service"; @Injectable({ providedIn: 'root' }) export class SkillService { - deleteSkill(id: number) { - this.getEmployeesBySkill(id).subscribe(employees => { - for (let employee of employees.employees) { - this.employeeService.removeSkillFromEmployee(id, employee.id); - } - }); - - this.http.delete(`${SkillService.BASE_URL}/qualifications/${id}`).subscribe(); - } public static readonly BASE_URL = "http://localhost:8089"; @@ -27,7 +17,7 @@ export class SkillService { } } - constructor(private http: HttpClient, private employeeService: EmployeeService) { + constructor(private http: HttpClient) { }