pd schedule changes

This commit is contained in:
gandhimathi 2019-01-22 17:10:53 +05:30
parent f146c7809d
commit 5d23626fad

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Inject, Pipe, PipeTransform } from '@angular/core';
import { Component, OnInit, Inject, Pipe, PipeTransform, OnDestroy } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms';
import { NotifierService } from 'angular-notifier';
@ -15,7 +15,8 @@ export interface Timeslot {
templateUrl: './schedule-pd.component.html',
styleUrls: ['./schedule-pd.component.scss']
})
export class SchedulePdComponent implements OnInit {
export class SchedulePdComponent implements OnInit, OnDestroy {
public pageTitle: string = "PD Schedule";
pipe = new DatePipe('en-US');
public selectedMoment = new Date();
@ -55,6 +56,7 @@ export class SchedulePdComponent implements OnInit {
// ];
public min = new Date();
validateTime:any;
constructor(notifier: NotifierService, private dialogRef: MatDialogRef<SchedulePdComponent>,
private _pd: PdTrigerService,
@Inject(MAT_DIALOG_DATA) public data: any) {
@ -62,7 +64,16 @@ export class SchedulePdComponent implements OnInit {
}
ngOnInit() {
this.validateTime = setInterval(() => {
let currentTime:any = new Date();
currentTime = currentTime.getFullYear()+'-'+currentTime.getMonth()+'-'+currentTime.getDay()+currentTime.getHours()+'-'+currentTime.getMinutes();
let existTime:any = this.selectedMoment.getFullYear()+'-'+this.selectedMoment.getMonth()+'-'+this.selectedMoment.getDay() +'-'+this.selectedMoment.getHours()+'-'+this.selectedMoment.getMinutes();
if(existTime < currentTime) {
this.selectedMoment = new Date();
this.min = new Date();
}
},1000);
}
// close pd schedule pop up
@ -72,6 +83,7 @@ export class SchedulePdComponent implements OnInit {
// update pd schedule
upatePDSchedule(date:any){
let myFormattedDate = this.pipe.transform(date, 'yyyy-MM-dd HH:mm');
let updateData = {
@ -94,4 +106,7 @@ export class SchedulePdComponent implements OnInit {
this.dialogRef.close();
});
}
ngOnDestroy(): void {
clearInterval(this.validateTime);
}
}