File
Implements
Metadata
changeDetection |
ChangeDetectionStrategy.OnPush |
selector |
app-settings |
styleUrls |
./settings.component.scss |
templateUrl |
./settings.component.html |
Methods
doFilter
|
doFilter(value: string)
|
|
Parameters :
Name |
Type |
Optional |
value |
string
|
No
|
|
downloadCsv
|
downloadCsv()
|
|
|
dataSource
|
Type : MatTableDataSource<any>
|
|
displayedColumns
|
Type : Array<string>
|
Default value : ['name', 'email', 'userId']
|
|
paginator
|
Type : MatPaginator
|
Decorators :
@ViewChild(MatPaginator)
|
|
sort
|
Type : MatSort
|
Decorators :
@ViewChild(MatSort)
|
|
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';
@Component({
selector: 'app-settings',
templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SettingsComponent implements OnInit {
date: string;
dataSource: MatTableDataSource<any>;
displayedColumns: Array<string> = ['name', 'email', 'userId'];
trustedUsers: Array<Staff>;
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
constructor(
private authService: AuthService
) { }
ngOnInit(): void {
const d = new Date();
this.date = `${d.getDate()}/${d.getMonth()}/${d.getFullYear()}`;
this.trustedUsers = this.authService.getTrustedUsers();
this.dataSource = new MatTableDataSource<any>(this.trustedUsers);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
doFilter(value: string): void {
this.dataSource.filter = value.trim().toLocaleLowerCase();
}
downloadCsv(): void {
exportCsv(this.trustedUsers, 'users');
}
logout(): void {
this.authService.logout();
}
}
<!-- Begin page -->
<div class="wrapper">
<app-sidebar></app-sidebar>
<!-- ============================================================== -->
<!-- Start Page Content here -->
<!-- ============================================================== -->
<div id="content">
<app-topbar></app-topbar>
<!-- Start Content-->
<div class="container-fluid" appMenuSelection>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a routerLink="/home">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Settings</li>
</ol>
</nav>
<div class="row">
<div class="col-md-6 mb-2">
<div class="card">
<mat-card-title class="card-header text-center">
SETTINGS
</mat-card-title>
<div class="card-body">
<h4>Kobo Toolbox Credentials</h4>
<span><strong>Username: </strong> admin_reserve </span><br>
<span><strong>Password: </strong> ******** </span>
</div>
<hr>
<div class="card-body">
<h4>Organization Settings</h4>
<a routerLink="/settings/organization"><i>Update your organization settings</i></a>
</div>
</div>
</div>
<div class="col-md-6 mb-2">
<div class="card">
<mat-card-title class="card-header text-center">
ACCOUNT MANAGEMENT
</mat-card-title>
<div class="card-body">
<h4>Change Password</h4>
<a routerLink="/settings"><i>Change your account password</i></a>
</div>
<hr>
<div class="card-body">
<h4>Two-step authentication</h4>
<a routerLink="/settings"><i>Secure your account with two step verification</i></a>
</div>
<hr>
<div class="card-body">
<button mat-raised-button color="primary" type="button" class="btn btn-outline-primary" (click)="logout()"> LOGOUT ADMIN </button>
</div>
</div>
</div>
<div class="col-12">
<div class="card mb-3">
<mat-card-title class="card-header">
<div class="row">
TRUSTED USERS
<button mat-raised-button color="primary" type="button" class="btn btn-outline-primary ml-auto mr-2" (click)="downloadCsv()"> EXPORT </button>
</div>
</mat-card-title>
<div class="card-body">
<mat-form-field appearance="outline">
<mat-label> Filter </mat-label>
<input matInput type="text" (keyup)="doFilter($event.target.value)" placeholder="Filter">
<mat-icon matSuffix>search</mat-icon>
</mat-form-field>
<mat-table class="mat-elevation-z10" [dataSource]="dataSource" matSort matSortActive="name"
matSortDirection="asc" matSortDisableClear>
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header> NAME </mat-header-cell>
<mat-cell *matCellDef="let user"> {{user.name}} </mat-cell>
</ng-container>
<ng-container matColumnDef="email">
<mat-header-cell *matHeaderCellDef mat-sort-header> EMAIL </mat-header-cell>
<mat-cell *matCellDef="let user"> {{user.email}} </mat-cell>
</ng-container>
<ng-container matColumnDef="userId">
<mat-header-cell *matHeaderCellDef mat-sort-header> USER ID </mat-header-cell>
<mat-cell *matCellDef="let user"> {{user.userid}} </mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let user; columns: displayedColumns"></mat-row>
</mat-table>
<mat-paginator [pageSize]="5" [pageSizeOptions]="[5, 10, 20, 50, 100]" showFirstLastButtons></mat-paginator>
</div>
</div>
</div>
</div>
</div>
<app-footer appMenuSelection></app-footer>
</div>
<!-- ============================================================== -->
<!-- End Page content -->
<!-- ============================================================== -->
</div>
Legend
Html element with directive