cic-staff-client/src/app/pages/settings/settings.component.ts

40 lines
1.3 KiB
TypeScript
Raw Normal View History

import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/core';
2020-11-25 08:59:48 +01:00
import {MatTableDataSource} from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort';
2021-03-16 18:13:48 +01:00
import {AuthService} from '@app/_services';
import {Staff} from '@app/_models/staff';
2020-11-25 08:59:48 +01:00
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
2020-11-25 08:59:48 +01:00
})
export class SettingsComponent implements OnInit {
2020-11-25 08:59:48 +01:00
date: string;
dataSource: MatTableDataSource<any>;
2021-03-16 18:13:48 +01:00
displayedColumns = ['name', 'email', 'userId'];
trustedUsers: Staff[];
2020-11-25 08:59:48 +01:00
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
constructor(
2021-03-16 18:13:48 +01:00
private authService: AuthService
) { }
2020-11-25 08:59:48 +01:00
ngOnInit(): void {
const d = new Date();
this.date = `${d.getDate()}/${d.getMonth()}/${d.getFullYear()}`;
2021-03-16 18:13:48 +01:00
this.trustedUsers = this.authService.getTrustedUsers();
this.dataSource = new MatTableDataSource<any>(this.trustedUsers);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
2020-11-25 08:59:48 +01:00
}
doFilter(value: string): void {
this.dataSource.filter = value.trim().toLocaleLowerCase();
}
}