@@ -0,0 +1 @@
|
||||
<iframe *ngIf = "!hideOutput" [src]="pentahoUrl" frameborder="0" width=100% height="750px;"></iframe>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PentahoComponent } from './pentaho.component';
|
||||
|
||||
describe('PentahoComponent', () => {
|
||||
let component: PentahoComponent;
|
||||
let fixture: ComponentFixture<PentahoComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PentahoComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PentahoComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnChanges, Input } from '@angular/core';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
|
||||
/** Custom Services */
|
||||
import { ReportsService } from '../../reports.service';
|
||||
|
||||
/**
|
||||
* Pentaho Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-pentaho',
|
||||
templateUrl: './pentaho.component.html',
|
||||
styleUrls: ['./pentaho.component.scss']
|
||||
})
|
||||
export class PentahoComponent implements OnChanges {
|
||||
|
||||
/** Run Report Data */
|
||||
@Input() dataObject: any;
|
||||
|
||||
/** substitute for resolver */
|
||||
hideOutput = true;
|
||||
/** trusted resource url for pentaho output */
|
||||
pentahoUrl: any;
|
||||
|
||||
/**
|
||||
* @param {DomSanitizer} sanitizer DOM Sanitizer
|
||||
* @param {ReportsService} reportsService Reports Service
|
||||
*/
|
||||
constructor(private sanitizer: DomSanitizer,
|
||||
private reportsService: ReportsService) { }
|
||||
|
||||
/**
|
||||
* Fetches run report data post changes in run report form.
|
||||
*/
|
||||
ngOnChanges() {
|
||||
this.hideOutput = true;
|
||||
this.getRunReportData();
|
||||
}
|
||||
|
||||
getRunReportData() {
|
||||
this.reportsService.getPentahoRunReportData(this.dataObject.reportData, this.dataObject.formData, 'default', 'en', 'dd MMMM yyyy')
|
||||
.subscribe( (res: any) => {
|
||||
const contentType = res.headers.get('Content-Type');
|
||||
const file = new Blob([res.body], {type: contentType});
|
||||
const filecontent = URL.createObjectURL(file);
|
||||
this.pentahoUrl = this.sanitizer.bypassSecurityTrustResourceUrl(filecontent);
|
||||
this.hideOutput = false;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user