committed by
Abhay Chawla
parent
1c8e953e38
commit
0229cf2515
@@ -0,0 +1,40 @@
|
||||
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
|
||||
<button mat-raised-button color="primary">
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
Create Data Table
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div fxLayout="row" fxLayoutGap="20px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Filter</mat-label>
|
||||
<input matInput (keyup)="applyFilter($event.target.value)">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div class="mat-elevation-z8">
|
||||
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<ng-container matColumnDef="registeredTableName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Data Table Name </th>
|
||||
<td mat-cell *matCellDef="let dataTable"> {{ dataTable.registeredTableName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="applicationTableName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Associated With </th>
|
||||
<td mat-cell *matCellDef="let dataTable"> {{ dataTable.applicationTableName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
table {
|
||||
width: 100%;
|
||||
|
||||
.select-row:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ManageDataTablesComponent } from './manage-data-tables.component';
|
||||
|
||||
describe('ManageDataTablesComponent', () => {
|
||||
let component: ManageDataTablesComponent;
|
||||
let fixture: ComponentFixture<ManageDataTablesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ManageDataTablesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ManageDataTablesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
* Manage Data Tables component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-manage-data-tables',
|
||||
templateUrl: './manage-data-tables.component.html',
|
||||
styleUrls: ['./manage-data-tables.component.scss']
|
||||
})
|
||||
export class ManageDataTablesComponent implements OnInit {
|
||||
|
||||
/** Data table data. */
|
||||
dataTableData: any;
|
||||
/** Columns to be displayed in manage data tables table. */
|
||||
displayedColumns: string[] = ['registeredTableName', 'applicationTableName'];
|
||||
/** Data source for manage data tables table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for manage data tables table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for manage data tables table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the data tables data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { dataTables: any }) => {
|
||||
this.dataTableData = data.dataTables;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in manage data tables table based on passed value.
|
||||
* @param {string} filterValue Value to filter data.
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the manage data tables table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setDataTables();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for manage data tables table.
|
||||
*/
|
||||
setDataTables() {
|
||||
this.dataSource = new MatTableDataSource(this.dataTableData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** Custom Services */
|
||||
import { SystemService } from '../system.service';
|
||||
|
||||
/**
|
||||
* Manage data tables data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class ManageDataTablesResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {SystemService} systemService System service.
|
||||
*/
|
||||
constructor(private systemService: SystemService) {}
|
||||
|
||||
/**
|
||||
* Returns the manage data tables data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.systemService.getDataTables();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,9 +10,11 @@ import { SystemComponent } from './system.component';
|
||||
import { CodesComponent } from './codes/codes.component';
|
||||
import { CreateCodeComponent } from './codes/create-code/create-code.component';
|
||||
import { ExternalServicesComponent } from './external-services/external-services.component';
|
||||
import { ManageDataTablesComponent } from './manage-data-tables/manage-data-tables.component';
|
||||
|
||||
/** Custom Resolvers */
|
||||
import { CodesResolver } from './codes/codes.resolver';
|
||||
import { ManageDataTablesResolver } from './manage-data-tables/manage-data-tables.resolver';
|
||||
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
@@ -48,6 +50,14 @@ const routes: Routes = [
|
||||
component: ExternalServicesComponent,
|
||||
data: { title: extract('External Services'), breadcrumb: 'External Services' },
|
||||
},
|
||||
{
|
||||
path: 'data-tables',
|
||||
component: ManageDataTablesComponent,
|
||||
resolve: {
|
||||
dataTables: ManageDataTablesResolver
|
||||
},
|
||||
data: { title: extract('Manage Data Tables'), breadcrumb: 'Manage Data Tables' },
|
||||
},
|
||||
]
|
||||
}
|
||||
])
|
||||
@@ -56,6 +66,9 @@ const routes: Routes = [
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [CodesResolver]
|
||||
providers: [
|
||||
CodesResolver,
|
||||
ManageDataTablesResolver
|
||||
]
|
||||
})
|
||||
export class SystemRoutingModule { }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<mat-nav-list>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['data-tables']">
|
||||
<mat-icon matListIcon>
|
||||
<fa-icon icon="table" size="sm"></fa-icon>
|
||||
</mat-icon>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { CodesComponent } from './codes/codes.component';
|
||||
import { SystemComponent } from './system.component';
|
||||
import { CreateCodeComponent } from './codes/create-code/create-code.component';
|
||||
import { ExternalServicesComponent } from './external-services/external-services.component';
|
||||
import { ManageDataTablesComponent } from './manage-data-tables/manage-data-tables.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -21,6 +22,7 @@ import { ExternalServicesComponent } from './external-services/external-services
|
||||
CodesComponent,
|
||||
CreateCodeComponent,
|
||||
ExternalServicesComponent,
|
||||
ManageDataTablesComponent
|
||||
]
|
||||
})
|
||||
export class SystemModule { }
|
||||
|
||||
@@ -18,6 +18,13 @@ export class SystemService {
|
||||
*/
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Data tables.
|
||||
*/
|
||||
getDataTables(): Observable<any> {
|
||||
return this.http.get('/datatables');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Fetches Codes.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user