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
|
|
|
dataSource: MatTableDataSource<any>;
|
2021-04-30 14:50:16 +02:00
|
|
|
displayedColumns: Array<string> = ['name', 'email', 'userId'];
|
|
|
|
trustedUsers: Array<Staff>;
|
2021-05-18 09:33:38 +02:00
|
|
|
userInfo: Staff;
|
2021-07-13 18:57:28 +02:00
|
|
|
loading: boolean = true;
|
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
|
|
|
|
2021-07-13 18:57:28 +02:00
|
|
|
ngOnInit(): void {
|
2021-06-02 09:48:02 +02:00
|
|
|
this.authService.trustedUsersSubject.subscribe((users) => {
|
|
|
|
this.dataSource = new MatTableDataSource<any>(users);
|
|
|
|
this.dataSource.paginator = this.paginator;
|
|
|
|
this.dataSource.sort = this.sort;
|
|
|
|
this.trustedUsers = users;
|
2021-07-13 18:57:28 +02:00
|
|
|
if (users.length > 0) {
|
|
|
|
this.loading = false;
|
|
|
|
}
|
2021-06-02 09:48:02 +02:00
|
|
|
});
|
2021-05-18 09:33:38 +02:00
|
|
|
this.userInfo = this.authService.getPrivateKeyInfo();
|
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
|
|
|
}
|