header.component.ts 1.14 KB
import { Component, OnInit, HostListener } from '@angular/core';
import { appSettings } from 'src/etc/AppSettings';
import { BsModalService } from 'ngx-bootstrap';
import { ConfiguracionComponent } from '../configuracion/configuracion.component';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {

  private apiImagenes : string = appSettings.apiImagenes;
   timer: any;
   isShowModalConfiguration = false;

  constructor(
    private modalService: BsModalService,
  ) { }

  ngOnInit() {
  }

  @HostListener('document:keydown.Control.Shift.A', ['$event'])
  openConfigurationScreen(delay: number = 3000) {

    if (this.isShowModalConfiguration) return;

    this.modalService.onHide
      .subscribe(() => this.isShowModalConfiguration = false);

    this.timer = setTimeout(() => {

      this.isShowModalConfiguration = true;
      this.modalService.show(ConfiguracionComponent, {
        class: 'modal-md',
        ignoreBackdropClick: true,
      });
    }, delay);
  }

  resetCountDown() {

    clearTimeout(this.timer);
  }

}