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,10 +1,8 @@
|
||||
import {DataSource} from '@angular/cdk/collections';
|
||||
import {Observable} from 'rxjs';
|
||||
import {EmployeeAttendanceItem} from './employee-attendance';
|
||||
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable } from 'rxjs';
|
||||
import { EmployeeAttendanceItem } from './employee-attendance';
|
||||
|
||||
export class EmployeeAttendanceDataSource extends DataSource<EmployeeAttendanceItem> {
|
||||
|
||||
constructor(private data: Observable<EmployeeAttendanceItem[]>) {
|
||||
super();
|
||||
}
|
||||
@@ -13,6 +11,5 @@ export class EmployeeAttendanceDataSource extends DataSource<EmployeeAttendanceI
|
||||
return this.data;
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
disconnect() {}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {EmployeeAttendanceService} from './employee-attendance.service';
|
||||
import {EmployeeAttendance} from './employee-attendance';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { EmployeeAttendanceService } from './employee-attendance.service';
|
||||
import { EmployeeAttendance } from './employee-attendance';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EmployeeAttendanceResolver implements Resolve<EmployeeAttendance> {
|
||||
constructor(private ser: EmployeeAttendanceService) {}
|
||||
|
||||
constructor(private ser: EmployeeAttendanceService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<EmployeeAttendance> {
|
||||
resolve(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot,
|
||||
): Observable<EmployeeAttendance> {
|
||||
const id = route.paramMap.get('id');
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {EmployeeAttendanceResolver} from './employee-attendance-resolver.service';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {EmployeeAttendanceComponent} from './employee-attendance.component';
|
||||
import {AttendanceTypeResolver} from '../attendance/attendance-type-resolver.service';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { EmployeeAttendanceResolver } from './employee-attendance-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { EmployeeAttendanceComponent } from './employee-attendance.component';
|
||||
import { AttendanceTypeResolver } from '../attendance/attendance-type-resolver.service';
|
||||
|
||||
const employeeEmployeeAttendanceRoutes: Routes = [
|
||||
{
|
||||
@@ -12,41 +12,32 @@ const employeeEmployeeAttendanceRoutes: Routes = [
|
||||
component: EmployeeAttendanceComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Attendance'
|
||||
permission: 'Attendance',
|
||||
},
|
||||
resolve: {
|
||||
info: EmployeeAttendanceResolver,
|
||||
attendanceTypes: AttendanceTypeResolver
|
||||
attendanceTypes: AttendanceTypeResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: EmployeeAttendanceComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Attendance'
|
||||
permission: 'Attendance',
|
||||
},
|
||||
resolve: {
|
||||
info: EmployeeAttendanceResolver,
|
||||
attendanceTypes: AttendanceTypeResolver
|
||||
attendanceTypes: AttendanceTypeResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(employeeEmployeeAttendanceRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
EmployeeAttendanceResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(employeeEmployeeAttendanceRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [EmployeeAttendanceResolver],
|
||||
})
|
||||
export class EmployeeAttendanceRoutingModule {
|
||||
}
|
||||
export class EmployeeAttendanceRoutingModule {}
|
||||
|
||||
@@ -8,46 +8,46 @@
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.present :not(.no-bg){
|
||||
background-color: #228B22;
|
||||
.present :not(.no-bg) {
|
||||
background-color: #228b22;
|
||||
}
|
||||
|
||||
.off-day :not(.no-bg){
|
||||
background-color: #87CEFA;
|
||||
.off-day :not(.no-bg) {
|
||||
background-color: #87cefa;
|
||||
}
|
||||
|
||||
.on-leave :not(.no-bg){
|
||||
background-color: #CD5C5C;
|
||||
.on-leave :not(.no-bg) {
|
||||
background-color: #cd5c5c;
|
||||
}
|
||||
|
||||
.absent :not(.no-bg){
|
||||
background-color: #CD0000;
|
||||
.absent :not(.no-bg) {
|
||||
background-color: #cd0000;
|
||||
}
|
||||
|
||||
.half-day :not(.no-bg){
|
||||
background-color: #98FB98;
|
||||
.half-day :not(.no-bg) {
|
||||
background-color: #98fb98;
|
||||
}
|
||||
|
||||
.double-duty :not(.no-bg){
|
||||
.double-duty :not(.no-bg) {
|
||||
background-color: #006400;
|
||||
}
|
||||
|
||||
.paid-leave-availed :not(.no-bg){
|
||||
background-color: #EEEE00;
|
||||
.paid-leave-availed :not(.no-bg) {
|
||||
background-color: #eeee00;
|
||||
}
|
||||
|
||||
.casual-leave-availed :not(.no-bg){
|
||||
.casual-leave-availed :not(.no-bg) {
|
||||
background-color: #800080;
|
||||
}
|
||||
|
||||
.compensatory-off :not(.no-bg){
|
||||
background-color: #F5DEB3;
|
||||
.compensatory-off :not(.no-bg) {
|
||||
background-color: #f5deb3;
|
||||
}
|
||||
|
||||
.half-day-pl :not(.no-bg){
|
||||
background-color: #FFF68F;
|
||||
.half-day-pl :not(.no-bg) {
|
||||
background-color: #fff68f;
|
||||
}
|
||||
|
||||
.half-day-cl :not(.no-bg){
|
||||
background-color: #FF00FF;
|
||||
.half-day-cl :not(.no-bg) {
|
||||
background-color: #ff00ff;
|
||||
}
|
||||
|
||||
@@ -4,39 +4,73 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<input matInput [matDatepicker]="startDate" (focus)="startDate.open()" placeholder="Start Date"
|
||||
formControlName="startDate" autocomplete="off">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="startDate"
|
||||
(focus)="startDate.open()"
|
||||
placeholder="Start Date"
|
||||
formControlName="startDate"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #startDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<input matInput [matDatepicker]="finishDate" (focus)="finishDate.open()" placeholder="Finish Date"
|
||||
formControlName="finishDate" autocomplete="off">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="finishDate"
|
||||
(focus)="finishDate.open()"
|
||||
placeholder="Finish Date"
|
||||
formControlName="finishDate"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #finishDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex="80">
|
||||
<input type="text" matInput #employeeElement placeholder="Employee" [matAutocomplete]="auto"
|
||||
formControlName="employee" autocomplete="off">
|
||||
<mat-autocomplete #auto="matAutocomplete" autoActiveFirstOption [displayWith]="displayFn"
|
||||
(optionSelected)="selected($event)">
|
||||
<mat-option *ngFor="let employee of employees | async" [value]="employee">{{employee.name}}</mat-option>
|
||||
<input
|
||||
type="text"
|
||||
matInput
|
||||
#employeeElement
|
||||
placeholder="Employee"
|
||||
[matAutocomplete]="auto"
|
||||
formControlName="employee"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-autocomplete
|
||||
#auto="matAutocomplete"
|
||||
autoActiveFirstOption
|
||||
[displayWith]="displayFn"
|
||||
(optionSelected)="selected($event)"
|
||||
>
|
||||
<mat-option *ngFor="let employee of employees | async" [value]="employee">{{
|
||||
employee.name
|
||||
}}</mat-option>
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
<button fxFlex="20" mat-raised-button color="primary" (click)="show()">Show</button>
|
||||
</div>
|
||||
<mat-table #table [dataSource]="dataSource" formArrayName="attendances">
|
||||
|
||||
<!-- Date Column -->
|
||||
<ng-container matColumnDef="date">
|
||||
<mat-header-cell *matHeaderCellDef class="center">Date</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="center">{{row.date}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="center">{{ row.date }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Status Column -->
|
||||
@@ -55,23 +89,34 @@
|
||||
<ng-container matColumnDef="prints">
|
||||
<mat-header-cell *matHeaderCellDef>Prints</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row; let i = index" class="no-bg">
|
||||
{{row.prints}}
|
||||
<mat-icon *ngIf="!form.controls.attendances.controls[i].pristine">new_releases</mat-icon>
|
||||
{{ row.prints }}
|
||||
<mat-icon *ngIf="!form.controls.attendances.controls[i].pristine"
|
||||
>new_releases</mat-icon
|
||||
>
|
||||
<mat-chip-list class="no-bg">
|
||||
<mat-chip *ngIf="row.hoursWorked.length" class="no-bg" [selected]="true"
|
||||
[color]="row.fullDay === true ? 'primary' : 'warn'">
|
||||
{{row.hoursWorked}}
|
||||
<mat-chip
|
||||
*ngIf="row.hoursWorked.length"
|
||||
class="no-bg"
|
||||
[selected]="true"
|
||||
[color]="row.fullDay === true ? 'primary' : 'warn'"
|
||||
>
|
||||
{{ row.hoursWorked }}
|
||||
</mat-chip>
|
||||
</mat-chip-list>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; let i = index; columns: displayedColumns;" [class]="getClass(i)"></mat-row>
|
||||
<mat-row
|
||||
*matRowDef="let row; let i = index; columns: displayedColumns"
|
||||
[class]="getClass(i)"
|
||||
></mat-row>
|
||||
</mat-table>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" (click)="save()" [disabled]="form.pristine">Save</button>
|
||||
<button mat-raised-button color="primary" (click)="save()" [disabled]="form.pristine">
|
||||
Save
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import {FormArray, FormBuilder, FormGroup} from '@angular/forms';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {BehaviorSubject, Observable, of as observableOf} from 'rxjs';
|
||||
import {EmployeeAttendanceDataSource} from './employee-attendance-datasource';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
|
||||
import { EmployeeAttendanceDataSource } from './employee-attendance-datasource';
|
||||
import * as moment from 'moment';
|
||||
import {AuthService} from '../auth/auth.service';
|
||||
import {ToasterService} from '../core/toaster.service';
|
||||
import {EmployeeAttendanceService} from './employee-attendance.service';
|
||||
import {EmployeeAttendance, EmployeeAttendanceItem} from './employee-attendance';
|
||||
import {EmployeeService} from '../employee/employee.service';
|
||||
import {Employee} from '../employee/employee';
|
||||
import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators';
|
||||
import {AttendanceType} from '../attendance/attendance-type';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { EmployeeAttendanceService } from './employee-attendance.service';
|
||||
import { EmployeeAttendance, EmployeeAttendanceItem } from './employee-attendance';
|
||||
import { EmployeeService } from '../employee/employee.service';
|
||||
import { Employee } from '../employee/employee';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
import { AttendanceType } from '../attendance/attendance-type';
|
||||
|
||||
@Component({
|
||||
selector: 'app-employee-attendance',
|
||||
templateUrl: './employee-attendance.component.html',
|
||||
styleUrls: ['./employee-attendance.component.css']
|
||||
styleUrls: ['./employee-attendance.component.css'],
|
||||
})
|
||||
export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('employeeElement', { static: true }) employeeElement: ElementRef;
|
||||
@@ -41,30 +41,34 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
private toaster: ToasterService,
|
||||
private auth: AuthService,
|
||||
private ser: EmployeeAttendanceService,
|
||||
private employeeSer: EmployeeService
|
||||
private employeeSer: EmployeeService,
|
||||
) {
|
||||
this.createForm();
|
||||
this.listenToEmployeeValueChanges();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: EmployeeAttendance, attendanceTypes: AttendanceType[] }) => {
|
||||
this.route.data.subscribe(
|
||||
(data: { info: EmployeeAttendance; attendanceTypes: AttendanceType[] }) => {
|
||||
this.info = data.info;
|
||||
this.attendanceTypes = data.attendanceTypes;
|
||||
this.form.get('startDate').setValue(moment(this.info.startDate, 'DD-MMM-YYYY').toDate());
|
||||
this.form.get('finishDate').setValue(moment(this.info.finishDate, 'DD-MMM-YYYY').toDate());
|
||||
this.form.get('employee').setValue(this.info.employee);
|
||||
this.form.setControl('attendances', this.fb.array(
|
||||
this.info.body.map(
|
||||
x => this.fb.group({
|
||||
attendanceType: x.attendanceType.id
|
||||
})
|
||||
)
|
||||
));
|
||||
this.form.setControl(
|
||||
'attendances',
|
||||
this.fb.array(
|
||||
this.info.body.map((x) =>
|
||||
this.fb.group({
|
||||
attendanceType: x.attendanceType.id,
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
this.dataSource = new EmployeeAttendanceDataSource(this.employeeAttendanceObservable);
|
||||
this.employeeAttendanceObservable.next(this.info.body);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
@@ -78,20 +82,18 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
employee: '',
|
||||
attendances: this.fb.array([])
|
||||
attendances: this.fb.array([]),
|
||||
});
|
||||
}
|
||||
|
||||
listenToEmployeeValueChanges() {
|
||||
this.employees = this.form.get('employee').valueChanges
|
||||
.pipe(
|
||||
startWith(null),
|
||||
map(x => (x !== null && x.length >= 1) ? x : null),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap(x => (x === null) ? observableOf([]) : this.employeeSer.autocomplete(x))
|
||||
);
|
||||
|
||||
this.employees = this.form.get('employee').valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) => (x === null ? observableOf([]) : this.employeeSer.autocomplete(x))),
|
||||
);
|
||||
}
|
||||
|
||||
displayFn(employee?: Employee): string | undefined {
|
||||
@@ -102,10 +104,10 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
this.info.employee = event.option.value;
|
||||
}
|
||||
|
||||
getClass(index: number) {
|
||||
getClass(index: number) {
|
||||
const array = this.form.get('attendances') as FormArray;
|
||||
const id = array.controls[index].value.attendanceType;
|
||||
const name: string = this.attendanceTypes.filter(x => x.id === id)[0].name;
|
||||
const name: string = this.attendanceTypes.filter((x) => x.id === id)[0].name;
|
||||
return name.toLowerCase().replace(/(\s+\+\s+)|(\s+)/g, '-');
|
||||
}
|
||||
|
||||
@@ -116,22 +118,20 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
this.router.navigate(['/employee-attendance', this.info.employee.id], {
|
||||
queryParams: {
|
||||
startDate: this.info.startDate,
|
||||
finishDate: this.info.finishDate
|
||||
}
|
||||
finishDate: this.info.finishDate,
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.save(this.getEmployeeAttendance())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
}
|
||||
);
|
||||
this.ser.save(this.getEmployeeAttendance()).subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
getEmployeeAttendance(): EmployeeAttendance {
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule } from '@angular/material/core';
|
||||
import {
|
||||
DateAdapter,
|
||||
MAT_DATE_FORMATS,
|
||||
MAT_DATE_LOCALE,
|
||||
MatNativeDateModule,
|
||||
} from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
@@ -16,14 +21,14 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import {SharedModule} from '../shared/shared.module';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import {CdkTableModule} from '@angular/cdk/table';
|
||||
import {EmployeeAttendanceRoutingModule} from './employee-attendance-routing.module';
|
||||
import {EmployeeAttendanceComponent} from './employee-attendance.component';
|
||||
import {MomentDateAdapter} from '@angular/material-moment-adapter';
|
||||
import {A11yModule} from '@angular/cdk/a11y';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { EmployeeAttendanceRoutingModule } from './employee-attendance-routing.module';
|
||||
import { EmployeeAttendanceComponent } from './employee-attendance.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
@@ -61,15 +66,12 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
EmployeeAttendanceRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
EmployeeAttendanceComponent
|
||||
EmployeeAttendanceRoutingModule,
|
||||
],
|
||||
declarations: [EmployeeAttendanceComponent],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
|
||||
],
|
||||
})
|
||||
export class EmployeeAttendanceModule {
|
||||
}
|
||||
export class EmployeeAttendanceModule {}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {EmployeeAttendance} from './employee-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, HttpParams } from '@angular/common/http';
|
||||
import { EmployeeAttendance } from './employee-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/employee-attendance';
|
||||
const serviceName = 'EmployeeAttendanceService';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class EmployeeAttendanceService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(id: string, startDate: string, finishDate: string): Observable<EmployeeAttendance> {
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
const options = {params: new HttpParams()};
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
}
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<EmployeeAttendance>>this.http.get<EmployeeAttendance>(getUrl, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
);
|
||||
return <Observable<EmployeeAttendance>>(
|
||||
this.http
|
||||
.get<EmployeeAttendance>(getUrl, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
|
||||
);
|
||||
}
|
||||
|
||||
save(employeeAttendance: EmployeeAttendance): Observable<EmployeeAttendance> {
|
||||
const id = employeeAttendance.employee.id;
|
||||
return <Observable<EmployeeAttendance>>this.http.post<EmployeeAttendance>(`${url}/${id}`, employeeAttendance, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
return <Observable<EmployeeAttendance>>(
|
||||
this.http
|
||||
.post<EmployeeAttendance>(`${url}/${id}`, employeeAttendance, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Employee} from '../employee/employee';
|
||||
import {AttendanceType} from '../attendance/attendance-type';
|
||||
import { Employee } from '../employee/employee';
|
||||
import { AttendanceType } from '../attendance/attendance-type';
|
||||
|
||||
export class EmployeeAttendance {
|
||||
startDate: string;
|
||||
|
||||
Reference in New Issue
Block a user