feat(centers && groups) : Centers and groups list (#238)
*feat(centers && groups) : Centers and groups list (#238)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { Route, extract } from '../core';
|
||||
import { CentersComponent } from './centers.component';
|
||||
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
|
||||
{
|
||||
path: 'centers',
|
||||
component: CentersComponent,
|
||||
data: { title: extract('Centers'), breadcrumb: 'Centers' }
|
||||
}
|
||||
])
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: []
|
||||
})
|
||||
export class CentersRoutingModule { }
|
||||
@@ -0,0 +1,53 @@
|
||||
<div class="container m-t-40 m-b-40">
|
||||
|
||||
<mat-form-field class="filter">
|
||||
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
|
||||
</mat-form-field>
|
||||
|
||||
<div class="mat-elevation-z8">
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header='name'> Name </th>
|
||||
<td mat-cell *matCellDef="let row"> {{row?.name}} </td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="accountno">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header='accountno'> Account # </th>
|
||||
<td mat-cell *matCellDef="let row"> {{row?.accountNo}} </td>
|
||||
</ng-container>
|
||||
|
||||
<!-- Account no Column -->
|
||||
<ng-container matColumnDef="externalid">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header='externalid'> ExternalID </th>
|
||||
<td mat-cell *matCellDef="let row"> {{row?.externalId}} </td>
|
||||
</ng-container>
|
||||
|
||||
<!-- External ID Column -->
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header='status'> Status </th>
|
||||
<td mat-cell *matCellDef="let row"> <div [className]="row.active === true ? 'active' : 'inactive'">
|
||||
<i class="fa fa-circle fa-2x"> </i>
|
||||
</div> </td>
|
||||
|
||||
</ng-container>
|
||||
|
||||
|
||||
|
||||
<!-- Status Column -->
|
||||
<ng-container matColumnDef="office">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header='office'> Office </th>
|
||||
<td mat-cell *matCellDef="let row"> {{row?.officeName}} </td>
|
||||
</ng-container>
|
||||
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="[ ]">
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 100]"></mat-paginator>
|
||||
</div>
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mat-form-field {
|
||||
font-size: 14px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td, th {
|
||||
width: 15%;
|
||||
}
|
||||
|
||||
.filter{
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.inactive {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.active {
|
||||
color: green;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
|
||||
import { CentersService } from 'app/centers/centers.service';
|
||||
import {DataSource} from '@angular/cdk/collections';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-app-centers',
|
||||
templateUrl: './centers.component.html',
|
||||
styleUrls: ['./centers.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class CentersComponent implements OnInit {
|
||||
private ELEMENT_DATA: any = undefined;
|
||||
displayedColumns = ['name', 'accountno', 'externalid', 'status', 'office'];
|
||||
dataSource = new MatTableDataSource();
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
constructor(private centerService: CentersService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.centerService.getCenters()
|
||||
.subscribe(
|
||||
(res => {
|
||||
console.log(res);
|
||||
// console.log(res.active);
|
||||
res.active = !!res.active;
|
||||
this.dataSource = new MatTableDataSource(res);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
applyFilter(filterValue: string) {
|
||||
filterValue = filterValue.trim(); // Remove whitespace
|
||||
filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches
|
||||
this.dataSource.filter = filterValue;
|
||||
if (this.dataSource.paginator) {
|
||||
this.dataSource.paginator.firstPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { CoreModule } from '../core/core.module';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
import { CentersComponent } from './centers.component';
|
||||
import { CentersRoutingModule } from 'app/centers/centers-routing.module';
|
||||
import { CentersService } from './centers.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreModule,
|
||||
CommonModule,
|
||||
CentersRoutingModule,
|
||||
FormsModule,
|
||||
MatTableModule,
|
||||
FlexLayoutModule
|
||||
|
||||
],
|
||||
declarations: [CentersComponent],
|
||||
schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
]
|
||||
})
|
||||
export class CentersModule { }
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
|
||||
export class CentersService {
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
getCenters(): Observable<any> {
|
||||
return this.http.get('/centers');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user