feat(centers && groups) : Centers and groups list (#238)
*feat(centers && groups) : Centers and groups list (#238)
This commit is contained in:
@@ -21,6 +21,8 @@ import { LoginModule } from './login/login.module';
|
|||||||
import { ClientsModule} from './clients/clients.module';
|
import { ClientsModule} from './clients/clients.module';
|
||||||
import { AccountingModule } from './accounting/accounting.module';
|
import { AccountingModule } from './accounting/accounting.module';
|
||||||
import { SelfServiceModule } from './self-service/self-service.module';
|
import { SelfServiceModule } from './self-service/self-service.module';
|
||||||
|
import { CentersModule } from './centers/centers.module';
|
||||||
|
import { GroupsModule } from './groups/groups.module';
|
||||||
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { SettingsModule } from './settings/settings.module';
|
import { SettingsModule } from './settings/settings.module';
|
||||||
@@ -44,6 +46,8 @@ import { SettingsModule } from './settings/settings.module';
|
|||||||
AccountingModule,
|
AccountingModule,
|
||||||
SelfServiceModule,
|
SelfServiceModule,
|
||||||
SettingsModule,
|
SettingsModule,
|
||||||
|
CentersModule,
|
||||||
|
GroupsModule,
|
||||||
AppRoutingModule
|
AppRoutingModule
|
||||||
],
|
],
|
||||||
declarations: [WebAppComponent],
|
declarations: [WebAppComponent],
|
||||||
|
|||||||
@@ -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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -71,8 +71,8 @@
|
|||||||
<mat-menu #institutionMenu="matMenu" [overlapTrigger]="false">
|
<mat-menu #institutionMenu="matMenu" [overlapTrigger]="false">
|
||||||
<span>
|
<span>
|
||||||
<button mat-menu-item routerLink="/clients">Clients</button>
|
<button mat-menu-item routerLink="/clients">Clients</button>
|
||||||
<button mat-menu-item>Groups</button>
|
<button mat-menu-item routerLink="/groups">Groups</button>
|
||||||
<button mat-menu-item>Centers</button>
|
<button mat-menu-item routerLink="/centers">Centers</button>
|
||||||
<span fxHide.lg>
|
<span fxHide.lg>
|
||||||
<button mat-menu-item>Accounting</button>
|
<button mat-menu-item>Accounting</button>
|
||||||
<button mat-menu-item [matMenuTriggerFor]="reportsMenu">Reports</button>
|
<button mat-menu-item [matMenuTriggerFor]="reportsMenu">Reports</button>
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import { Route, extract } from '../core';
|
||||||
|
import { GroupsComponent } from './groups.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
Route.withShell([
|
||||||
|
|
||||||
|
{
|
||||||
|
path: 'groups',
|
||||||
|
component: GroupsComponent,
|
||||||
|
data: { title: extract('Groups'), breadcrumb: 'Groups' }
|
||||||
|
}
|
||||||
|
])
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule],
|
||||||
|
providers: []
|
||||||
|
})
|
||||||
|
export class GroupsRoutingModule { }
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<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,44 @@
|
|||||||
|
import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||||
|
import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
|
||||||
|
import { GroupsService } from './groups.service';
|
||||||
|
import {DataSource} from '@angular/cdk/collections';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-app-groups',
|
||||||
|
templateUrl: './groups.component.html',
|
||||||
|
styleUrls: ['./groups.component.scss']
|
||||||
|
})
|
||||||
|
export class GroupsComponent 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 groupService: GroupsService) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.groupService.getGroups()
|
||||||
|
.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,23 @@
|
|||||||
|
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CoreModule } from '../core/core.module';
|
||||||
|
import { MatTableModule } from '@angular/material/table';
|
||||||
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
|
|
||||||
|
import { GroupsComponent } from './groups.component';
|
||||||
|
import { GroupsRoutingModule } from 'app/groups/groups-routing.module';
|
||||||
|
import { GroupsService } from './groups.service';
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
GroupsRoutingModule,
|
||||||
|
CoreModule,
|
||||||
|
MatTableModule,
|
||||||
|
FlexLayoutModule
|
||||||
|
],
|
||||||
|
declarations: [GroupsComponent],
|
||||||
|
schemas: [
|
||||||
|
CUSTOM_ELEMENTS_SCHEMA
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class GroupsModule { }
|
||||||
@@ -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 GroupsService {
|
||||||
|
constructor(private http: HttpClient) { }
|
||||||
|
|
||||||
|
getGroups(): Observable<any> {
|
||||||
|
return this.http.get('/groups');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user