feat: add users components

- Add Users component
- Add View Users component

Fixes: #484
This commit is contained in:
punwai
2019-12-23 06:41:43 +05:30
committed by Jivjyot Singh
parent 7357a1fb4c
commit 6b250f081a
10 changed files with 281 additions and 1 deletions
+65
View File
@@ -0,0 +1,65 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
/** rxjs Imports */
import { of } from 'rxjs';
/**
* Users component.
*/
@Component({
selector: 'mifosx-users',
templateUrl: './users.component.html',
styleUrls: ['./users.component.scss']
})
export class UsersComponent implements OnInit {
/** Users data. */
usersData: any;
/** Columns to be displayed in users table. */
displayedColumns: string[] = ['firstname', 'lastname', 'email', 'officeName'];
/** Data source for users table. */
dataSource: MatTableDataSource<any>;
/** Paginator for users table. */
@ViewChild(MatPaginator) paginator: MatPaginator;
/** Sorter for users table. */
@ViewChild(MatSort) sort: MatSort;
/**
* Retrieves the users data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute) {
this.route.data.subscribe(( data: { users: any }) => {
this.usersData = data.users;
});
}
/**
* Filters data in users table based on passed value.
* @param {string} filterValue Value to filter data.
*/
applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
/**
* Sets the users table.
*/
ngOnInit() {
this.setUsers();
}
/**
* Initializes the data source, paginator and sorter for users table.
*/
setUsers() {
this.dataSource = new MatTableDataSource(this.usersData);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
}