format code and improve readability across files (#47)
Reviewed-on: http://git.simonis.lol/angular/ems-frontend/pulls/47 Co-authored-by: Jan-Marlon Leibl <jleibl@proton.me> Co-committed-by: Jan-Marlon Leibl <jleibl@proton.me>
This commit is contained in:
committed by
Hop In, I Have Puppies AND WiFi

parent
88d9a1a534
commit
545c6194e4
@ -1,14 +1,15 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AuthService} from "./auth.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {KeycloakService} from "keycloak-angular";
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AuthService } from './auth.service';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthGuardService {
|
||||
constructor(public auth: AuthService, public router: Router) {
|
||||
}
|
||||
constructor(
|
||||
public auth: AuthService,
|
||||
public router: Router,
|
||||
) {}
|
||||
|
||||
canActivate(): boolean {
|
||||
if (!this.auth.isAuthenticated()) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {KeycloakService} from "keycloak-angular";
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
private keycloakService = inject(KeycloakService);
|
||||
|
@ -1,11 +1,10 @@
|
||||
import {inject, Injectable} from "@angular/core";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Observable} from "rxjs";
|
||||
import {Employee} from "../employee/Employee";
|
||||
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Employee } from '../employee/Employee';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export default class EmployeeApiService {
|
||||
private http: HttpClient = inject(HttpClient);
|
||||
@ -13,22 +12,30 @@ export default class EmployeeApiService {
|
||||
private static readonly BASE_URL = '/backend';
|
||||
|
||||
public getById(id: number): Observable<Employee> {
|
||||
return this.http.get(`${EmployeeApiService.BASE_URL}/employees/${id}`)
|
||||
return this.http.get(`${EmployeeApiService.BASE_URL}/employees/${id}`);
|
||||
}
|
||||
|
||||
public deleteById(id: number): Observable<Employee> {
|
||||
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`)
|
||||
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`);
|
||||
}
|
||||
|
||||
public getAll(): Observable<Employee[]> {
|
||||
return this.http.get<Employee[]>(`${EmployeeApiService.BASE_URL}/employees`)
|
||||
return this.http.get<Employee[]>(
|
||||
`${EmployeeApiService.BASE_URL}/employees`,
|
||||
);
|
||||
}
|
||||
|
||||
public create(employee: Employee) {
|
||||
return this.http.post<Employee>(`${EmployeeApiService.BASE_URL}/employees`, employee)
|
||||
return this.http.post<Employee>(
|
||||
`${EmployeeApiService.BASE_URL}/employees`,
|
||||
employee,
|
||||
);
|
||||
}
|
||||
|
||||
public update(employee: Employee, id: number) {
|
||||
return this.http.put(`${EmployeeApiService.BASE_URL}/employees/${id}`, employee)
|
||||
return this.http.put(
|
||||
`${EmployeeApiService.BASE_URL}/employees/${id}`,
|
||||
employee,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ErrorHandlerService {
|
||||
private readonly snackBar: MatSnackBar = inject(MatSnackBar);
|
||||
@ -12,7 +12,7 @@ export class ErrorHandlerService {
|
||||
duration: 5000,
|
||||
horizontalPosition: 'end',
|
||||
verticalPosition: 'bottom',
|
||||
panelClass: ['!bg-red-50', '!text-red-900', '!border', '!border-red-100']
|
||||
panelClass: ['!bg-red-50', '!text-red-900', '!border', '!border-red-100'],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,53 @@
|
||||
import {inject, Injectable} from "@angular/core";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {map, Observable} from "rxjs";
|
||||
import {Qualification} from "../qualification/Qualification";
|
||||
import {Employee} from "../employee/Employee";
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Qualification } from '../qualification/Qualification';
|
||||
import { Employee } from '../employee/Employee';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export default class QualificationService {
|
||||
private http: HttpClient = inject(HttpClient);
|
||||
|
||||
private static readonly BASE_URL = '/backend';
|
||||
|
||||
public getAll(): Observable<Qualification[]> {
|
||||
return this.http.get<Qualification[]>(`${QualificationService.BASE_URL}/qualifications`).pipe(
|
||||
map(qualifications => qualifications.sort((a, b) => a.id - b.id))
|
||||
)
|
||||
}
|
||||
private readonly apiUrl = `${QualificationService.BASE_URL}/qualifications`;
|
||||
|
||||
public create(data: any) {
|
||||
return this.http.post(`${QualificationService.BASE_URL}/qualifications`, data)
|
||||
}
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
public edit(id: number, data: any) {
|
||||
return this.http.put(`${QualificationService.BASE_URL}/qualifications/${id}`, data)
|
||||
}
|
||||
|
||||
public delete(id: number) {
|
||||
return this.http.delete(`${QualificationService.BASE_URL}/qualifications/${id}`)
|
||||
}
|
||||
|
||||
public findEmployees(id: number): Observable<Employee[]> {
|
||||
return this.http.get<any>(`${QualificationService.BASE_URL}/qualifications/${id}/employees`)
|
||||
getAll(): Observable<Qualification[]> {
|
||||
return this.http
|
||||
.get<Qualification[]>(this.apiUrl)
|
||||
.pipe(
|
||||
map(response => response.employees)
|
||||
map((qualifications) => qualifications.sort((a, b) => a.id - b.id)),
|
||||
);
|
||||
}
|
||||
|
||||
getById(id: number): Observable<Qualification> {
|
||||
return this.http.get<Qualification>(`${this.apiUrl}/${id}`);
|
||||
}
|
||||
|
||||
create(qualification: Omit<Qualification, 'id'>): Observable<Qualification> {
|
||||
return this.http.post<Qualification>(this.apiUrl, qualification);
|
||||
}
|
||||
|
||||
update(
|
||||
id: number,
|
||||
qualification: Partial<Qualification>,
|
||||
): Observable<Qualification> {
|
||||
return this.http.put<Qualification>(`${this.apiUrl}/${id}`, qualification);
|
||||
}
|
||||
|
||||
delete(id: number): Observable<void> {
|
||||
return this.http.delete<void>(`${this.apiUrl}/${id}`);
|
||||
}
|
||||
|
||||
findEmployees(id: number): Observable<Employee[]> {
|
||||
interface EmployeeResponse {
|
||||
employees: Employee[];
|
||||
}
|
||||
return this.http
|
||||
.get<EmployeeResponse>(`${this.apiUrl}/${id}/employees`)
|
||||
.pipe(map((response) => response.employees));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user