Moved from tslint to eslint as tslint was depreciated.
Added prettier and also prettied all the typescript files using prettier ESLint is using the AirBnB rules which are the most strict to lint the files.
This commit is contained in:
@ -1,35 +1,35 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
import {Attendance} from './attendance';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Attendance } from './attendance';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
|
||||
const url = '/api/attendance';
|
||||
const serviceName = 'AttendanceService';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AttendanceService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(date: string): Observable<Attendance> {
|
||||
const getUrl: string = (date === null) ? url : `${url}/${date}`;
|
||||
return <Observable<Attendance>>this.http.get<Attendance>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get date=${date}`))
|
||||
);
|
||||
const getUrl: string = date === null ? url : `${url}/${date}`;
|
||||
return <Observable<Attendance>>(
|
||||
this.http
|
||||
.get<Attendance>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get date=${date}`)))
|
||||
);
|
||||
}
|
||||
|
||||
save(attendance: Attendance): Observable<Attendance> {
|
||||
return <Observable<Attendance>>this.http.post<Attendance>(`${url}/${attendance.date}`, attendance, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
return <Observable<Attendance>>(
|
||||
this.http
|
||||
.post<Attendance>(`${url}/${attendance.date}`, attendance, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user