File

src/app/timeout/timeout.component.ts

Implements

OnInit

Metadata

host {
}
selector app-timeout
styleUrls timeout.component.css
templateUrl ./timeout.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(timeoutService: TimeoutService)
Parameters :
Name Type Optional
timeoutService TimeoutService no

Inputs

delegate

Type: Function

Methods

ngOnInit
ngOnInit()
Returns : void
onAction
onAction()
Returns : void
setupTimeout
setupTimeout()
Returns : void
stayActive
stayActive()
Returns : void
timeout
timeout()
Returns : void

Properties

inactive
inactive:
Default value : false
import { Component, Input, OnInit } from '@angular/core';

import { TimeoutState } from './timeout-states.enum';
import { TimeoutService } from './timeout.service';

@Component({
  selector: 'app-timeout',
  templateUrl: './timeout.component.html',
  styleUrls: ['./timeout.component.css'],
  // tslint:disable-next-line:use-host-property-decorator
  host: {
    '(document:mousemove)': 'onAction()',
    '(document:mousedown)': 'onAction()',
    '(document:keypress)': 'onAction()',
    '(document:DOMMouseScroll)': 'onAction()',
    '(document:mousewheel)': 'onAction()',
    '(document:touchmove)': 'onAction()',
    '(document:MSPointerMove)': 'onAction()'
  }
})
export class TimeoutComponent implements OnInit {
  @Input() delegate?: Function;
  constructor(private timeoutService: TimeoutService) {}
  inactive = false;

  ngOnInit(): void {
    this.setupTimeout();
  }

  timeout() {
    this.timeoutService.timeout();
    if (this.delegate) {
      this.delegate();
    }
  }

  onAction() {
    this.timeoutService.reset();
  }

  stayActive() {
    this.timeoutService.activate();
  }

  setupTimeout() {
    console.log('setup timeout');
    this.timeoutService.state$.subscribe(state => {
      switch (state) {
        case TimeoutState.INACTIVE:
          this.inactive = true;
          break;
        case TimeoutState.ACTIVE:
          this.inactive = false;
          break;
        case TimeoutState.TIMEDOUT:
          this.inactive = false;
          if (this.delegate) {
            this.delegate();
          }
          break;
      }
    });
    this.timeoutService.startTimer();
  }
}
<div class="overlay scroller" *ngIf="inactive">
  <div class="pop-up-ctn" id="timeOutContainer">

    <div class="close-ctn">
      <a id="closeButton" (click)="stayActive()">
        <i class="material-icons">close</i>
      </a>
    </div>

    <div class="pop-up-ctn-header">
      <p class="header-text">
        <i class="material-icons timeout-icon">access_time</i>Session Timeout</p>
    </div>
    <div class="pop-up-ctn-body">

      <p id="timeoutInfo" class='text-center'>Due to inactivity your pay a person session is about to expire.</p>

      <p class="options">
        <span class="option">
          <a id="continueButton" (click)="stayActive()">Continue</a>
        </span>
        <span class="option">
          <a id="logOffButton" (click)="timeout()">Log Off</a>
        </span>
      </p>

    </div>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""