import { Component, OnInit,Inject } from '@angular/core';
import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material';
import {Device} from '../../device';
import {ContactService} from '../../contact.service';
import { SidebarComponent } from '../../sidebar/sidebar.component';

@Component({
  selector: 'app-speednotify',
  templateUrl: './speednotify.component.html',
  styleUrls: ['./speednotify.component.scss'],
  providers: [ContactService,SidebarComponent]
})
export class SpeednotifyComponent implements OnInit {

  dname:any;
  did:any;
  status:any;
  speed:any;

  speedAlert(){

    this.contactService.speedlimit(this.did,this.speed,"true").subscribe(
      
      data => {
        this.dataa = data 
        window.localStorage['DataUpdate'] = 'True'
        this.sidebar.sidebarData()
        this.dialogRef.close("device_alert");

      })


  }
 // speeed:any;
  constructor(public dialogRef: MdDialogRef<SpeednotifyComponent>,
    @Inject(MD_DIALOG_DATA) public data: any,private contactService: ContactService,private sidebar: SidebarComponent) {
        
     // console.log(data)
      this.dname = data.dname;
      this.did = data.did;
      this.status = data.status;
      this.speed = data.speed;
      //console.log(data.speed)
     }

     onNoClick(a): void {
      this.dialogRef.close(a);
     }
     dataa:any
  ngOnInit() {
 
  }

}
