@@ -0,0 +1,26 @@
|
||||
<div class="container">
|
||||
|
||||
<div class="mat-elevation-z8">
|
||||
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<ng-container matColumnDef="notification">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Notification </th>
|
||||
<td mat-cell *matCellDef="let notification"> {{ notification.content }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="createdAt">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Created At </th>
|
||||
<td mat-cell *matCellDef="let notification"> {{ notification.createdAt }} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotificationsPageComponent } from './notifications-page.component';
|
||||
|
||||
describe('NotificationsPageComponent', () => {
|
||||
let component: NotificationsPageComponent;
|
||||
let fixture: ComponentFixture<NotificationsPageComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ NotificationsPageComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NotificationsPageComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
/**
|
||||
* Notifications Page Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-notifications-page',
|
||||
templateUrl: './notifications-page.component.html',
|
||||
styleUrls: ['./notifications-page.component.scss']
|
||||
})
|
||||
export class NotificationsPageComponent implements OnInit {
|
||||
|
||||
/** Notifications data. */
|
||||
notificationsData: any;
|
||||
/** Columns to be displayed in notifications table. */
|
||||
displayedColumns: string[] = ['notification', 'createdAt'];
|
||||
/** Data source for notifications table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for notifications table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for notifications table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the notifications data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { notifications: any }) => {
|
||||
this.notificationsData = data.notifications.pageItems;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the notifications table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setNotifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for notifications table.
|
||||
*/
|
||||
setNotifications() {
|
||||
this.dataSource = new MatTableDataSource(this.notificationsData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user