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

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



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

@@ -1,29 +1,24 @@
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({
selector: 'app-root',
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';
@ViewChild('clickButton') clickButton!: ElementRef<HTMLButtonElement>;

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

ngOnInit() {
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

@@ -103,8 +103,12 @@ export class CentralizedSecurityManagementComponent
this.state2 = message.state2 === '0'; // 1 OFF // alarm 1h
this.state5 = message.state5 === '1'; // 1 ON, 0 OFF
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();
}
}

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

@@ -5,7 +5,7 @@ import { ElementRef, Injectable } from '@angular/core';
})
export class AlarmSoundService {
private alertInterval: any;
private alertDuration: number = 30000;
private alertDuration: number = 10000;
private audio = new Audio();
constructor() {
this.audio.src = 'assets/sound/alarm_5m.mp3';

Loading…
Cancel
Save