src/app/timeout/timeout.component.ts
host | { |
selector | app-timeout |
styleUrls | timeout.component.css |
templateUrl | ./timeout.component.html |
Properties |
Methods |
Inputs |
constructor(timeoutService: TimeoutService)
|
||||||
Defined in src/app/timeout/timeout.component.ts:22
|
||||||
Parameters :
|
delegate
|
Type: |
Defined in src/app/timeout/timeout.component.ts:22
|
ngOnInit |
ngOnInit()
|
Defined in src/app/timeout/timeout.component.ts:26
|
Returns :
void
|
onAction |
onAction()
|
Defined in src/app/timeout/timeout.component.ts:37
|
Returns :
void
|
setupTimeout |
setupTimeout()
|
Defined in src/app/timeout/timeout.component.ts:45
|
Returns :
void
|
stayActive |
stayActive()
|
Defined in src/app/timeout/timeout.component.ts:41
|
Returns :
void
|
timeout |
timeout()
|
Defined in src/app/timeout/timeout.component.ts:30
|
Returns :
void
|
inactive |
inactive:
|
Default value : false
|
Defined in src/app/timeout/timeout.component.ts:24
|
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>