@@ -0,0 +1,66 @@
|
||||
<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 SMS Campaign
|
||||
</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="campaignName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
|
||||
<td mat-cell *matCellDef="let smsCampaign"> {{ smsCampaign.campaignName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="campaignMessage">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Template Message </th>
|
||||
<td mat-cell *matCellDef="let smsCampaign"> {{ smsCampaign.campaignMessage }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="campaignType.value">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Campaign Type </th>
|
||||
<td mat-cell *matCellDef="let smsCampaign"> {{ smsCampaign.campaignType.value }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="triggerType.value">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Trigger Type </th>
|
||||
<td mat-cell *matCellDef="let smsCampaign"> {{ smsCampaign.triggerType.value }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="campaignStatus.value">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
|
||||
<td mat-cell *matCellDef="let smsCampaign">
|
||||
<div [className]="smsCampaign.campaignStatus.code | statusLookup">
|
||||
<fa-icon matTooltip="{{ smsCampaign.campaignStatus.value | titlecase }}" matTooltipPosition="right" icon="circle" size="lg"></fa-icon>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="smsCampaignTimeLine.submittedByUsername">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Approved By </th>
|
||||
<td mat-cell *matCellDef="let smsCampaign"> {{ smsCampaign.smsCampaignTimeLine.submittedByUsername }} </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 { SmsCampaignsComponent } from './sms-campaigns.component';
|
||||
|
||||
describe('SmsCampaignsComponent', () => {
|
||||
let component: SmsCampaignsComponent;
|
||||
let fixture: ComponentFixture<SmsCampaignsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SmsCampaignsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SmsCampaignsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
/** 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';
|
||||
|
||||
/**
|
||||
* SMS Campaigns component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-sms-campaigns',
|
||||
templateUrl: './sms-campaigns.component.html',
|
||||
styleUrls: ['./sms-campaigns.component.scss']
|
||||
})
|
||||
export class SmsCampaignsComponent implements OnInit {
|
||||
|
||||
/** SMS Campaigns data. */
|
||||
smsCampaignsData: any;
|
||||
/** Columns to be displayed in sms campaigns table. */
|
||||
displayedColumns: string[] = ['campaignName', 'campaignMessage', 'campaignType.value', 'triggerType.value', 'campaignStatus.value', 'smsCampaignTimeLine.submittedByUsername'];
|
||||
/** Data source for SMS campaigns table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for SMS campaigns table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for SMS campaigns table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the SMS campaigns data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { smsCampaigns: any }) => {
|
||||
this.smsCampaignsData = data.smsCampaigns.pageItems;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in SMS campaigns table based on passed value.
|
||||
* @param {string} filterValue Value to filter data.
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SMS campaigns table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setSmsCampaigns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for SMS campaigns table.
|
||||
*/
|
||||
setSmsCampaigns() {
|
||||
this.dataSource = new MatTableDataSource(this.smsCampaignsData);
|
||||
this.dataSource.sortingDataAccessor = (item, property) => {
|
||||
switch (property) {
|
||||
case 'campaignType.value': return item.campaignType.value;
|
||||
case 'triggerType.value': return item.triggerType.value;
|
||||
case 'campaignStatus.value': return item.campaignStatus.value;
|
||||
case 'smsCampaignTimeLine.submittedByUsername': return item.smsCampaignTimeLine.submittedByUsername;
|
||||
default: return item[property];
|
||||
}
|
||||
};
|
||||
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 { OrganizationService } from '../organization.service';
|
||||
|
||||
/**
|
||||
* SMS Campaigns data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class SmsCampaignsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
constructor(private organizationService: OrganizationService) {}
|
||||
|
||||
/**
|
||||
* Returns the SMS Campaigns data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.organizationService.getSmsCampaigns();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user