Browse Source

change time duration

pull/14/head
PhamY0601 1 year ago
parent
commit
14352e6111
4 changed files with 19 additions and 23 deletions
  1. +0
    -3
      src/app/app.component.html
  2. +12
    -17
      src/app/app.component.ts
  3. +6
    -2
      src/app/modules/homepage/centralized-security-management/centralized-security-management.component.ts
  4. +1
    -1
      src/app/shared/services/alarm-sound.service.ts

+ 0
- 3
src/app/app.component.html View File

<router-outlet></router-outlet> <router-outlet></router-outlet>
<button #clickButton (click)="alarmSoundService$.playSound()">Click me to play sound</button>



+ 12
- 17
src/app/app.component.ts View File

import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {SocketService} from "./shared/services/socket.service";
import {AlarmSoundService} from "./shared/services/alarm-sound.service";
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({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
styleUrls: ['./app.component.scss'],
}) })
export class AppComponent implements OnInit, AfterViewInit {
export class AppComponent implements OnInit {
title = 'Iot-web-ui'; title = 'Iot-web-ui';
@ViewChild('clickButton') clickButton!: ElementRef<HTMLButtonElement>;


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


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

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

+ 6
- 2
src/app/modules/homepage/centralized-security-management/centralized-security-management.component.ts View File

this.state2 = message.state2 === '0'; // 1 OFF // alarm 1h this.state2 = message.state2 === '0'; // 1 OFF // alarm 1h
this.state5 = message.state5 === '1'; // 1 ON, 0 OFF this.state5 = message.state5 === '1'; // 1 ON, 0 OFF
this.isReady = message.ready === '1'; this.isReady = message.ready === '1';
// this.alarmSoundService$.startAlarm(true, true, true, this.state2);

this.alarmSoundService$.startAlarm(
this.state5,
this.isReady,
this.state1,
this.state2,
);
this.updateIcons(); this.updateIcons();
} }
} }

+ 1
- 1
src/app/shared/services/alarm-sound.service.ts View File

}) })
export class AlarmSoundService { export class AlarmSoundService {
private alertInterval: any; private alertInterval: any;
private alertDuration: number = 30000;
private alertDuration: number = 10000;
private audio = new Audio(); private audio = new Audio();
constructor() { constructor() {
this.audio.src = 'assets/sound/alarm_5m.mp3'; this.audio.src = 'assets/sound/alarm_5m.mp3';

Loading…
Cancel
Save