import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {SocketService} from "./shared/services/socket.service";
import {AlarmSoundService} from "./shared/services/alarm-sound.service";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit, AfterViewInit {
  title = 'Iot-web-ui';
  @ViewChild('clickButton') clickButton!: ElementRef<HTMLButtonElement>;

  constructor(private socketService$: SocketService,
              public alarmSoundService$: AlarmSoundService,) {
  }

  ngOnInit() {
    this.socketService$.connect();
  }
  ngAfterViewInit(): void {
    console.log('click');
    this.simulateButtonClick();
  }

  simulateButtonClick() {
    this.alarmSoundService$.simulateClick(this.clickButton.nativeElement);
  }
}
