Add table destroy event
This commit is contained in:
parent
88f6a13016
commit
84b8bc0136
|
@ -1,4 +1,4 @@
|
|||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { TableType } from 'src/app/_models/TableType';
|
||||
import { ApiClientService } from 'src/app/_services/api-client.service';
|
||||
import { AuthService } from '../../_services/auth.service';
|
||||
|
@ -8,7 +8,7 @@ import { AuthService } from '../../_services/auth.service';
|
|||
templateUrl: './table.component.html',
|
||||
styleUrls: ['./table.component.scss']
|
||||
})
|
||||
export class TableComponent implements OnInit {
|
||||
export class TableComponent implements OnInit, OnDestroy {
|
||||
|
||||
@Input() sourceType?: string;
|
||||
@Input() refreshInterval?: number;
|
||||
|
@ -17,7 +17,7 @@ export class TableComponent implements OnInit {
|
|||
|
||||
public data: any = [];
|
||||
|
||||
public loadDataInterval: NodeJS.Timer | number = 0;
|
||||
public loadDataInterval: NodeJS.Timer | undefined = undefined;
|
||||
|
||||
constructor(public apiClient: ApiClientService, public auth: AuthService) {}
|
||||
|
||||
|
@ -44,6 +44,12 @@ export class TableComponent implements OnInit {
|
|||
}, this.refreshInterval || 10000);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if(typeof this.loadDataInterval !== 'undefined') {
|
||||
clearInterval(this.loadDataInterval);
|
||||
}
|
||||
}
|
||||
|
||||
onChangeAvailability(user: number, newState: 0|1) {
|
||||
if(this.auth.profile.full_viewer) {
|
||||
this.changeAvailability.emit({user, newState});
|
||||
|
|
Loading…
Reference in New Issue