@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user