@@ -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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adhoc Queries data resolver.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class AdhocQueriesResolver implements Resolve<Object> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OrganizationService} organizationService Organization service.
|
||||||
|
*/
|
||||||
|
constructor(private organizationService: OrganizationService) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the adhoc queries data.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(): Observable<any> {
|
||||||
|
return this.organizationService.getAdhocQueries();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<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 AdHoc Query
|
||||||
|
</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="name">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
|
||||||
|
<td mat-cell *matCellDef="let adhocquery"> {{ adhocquery.name }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="query">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> SQL Query </th>
|
||||||
|
<td mat-cell *matCellDef="let adhocquery"> {{ adhocquery.query }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="tableName">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Table Affected </th>
|
||||||
|
<td mat-cell *matCellDef="let adhocquery"> {{ adhocquery.tableName }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="email">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Email </th>
|
||||||
|
<td mat-cell *matCellDef="let adhocquery"> {{ adhocquery.email }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="reportRunFrequency">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Report Run Frequency </th>
|
||||||
|
<td mat-cell *matCellDef="let adhocquery"> {{ adhocquery.reportRunFrequency }} </td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="isActive">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
|
||||||
|
<td mat-cell *matCellDef="let adhocquery">
|
||||||
|
<div [className]="adhocquery.isActive === true ? 'true' : 'false'">
|
||||||
|
<fa-icon matTooltip="{{ adhocquery.isActive === true ? 'Active' : 'Inactive' }}" matTooltipPosition="right" icon="circle" size="lg"></fa-icon>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="createdBy">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Created By </th>
|
||||||
|
<td mat-cell *matCellDef="let adhocquery"> {{ adhocquery.createdBy }} </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,15 @@
|
|||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.select-row:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.true {
|
||||||
|
color: #32cd32;
|
||||||
|
}
|
||||||
|
|
||||||
|
.false {
|
||||||
|
color: #f44366;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { AdhocQueryComponent } from './adhoc-query.component';
|
||||||
|
|
||||||
|
describe('AdhocQueryComponent', () => {
|
||||||
|
let component: AdhocQueryComponent;
|
||||||
|
let fixture: ComponentFixture<AdhocQueryComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ AdhocQueryComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(AdhocQueryComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/** 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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adhoc Query component.
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-adhoc-query',
|
||||||
|
templateUrl: './adhoc-query.component.html',
|
||||||
|
styleUrls: ['./adhoc-query.component.scss']
|
||||||
|
})
|
||||||
|
export class AdhocQueryComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Adhoc Queries data. */
|
||||||
|
adhocQueriesData: any;
|
||||||
|
/** Columns to be displayed in adhoc queries table. */
|
||||||
|
displayedColumns: string[] = ['name', 'query', 'tableName', 'email', 'reportRunFrequency', 'isActive', 'createdBy'];
|
||||||
|
/** Data source for adhoc queries table. */
|
||||||
|
dataSource: MatTableDataSource<any>;
|
||||||
|
|
||||||
|
/** Paginator for adhoc queries table. */
|
||||||
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
/** Sorter for adhoc queries table. */
|
||||||
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the adhoc queries data from `resolve`.
|
||||||
|
* @param {ActivatedRoute} route Activated Route.
|
||||||
|
*/
|
||||||
|
constructor(private route: ActivatedRoute) {
|
||||||
|
this.route.data.subscribe(( data: { adhocQueries: any }) => {
|
||||||
|
this.adhocQueriesData = data.adhocQueries;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters data in adhoc queries table based on passed value.
|
||||||
|
* @param {string} filterValue Value to filter data.
|
||||||
|
*/
|
||||||
|
applyFilter(filterValue: string) {
|
||||||
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the adhoc queries table.
|
||||||
|
*/
|
||||||
|
ngOnInit() {
|
||||||
|
this.setAdhocQueries();
|
||||||
|
this.setReportRunFrequency();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets report run frequency to its corresponding values
|
||||||
|
*/
|
||||||
|
setReportRunFrequency() {
|
||||||
|
for (let i = 0; i < this.adhocQueriesData.length; i++) {
|
||||||
|
for (let j = 0; j < this.adhocQueriesData[i].reportRunFrequencies.length; j++) {
|
||||||
|
if (this.adhocQueriesData[i].reportRunFrequencies[j].id === this.adhocQueriesData[i].reportRunFrequency) {
|
||||||
|
this.adhocQueriesData[i].reportRunFrequency = this.adhocQueriesData[i].reportRunFrequencies[j].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the data source, paginator and sorter for adhoc queries table.
|
||||||
|
*/
|
||||||
|
setAdhocQueries() {
|
||||||
|
this.dataSource = new MatTableDataSource(this.adhocQueriesData);
|
||||||
|
this.dataSource.paginator = this.paginator;
|
||||||
|
this.dataSource.sort = this.sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import { OfficesComponent } from './offices/offices.component';
|
|||||||
import { EmployeesComponent } from './employees/employees.component';
|
import { EmployeesComponent } from './employees/employees.component';
|
||||||
import { CurrenciesComponent } from './currencies/currencies.component';
|
import { CurrenciesComponent } from './currencies/currencies.component';
|
||||||
import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
|
import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
|
||||||
|
import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component';
|
||||||
|
|
||||||
/** Custom Resolvers */
|
/** Custom Resolvers */
|
||||||
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
|
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
|
||||||
@@ -22,6 +23,7 @@ import { OfficesResolver } from './offices/offices.resolver';
|
|||||||
import { EmployeesResolver } from './employees/employees.resolver';
|
import { EmployeesResolver } from './employees/employees.resolver';
|
||||||
import { CurrenciesResolver } from './currencies/currencies.resolver';
|
import { CurrenciesResolver } from './currencies/currencies.resolver';
|
||||||
import { SmsCampaignsResolver } from './sms-campaigns/sms-campaigns.resolver';
|
import { SmsCampaignsResolver } from './sms-campaigns/sms-campaigns.resolver';
|
||||||
|
import { AdhocQueriesResolver } from './adhoc-query/adhoc-queries.resolver';
|
||||||
|
|
||||||
/** Organization Routes */
|
/** Organization Routes */
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
@@ -73,6 +75,19 @@ const routes: Routes = [
|
|||||||
resolve: {
|
resolve: {
|
||||||
smsCampaigns: SmsCampaignsResolver
|
smsCampaigns: SmsCampaignsResolver
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'adhoc-query',
|
||||||
|
data: { title: extract('Adhoc Query'), breadcrumb: 'Adhoc Query' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: AdhocQueryComponent,
|
||||||
|
resolve: {
|
||||||
|
adhocQueries: AdhocQueriesResolver
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -92,7 +107,8 @@ const routes: Routes = [
|
|||||||
OfficesResolver,
|
OfficesResolver,
|
||||||
EmployeesResolver,
|
EmployeesResolver,
|
||||||
CurrenciesResolver,
|
CurrenciesResolver,
|
||||||
SmsCampaignsResolver
|
SmsCampaignsResolver,
|
||||||
|
AdhocQueriesResolver
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OrganizationRoutingModule { }
|
export class OrganizationRoutingModule { }
|
||||||
|
|||||||
@@ -137,7 +137,7 @@
|
|||||||
<p matLine>Define SMS Campaigns for Organization</p>
|
<p matLine>Define SMS Campaigns for Organization</p>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
|
||||||
<mat-list-item>
|
<mat-list-item [routerLink]="['adhoc-query']">
|
||||||
<mat-icon matListIcon>
|
<mat-icon matListIcon>
|
||||||
<fa-icon icon="chevron-right" size="sm"></fa-icon>
|
<fa-icon icon="chevron-right" size="sm"></fa-icon>
|
||||||
</mat-icon>
|
</mat-icon>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { OfficesComponent } from './offices/offices.component';
|
|||||||
import { EmployeesComponent } from './employees/employees.component';
|
import { EmployeesComponent } from './employees/employees.component';
|
||||||
import { CurrenciesComponent } from './currencies/currencies.component';
|
import { CurrenciesComponent } from './currencies/currencies.component';
|
||||||
import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
|
import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
|
||||||
|
import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Organization Module
|
* Organization Module
|
||||||
@@ -31,7 +32,8 @@ import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
|
|||||||
OfficesComponent,
|
OfficesComponent,
|
||||||
EmployeesComponent,
|
EmployeesComponent,
|
||||||
CurrenciesComponent,
|
CurrenciesComponent,
|
||||||
SmsCampaignsComponent
|
SmsCampaignsComponent,
|
||||||
|
AdhocQueryComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OrganizationModule { }
|
export class OrganizationModule { }
|
||||||
|
|||||||
@@ -53,4 +53,11 @@ export class OrganizationService {
|
|||||||
return this.http.get('/smscampaigns');
|
return this.http.get('/smscampaigns');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Observable<any>} Adhoc Queries data
|
||||||
|
*/
|
||||||
|
getAdhocQueries(): Observable<any> {
|
||||||
|
return this.http.get('/adhocquery');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user