Moved to Angular 6.0

----

Pending
* Table width for the points column in incentive
* Linting
* keyboard navigation where it was used earlier
* can remove the unused totals calculated serverside in productledger
* spinner and loading bars
* Activate Guard for Employee Function tabs
* Progress for Fingerprint uploads
* deleted reconcile and receipe features as they were not being used
* focus the right control on component load
This commit is contained in:
tanshu
2018-06-09 17:05:11 +05:30
parent b3cb01da02
commit 6be1dd5a3a
1380 changed files with 23914 additions and 18722 deletions
@@ -0,0 +1,115 @@
import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {MatDatepicker, MatDialog} from '@angular/material';
import {ActivatedRoute, Router} from '@angular/router';
import * as moment from 'moment';
import {Moment} from 'moment';
import {AuthService} from '../auth/auth.service';
import {ToasterService} from '../core/toaster.service';
import {EmployeeService} from '../employee/employee.service';
import {EmployeeFunctionsService} from './employee-functions.service';
@Component({
selector: 'app-employee-functions',
templateUrl: './employee-functions.component.html',
styleUrls: ['./employee-functions.component.css']
})
export class EmployeeFunctionsComponent implements OnInit {
creditSalaryForm: FormGroup;
attendanceRecordForm: FormGroup;
fingerprintForm: FormGroup;
fingerprintFile: File;
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder,
private dialog: MatDialog,
private toaster: ToasterService,
private auth: AuthService,
private ser: EmployeeFunctionsService,
private employeeSer: EmployeeService
) {
this.createForm();
}
ngOnInit() {
}
createForm() {
const startDate = moment().date(1);
const finishDate = moment().date(startDate.daysInMonth());
this.creditSalaryForm = this.fb.group({
date: finishDate
});
this.attendanceRecordForm = this.fb.group({
startDate: startDate,
finishDate: finishDate
});
this.fingerprintForm = this.fb.group({});
}
chosenYearHandler(normalizedYear: Moment) {
const dateControl = this.creditSalaryForm.get('date');
const ctrlValue = dateControl.value;
ctrlValue.year(normalizedYear.year());
ctrlValue.date(ctrlValue.daysInMonth());
dateControl.setValue(ctrlValue);
}
chosenMonthHandler(normlizedMonth: Moment, datepicker: MatDatepicker<Moment>) {
const dateControl = this.creditSalaryForm.get('date');
const ctrlValue = dateControl.value;
ctrlValue.month(normlizedMonth.month());
ctrlValue.date(ctrlValue.daysInMonth());
dateControl.setValue(ctrlValue);
datepicker.close();
}
creditSalary() {
const date = moment(this.creditSalaryForm.get('date').value).format('DD-MMM-YYYY');
if (!date) {
this.toaster.show('Danger', 'Please choose a valid date.');
return;
}
this.ser.creditSalary(date)
.subscribe(
(result) => {
this.toaster.show('Success', 'Salaries Credited');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
}
attendanceRecordUrl() {
const startDate = moment(this.attendanceRecordForm.get('startDate').value).format('DD-MMM-YYYY');
const finishDate = moment(this.attendanceRecordForm.get('finishDate').value).format('DD-MMM-YYYY');
if (!startDate || !finishDate) {
// this.toaster.show('Danger', 'Please choose a start and finish date.');
return;
}
return '/AttendanceReport?StartDate=' + startDate + '&FinishDate=' + finishDate;
}
detectFiles(event) {
this.fingerprintFile = event.target.files[0];
}
uploadFingerprints() {
if (!this.fingerprintFile) {
this.toaster.show('Danger', 'Please choose a file first!');
return;
}
this.ser.uploadFingerprints(this.fingerprintFile)
.subscribe(
(result) => {
this.toaster.show('Success', 'Fingerprints uploaded');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
}
}