2021-05-10 18:15:25 +02:00
|
|
|
import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core';
|
|
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
|
|
import { MatPaginator } from '@angular/material/paginator';
|
|
|
|
import { MatSort } from '@angular/material/sort';
|
|
|
|
import { AuthService } from '@app/_services';
|
|
|
|
import { Staff } from '@app/_models/staff';
|
|
|
|
import { exportCsv } from '@app/_helpers';
|
2020-11-25 08:59:48 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-settings',
|
|
|
|
templateUrl: './settings.component.html',
|
2021-03-14 09:23:20 +01:00
|
|
|
styleUrls: ['./settings.component.scss'],
|
2021-05-10 18:15:25 +02:00
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
2020-11-25 08:59:48 +01:00
|
|
|
})
|
2020-12-05 07:30:30 +01:00
|
|
|
export class SettingsComponent implements OnInit {
|
2020-11-25 08:59:48 +01:00
|
|
|
date: string;
|
|
|
|
dataSource: MatTableDataSource<any>;
|
2021-04-30 14:50:16 +02:00
|
|
|
displayedColumns: Array<string> = ['name', 'email', 'userId'];
|
|
|
|
trustedUsers: Array<Staff>;
|
2020-11-25 08:59:48 +01:00
|
|
|
|
|
|
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
|
|
|
@ViewChild(MatSort) sort: MatSort;
|
|
|
|
|
2021-05-10 18:15:25 +02:00
|
|
|
constructor(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();
|
|
|
|
}
|
2021-03-24 14:26:51 +01:00
|
|
|
|
|
|
|
downloadCsv(): void {
|
|
|
|
exportCsv(this.trustedUsers, 'users');
|
|
|
|
}
|
2021-03-24 17:41:11 +01:00
|
|
|
|
|
|
|
logout(): void {
|
|
|
|
this.authService.logout();
|
|
|
|
}
|
2020-11-25 08:59:48 +01:00
|
|
|
}
|