alimetry-report 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/esm2020/alimetry-report.mjs +5 -0
- package/esm2020/lib/report.component.mjs +108 -0
- package/esm2020/lib/report.module.mjs +24 -0
- package/esm2020/lib/report.service.mjs +14 -0
- package/esm2020/public-api.mjs +7 -0
- package/fesm2015/alimetry-report.mjs +152 -0
- package/fesm2015/alimetry-report.mjs.map +1 -0
- package/fesm2020/alimetry-report.mjs +151 -0
- package/fesm2020/alimetry-report.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/report.component.d.ts +23 -0
- package/lib/report.module.d.ts +8 -0
- package/lib/report.service.d.ts +6 -0
- package/package.json +31 -0
- package/public-api.d.ts +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './public-api';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWxpbWV0cnktcmVwb3J0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vcHJvamVjdHMvcmVwb3J0L3NyYy9hbGltZXRyeS1yZXBvcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcbiJdfQ==
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Component, Input, ViewChild } from '@angular/core';
|
|
2
|
+
import { map, of } from 'rxjs';
|
|
3
|
+
import { switchMap } from 'rxjs';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import * as i1 from "@angular/common/http";
|
|
6
|
+
import * as i2 from "shared";
|
|
7
|
+
import * as i3 from "@angular/common";
|
|
8
|
+
export class ReportComponent {
|
|
9
|
+
constructor(http, shared) {
|
|
10
|
+
this.http = http;
|
|
11
|
+
this.shared = shared;
|
|
12
|
+
this.status = 'loading';
|
|
13
|
+
}
|
|
14
|
+
getReportUrl() {
|
|
15
|
+
return this.shared.getDeviceData(this.config.deviceDataModelId, this.config.owners[0].userId, ['PdfReport']).pipe(map(res => res?.data?.['PdfReport']?.link || null));
|
|
16
|
+
}
|
|
17
|
+
getReportDataUrl(link) {
|
|
18
|
+
return this.http.get(link, { responseType: 'blob' }).pipe(map(res => {
|
|
19
|
+
const pdfBlob = new Blob([res], { type: 'application/pdf' });
|
|
20
|
+
return URL.createObjectURL(pdfBlob);
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ngAfterViewInit() {
|
|
24
|
+
if (this.status === 'nouser')
|
|
25
|
+
return;
|
|
26
|
+
this.subscription = this.getReportUrl().pipe(switchMap(link => link ? this.getReportDataUrl(link) : of(null))).subscribe({
|
|
27
|
+
next: (url) => {
|
|
28
|
+
this.status = url ? "success" : "empty";
|
|
29
|
+
this.renderFrame.nativeElement.src = url;
|
|
30
|
+
this.reportDataUrl = url;
|
|
31
|
+
},
|
|
32
|
+
error: (err) => {
|
|
33
|
+
if (err.error == "ItemNotFoundException: none-found") {
|
|
34
|
+
this.status = "empty";
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.error(err);
|
|
38
|
+
this.status = "error";
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
ngOnInit() {
|
|
44
|
+
if (!this.config?.owners?.[0]?.userId) {
|
|
45
|
+
this.status = 'nouser';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
ngOnDestroy() {
|
|
49
|
+
if (this.reportDataUrl)
|
|
50
|
+
URL.revokeObjectURL(this.reportDataUrl);
|
|
51
|
+
if (this.subscription)
|
|
52
|
+
this.subscription.unsubscribe();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
ReportComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportComponent, deps: [{ token: i1.HttpClient }, { token: i2.SharedService }], target: i0.ɵɵFactoryTarget.Component });
|
|
56
|
+
ReportComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ReportComponent, selector: "lib-report", inputs: { config: "config" }, viewQueries: [{ propertyName: "renderFrame", first: true, predicate: ["renderFrame"], descendants: true }], ngImport: i0, template: `
|
|
57
|
+
<div class="wrapper">
|
|
58
|
+
<div class="status" *ngIf="status === 'empty'">
|
|
59
|
+
This user doesn't have a report.
|
|
60
|
+
</div>
|
|
61
|
+
<div class="status" *ngIf="status === 'nouser'">
|
|
62
|
+
There is no user specified as the data owner.
|
|
63
|
+
</div>
|
|
64
|
+
<div class="status" *ngIf="status === 'loading'">
|
|
65
|
+
Loading report for user...
|
|
66
|
+
</div>
|
|
67
|
+
<div class="status" *ngIf="status === 'error'">
|
|
68
|
+
An error occured while trying to get the report.
|
|
69
|
+
</div>
|
|
70
|
+
<div
|
|
71
|
+
class="aspect-ratio-container"
|
|
72
|
+
[ngStyle]="{ 'display': status === 'success' ? 'block' : 'none' }"
|
|
73
|
+
>
|
|
74
|
+
<iframe #renderFrame title="PDF Report"></iframe>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`, isInline: true, styles: [".wrapper{width:100%;height:100%}.status{font-size:2rem;margin:5rem auto;text-align:center}.aspect-ratio-container{width:100%;position:relative;max-height:1000px;aspect-ratio:1 / 1}iframe{top:0;left:0;width:100%;height:100%;border:none;position:absolute}\n"], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
78
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportComponent, decorators: [{
|
|
79
|
+
type: Component,
|
|
80
|
+
args: [{ selector: 'lib-report', template: `
|
|
81
|
+
<div class="wrapper">
|
|
82
|
+
<div class="status" *ngIf="status === 'empty'">
|
|
83
|
+
This user doesn't have a report.
|
|
84
|
+
</div>
|
|
85
|
+
<div class="status" *ngIf="status === 'nouser'">
|
|
86
|
+
There is no user specified as the data owner.
|
|
87
|
+
</div>
|
|
88
|
+
<div class="status" *ngIf="status === 'loading'">
|
|
89
|
+
Loading report for user...
|
|
90
|
+
</div>
|
|
91
|
+
<div class="status" *ngIf="status === 'error'">
|
|
92
|
+
An error occured while trying to get the report.
|
|
93
|
+
</div>
|
|
94
|
+
<div
|
|
95
|
+
class="aspect-ratio-container"
|
|
96
|
+
[ngStyle]="{ 'display': status === 'success' ? 'block' : 'none' }"
|
|
97
|
+
>
|
|
98
|
+
<iframe #renderFrame title="PDF Report"></iframe>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
`, styles: [".wrapper{width:100%;height:100%}.status{font-size:2rem;margin:5rem auto;text-align:center}.aspect-ratio-container{width:100%;position:relative;max-height:1000px;aspect-ratio:1 / 1}iframe{top:0;left:0;width:100%;height:100%;border:none;position:absolute}\n"] }]
|
|
102
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.SharedService }]; }, propDecorators: { config: [{
|
|
103
|
+
type: Input
|
|
104
|
+
}], renderFrame: [{
|
|
105
|
+
type: ViewChild,
|
|
106
|
+
args: ['renderFrame', { static: false }]
|
|
107
|
+
}] } });
|
|
108
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVwb3J0LmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3Vy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IH0sXG4gICAgICBlcnJvcjogKGVycikgPT4ge1xuICAgICAgICBpZiAoZXJyLmVycm9yID09IFwiSXRlbU5vdEZvdW5kRXhjZXB0aW9uOiBub25lLWZvdW5kXCIpIHtcbiAgICAgICAgICB0aGlzLnN0YXR1cyA9IFwiZW1wdHlcIjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjb25zb2xlLmVycm9yKGVycik7XG4gICAgICAgICAgdGhpcy5zdGF0dXMgPSBcImVycm9yXCI7XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgfSk7XG4gIH1cblxuICBuZ09uSW5pdCgpIHtcbiAgICBpZiAoIXRoaXMuY29uZmlnPy5vd25lcnM/LlswXT8udXNlcklkKSB7XG4gICAgICB0aGlzLnN0YXR1cyA9ICdub3VzZXInO1xuICAgIH1cbiAgfVxuXG4gIG5nT25EZXN0cm95KCkge1xuICAgIGlmICh0aGlzLnJlcG9ydERhdGFVcmwpIFVSTC5yZXZva2VPYmplY3RVUkwodGhpcy5yZXBvcnREYXRhVXJsKTtcbiAgICBpZiAodGhpcy5zdWJzY3JpcHRpb24pIHRoaXMuc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gIH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { ReportComponent } from './report.component';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export class ReportModule {
|
|
6
|
+
}
|
|
7
|
+
ReportModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
8
|
+
ReportModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, declarations: [ReportComponent], imports: [CommonModule], exports: [ReportComponent] });
|
|
9
|
+
ReportModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, imports: [CommonModule] });
|
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, decorators: [{
|
|
11
|
+
type: NgModule,
|
|
12
|
+
args: [{
|
|
13
|
+
declarations: [
|
|
14
|
+
ReportComponent
|
|
15
|
+
],
|
|
16
|
+
imports: [
|
|
17
|
+
CommonModule
|
|
18
|
+
],
|
|
19
|
+
exports: [
|
|
20
|
+
ReportComponent
|
|
21
|
+
]
|
|
22
|
+
}]
|
|
23
|
+
}] });
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVwb3J0Lm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3JlcG9ydC9zcmMvbGliL3JlcG9ydC5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQy9DLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLG9CQUFvQixDQUFDOztBQWVyRCxNQUFNLE9BQU8sWUFBWTs7MEdBQVosWUFBWTsyR0FBWixZQUFZLGlCQVRyQixlQUFlLGFBR2YsWUFBWSxhQUdaLGVBQWU7MkdBR04sWUFBWSxZQU5yQixZQUFZOzRGQU1ILFlBQVk7a0JBWHhCLFFBQVE7bUJBQUM7b0JBQ1IsWUFBWSxFQUFFO3dCQUNaLGVBQWU7cUJBQ2hCO29CQUNELE9BQU8sRUFBRTt3QkFDUCxZQUFZO3FCQUNiO29CQUNELE9BQU8sRUFBRTt3QkFDUCxlQUFlO3FCQUNoQjtpQkFDRiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IENvbW1vbk1vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvbW1vbic7XG5pbXBvcnQgeyBOZ01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuaW1wb3J0IHsgUmVwb3J0Q29tcG9uZW50IH0gZnJvbSAnLi9yZXBvcnQuY29tcG9uZW50JztcblxuXG5cbkBOZ01vZHVsZSh7XG4gIGRlY2xhcmF0aW9uczogW1xuICAgIFJlcG9ydENvbXBvbmVudFxuICBdLFxuICBpbXBvcnRzOiBbXG4gICAgQ29tbW9uTW9kdWxlXG4gIF0sXG4gIGV4cG9ydHM6IFtcbiAgICBSZXBvcnRDb21wb25lbnRcbiAgXVxufSlcbmV4cG9ydCBjbGFzcyBSZXBvcnRNb2R1bGUgeyB9XG4iXX0=
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export class ReportService {
|
|
4
|
+
constructor() { }
|
|
5
|
+
}
|
|
6
|
+
ReportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
7
|
+
ReportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, providedIn: 'root' });
|
|
8
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, decorators: [{
|
|
9
|
+
type: Injectable,
|
|
10
|
+
args: [{
|
|
11
|
+
providedIn: 'root'
|
|
12
|
+
}]
|
|
13
|
+
}], ctorParameters: function () { return []; } });
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVwb3J0LnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9yZXBvcnQvc3JjL2xpYi9yZXBvcnQuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQUszQyxNQUFNLE9BQU8sYUFBYTtJQUV4QixnQkFBZ0IsQ0FBQzs7MkdBRk4sYUFBYTsrR0FBYixhQUFhLGNBRlosTUFBTTs0RkFFUCxhQUFhO2tCQUh6QixVQUFVO21CQUFDO29CQUNWLFVBQVUsRUFBRSxNQUFNO2lCQUNuQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEluamVjdGFibGUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuQEluamVjdGFibGUoe1xuICBwcm92aWRlZEluOiAncm9vdCdcbn0pXG5leHBvcnQgY2xhc3MgUmVwb3J0U2VydmljZSB7XG5cbiAgY29uc3RydWN0b3IoKSB7IH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of report
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/report.service';
|
|
5
|
+
export * from './lib/report.component';
|
|
6
|
+
export * from './lib/report.module';
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL3JlcG9ydC9zcmMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsc0JBQXNCLENBQUM7QUFDckMsY0FBYyx3QkFBd0IsQ0FBQztBQUN2QyxjQUFjLHFCQUFxQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLypcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiByZXBvcnRcbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2xpYi9yZXBvcnQuc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9yZXBvcnQuY29tcG9uZW50JztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3JlcG9ydC5tb2R1bGUnO1xuIl19
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Component, Input, ViewChild, NgModule } from '@angular/core';
|
|
3
|
+
import { map, switchMap, of } from 'rxjs';
|
|
4
|
+
import * as i1 from '@angular/common/http';
|
|
5
|
+
import * as i2 from 'shared';
|
|
6
|
+
import * as i3 from '@angular/common';
|
|
7
|
+
import { CommonModule } from '@angular/common';
|
|
8
|
+
|
|
9
|
+
class ReportService {
|
|
10
|
+
constructor() { }
|
|
11
|
+
}
|
|
12
|
+
ReportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
13
|
+
ReportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, providedIn: 'root' });
|
|
14
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, decorators: [{
|
|
15
|
+
type: Injectable,
|
|
16
|
+
args: [{
|
|
17
|
+
providedIn: 'root'
|
|
18
|
+
}]
|
|
19
|
+
}], ctorParameters: function () { return []; } });
|
|
20
|
+
|
|
21
|
+
class ReportComponent {
|
|
22
|
+
constructor(http, shared) {
|
|
23
|
+
this.http = http;
|
|
24
|
+
this.shared = shared;
|
|
25
|
+
this.status = 'loading';
|
|
26
|
+
}
|
|
27
|
+
getReportUrl() {
|
|
28
|
+
return this.shared.getDeviceData(this.config.deviceDataModelId, this.config.owners[0].userId, ['PdfReport']).pipe(map(res => { var _a, _b; return ((_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a['PdfReport']) === null || _b === void 0 ? void 0 : _b.link) || null; }));
|
|
29
|
+
}
|
|
30
|
+
getReportDataUrl(link) {
|
|
31
|
+
return this.http.get(link, { responseType: 'blob' }).pipe(map(res => {
|
|
32
|
+
const pdfBlob = new Blob([res], { type: 'application/pdf' });
|
|
33
|
+
return URL.createObjectURL(pdfBlob);
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
ngAfterViewInit() {
|
|
37
|
+
if (this.status === 'nouser')
|
|
38
|
+
return;
|
|
39
|
+
this.subscription = this.getReportUrl().pipe(switchMap(link => link ? this.getReportDataUrl(link) : of(null))).subscribe({
|
|
40
|
+
next: (url) => {
|
|
41
|
+
this.status = url ? "success" : "empty";
|
|
42
|
+
this.renderFrame.nativeElement.src = url;
|
|
43
|
+
this.reportDataUrl = url;
|
|
44
|
+
},
|
|
45
|
+
error: (err) => {
|
|
46
|
+
if (err.error == "ItemNotFoundException: none-found") {
|
|
47
|
+
this.status = "empty";
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.error(err);
|
|
51
|
+
this.status = "error";
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
ngOnInit() {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
if (!((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.owners) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.userId)) {
|
|
59
|
+
this.status = 'nouser';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
ngOnDestroy() {
|
|
63
|
+
if (this.reportDataUrl)
|
|
64
|
+
URL.revokeObjectURL(this.reportDataUrl);
|
|
65
|
+
if (this.subscription)
|
|
66
|
+
this.subscription.unsubscribe();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
ReportComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportComponent, deps: [{ token: i1.HttpClient }, { token: i2.SharedService }], target: i0.ɵɵFactoryTarget.Component });
|
|
70
|
+
ReportComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ReportComponent, selector: "lib-report", inputs: { config: "config" }, viewQueries: [{ propertyName: "renderFrame", first: true, predicate: ["renderFrame"], descendants: true }], ngImport: i0, template: `
|
|
71
|
+
<div class="wrapper">
|
|
72
|
+
<div class="status" *ngIf="status === 'empty'">
|
|
73
|
+
This user doesn't have a report.
|
|
74
|
+
</div>
|
|
75
|
+
<div class="status" *ngIf="status === 'nouser'">
|
|
76
|
+
There is no user specified as the data owner.
|
|
77
|
+
</div>
|
|
78
|
+
<div class="status" *ngIf="status === 'loading'">
|
|
79
|
+
Loading report for user...
|
|
80
|
+
</div>
|
|
81
|
+
<div class="status" *ngIf="status === 'error'">
|
|
82
|
+
An error occured while trying to get the report.
|
|
83
|
+
</div>
|
|
84
|
+
<div
|
|
85
|
+
class="aspect-ratio-container"
|
|
86
|
+
[ngStyle]="{ 'display': status === 'success' ? 'block' : 'none' }"
|
|
87
|
+
>
|
|
88
|
+
<iframe #renderFrame title="PDF Report"></iframe>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
`, isInline: true, styles: [".wrapper{width:100%;height:100%}.status{font-size:2rem;margin:5rem auto;text-align:center}.aspect-ratio-container{width:100%;position:relative;max-height:1000px;aspect-ratio:1 / 1}iframe{top:0;left:0;width:100%;height:100%;border:none;position:absolute}\n"], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
92
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportComponent, decorators: [{
|
|
93
|
+
type: Component,
|
|
94
|
+
args: [{ selector: 'lib-report', template: `
|
|
95
|
+
<div class="wrapper">
|
|
96
|
+
<div class="status" *ngIf="status === 'empty'">
|
|
97
|
+
This user doesn't have a report.
|
|
98
|
+
</div>
|
|
99
|
+
<div class="status" *ngIf="status === 'nouser'">
|
|
100
|
+
There is no user specified as the data owner.
|
|
101
|
+
</div>
|
|
102
|
+
<div class="status" *ngIf="status === 'loading'">
|
|
103
|
+
Loading report for user...
|
|
104
|
+
</div>
|
|
105
|
+
<div class="status" *ngIf="status === 'error'">
|
|
106
|
+
An error occured while trying to get the report.
|
|
107
|
+
</div>
|
|
108
|
+
<div
|
|
109
|
+
class="aspect-ratio-container"
|
|
110
|
+
[ngStyle]="{ 'display': status === 'success' ? 'block' : 'none' }"
|
|
111
|
+
>
|
|
112
|
+
<iframe #renderFrame title="PDF Report"></iframe>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
`, styles: [".wrapper{width:100%;height:100%}.status{font-size:2rem;margin:5rem auto;text-align:center}.aspect-ratio-container{width:100%;position:relative;max-height:1000px;aspect-ratio:1 / 1}iframe{top:0;left:0;width:100%;height:100%;border:none;position:absolute}\n"] }]
|
|
116
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.SharedService }]; }, propDecorators: { config: [{
|
|
117
|
+
type: Input
|
|
118
|
+
}], renderFrame: [{
|
|
119
|
+
type: ViewChild,
|
|
120
|
+
args: ['renderFrame', { static: false }]
|
|
121
|
+
}] } });
|
|
122
|
+
|
|
123
|
+
class ReportModule {
|
|
124
|
+
}
|
|
125
|
+
ReportModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
126
|
+
ReportModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, declarations: [ReportComponent], imports: [CommonModule], exports: [ReportComponent] });
|
|
127
|
+
ReportModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, imports: [CommonModule] });
|
|
128
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, decorators: [{
|
|
129
|
+
type: NgModule,
|
|
130
|
+
args: [{
|
|
131
|
+
declarations: [
|
|
132
|
+
ReportComponent
|
|
133
|
+
],
|
|
134
|
+
imports: [
|
|
135
|
+
CommonModule
|
|
136
|
+
],
|
|
137
|
+
exports: [
|
|
138
|
+
ReportComponent
|
|
139
|
+
]
|
|
140
|
+
}]
|
|
141
|
+
}] });
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
* Public API Surface of report
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Generated bundle index. Do not edit.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
export { ReportComponent, ReportModule, ReportService };
|
|
152
|
+
//# sourceMappingURL=alimetry-report.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alimetry-report.mjs","sources":["../../../projects/report/src/lib/report.service.ts","../../../projects/report/src/lib/report.component.ts","../../../projects/report/src/lib/report.module.ts","../../../projects/report/src/public-api.ts","../../../projects/report/src/alimetry-report.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ReportService {\n\n constructor() { }\n}\n","import { Component, ElementRef, Input, ViewChild } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { map, of, Subscription } from 'rxjs';\nimport { Observable } from 'rxjs';\nimport { switchMap } from 'rxjs';\nimport { OnDestroy } from '@angular/core';\nimport { Config, SharedService } from 'shared';\n\n@Component({\n selector: 'lib-report', template: `\n <div class=\"wrapper\">\n <div class=\"status\" *ngIf=\"status === 'empty'\">\n This user doesn't have a report.\n </div>\n <div class=\"status\" *ngIf=\"status === 'nouser'\">\n There is no user specified as the data owner.\n </div>\n <div class=\"status\" *ngIf=\"status === 'loading'\">\n Loading report for user...\n </div>\n <div class=\"status\" *ngIf=\"status === 'error'\">\n An error occured while trying to get the report.\n </div>\n <div\n class=\"aspect-ratio-container\"\n [ngStyle]=\"{ 'display': status === 'success' ? 'block' : 'none' }\"\n >\n <iframe #renderFrame title=\"PDF Report\"></iframe>\n </div>\n </div>\n `,\n styleUrls: [\n \"./report.component.css\"\n ]\n})\nexport class ReportComponent implements OnDestroy {\n @Input() config!: Config;\n\n @ViewChild('renderFrame', { static: false })\n renderFrame: ElementRef<HTMLIFrameElement> | undefined;\n\n reportDataUrl: string | undefined;\n subscription: Subscription;\n status: 'error' | 'loading' | 'success' | 'empty' | 'nouser' = 'loading';\n\n constructor(private http: HttpClient, private shared: SharedService) { }\n\n private getReportUrl(): Observable<string | null> {\n return this.shared.getDeviceData(\n this.config.deviceDataModelId,\n this.config.owners[0].userId,\n ['PdfReport']\n ).pipe(\n map(res => res?.data?.['PdfReport']?.link || null)\n );\n }\n\n private getReportDataUrl(link: string): Observable<string> {\n return this.http.get(link, { responseType: 'blob' }).pipe(\n map(res => {\n const pdfBlob = new Blob([res], { type: 'application/pdf' });\n return URL.createObjectURL(pdfBlob);\n })\n );\n }\n\n ngAfterViewInit() {\n if (this.status === 'nouser') return;\n\n this.subscription = this.getReportUrl().pipe(\n switchMap(link => link ? this.getReportDataUrl(link) : of(null)),\n ).subscribe({\n next: (url) => {\n this.status = url ? \"success\" : \"empty\";\n this.renderFrame!.nativeElement.src = url;\n this.reportDataUrl = url\n },\n error: (err) => {\n if (err.error == \"ItemNotFoundException: none-found\") {\n this.status = \"empty\";\n } else {\n console.error(err);\n this.status = \"error\";\n }\n },\n });\n }\n\n ngOnInit() {\n if (!this.config?.owners?.[0]?.userId) {\n this.status = 'nouser';\n }\n }\n\n ngOnDestroy() {\n if (this.reportDataUrl) URL.revokeObjectURL(this.reportDataUrl);\n if (this.subscription) this.subscription.unsubscribe();\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReportComponent } from './report.component';\n\n\n\n@NgModule({\n declarations: [\n ReportComponent\n ],\n imports: [\n CommonModule\n ],\n exports: [\n ReportComponent\n ]\n})\nexport class ReportModule { }\n","/*\n * Public API Surface of report\n */\n\nexport * from './lib/report.service';\nexport * from './lib/report.component';\nexport * from './lib/report.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAKa,aAAa,CAAA;AAExB,IAAA,WAAA,GAAA,GAAiB;;2GAFN,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAb,aAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cAFZ,MAAM,EAAA,CAAA,CAAA;4FAEP,aAAa,EAAA,UAAA,EAAA,CAAA;kBAHzB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;MC+BY,eAAe,CAAA;IAU1B,WAAoB,CAAA,IAAgB,EAAU,MAAqB,EAAA;AAA/C,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;AAAU,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AAFnE,QAAA,IAAM,CAAA,MAAA,GAAyD,SAAS,CAAC;KAED;IAEhE,YAAY,GAAA;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAC9B,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAC5B,CAAC,WAA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A;;0GAAZ,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAZ,YAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,EATrB,YAAA,EAAA,CAAA,eAAe,CAGf,EAAA,OAAA,EAAA,CAAA,YAAY,aAGZ,eAAe,CAAA,EAAA,CAAA,CAAA;AAGN,YAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YANrB,YAAY,CAAA,EAAA,CAAA,CAAA;4FAMH,YAAY,EAAA,UAAA,EAAA,CAAA;kBAXxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,eAAe;AAChB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,eAAe;AAChB,qBAAA;iBACF,CAAA;;;AChBD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Component, Input, ViewChild, NgModule } from '@angular/core';
|
|
3
|
+
import { map, switchMap, of } from 'rxjs';
|
|
4
|
+
import * as i1 from '@angular/common/http';
|
|
5
|
+
import * as i2 from 'shared';
|
|
6
|
+
import * as i3 from '@angular/common';
|
|
7
|
+
import { CommonModule } from '@angular/common';
|
|
8
|
+
|
|
9
|
+
class ReportService {
|
|
10
|
+
constructor() { }
|
|
11
|
+
}
|
|
12
|
+
ReportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
13
|
+
ReportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, providedIn: 'root' });
|
|
14
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportService, decorators: [{
|
|
15
|
+
type: Injectable,
|
|
16
|
+
args: [{
|
|
17
|
+
providedIn: 'root'
|
|
18
|
+
}]
|
|
19
|
+
}], ctorParameters: function () { return []; } });
|
|
20
|
+
|
|
21
|
+
class ReportComponent {
|
|
22
|
+
constructor(http, shared) {
|
|
23
|
+
this.http = http;
|
|
24
|
+
this.shared = shared;
|
|
25
|
+
this.status = 'loading';
|
|
26
|
+
}
|
|
27
|
+
getReportUrl() {
|
|
28
|
+
return this.shared.getDeviceData(this.config.deviceDataModelId, this.config.owners[0].userId, ['PdfReport']).pipe(map(res => res?.data?.['PdfReport']?.link || null));
|
|
29
|
+
}
|
|
30
|
+
getReportDataUrl(link) {
|
|
31
|
+
return this.http.get(link, { responseType: 'blob' }).pipe(map(res => {
|
|
32
|
+
const pdfBlob = new Blob([res], { type: 'application/pdf' });
|
|
33
|
+
return URL.createObjectURL(pdfBlob);
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
ngAfterViewInit() {
|
|
37
|
+
if (this.status === 'nouser')
|
|
38
|
+
return;
|
|
39
|
+
this.subscription = this.getReportUrl().pipe(switchMap(link => link ? this.getReportDataUrl(link) : of(null))).subscribe({
|
|
40
|
+
next: (url) => {
|
|
41
|
+
this.status = url ? "success" : "empty";
|
|
42
|
+
this.renderFrame.nativeElement.src = url;
|
|
43
|
+
this.reportDataUrl = url;
|
|
44
|
+
},
|
|
45
|
+
error: (err) => {
|
|
46
|
+
if (err.error == "ItemNotFoundException: none-found") {
|
|
47
|
+
this.status = "empty";
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.error(err);
|
|
51
|
+
this.status = "error";
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
ngOnInit() {
|
|
57
|
+
if (!this.config?.owners?.[0]?.userId) {
|
|
58
|
+
this.status = 'nouser';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
ngOnDestroy() {
|
|
62
|
+
if (this.reportDataUrl)
|
|
63
|
+
URL.revokeObjectURL(this.reportDataUrl);
|
|
64
|
+
if (this.subscription)
|
|
65
|
+
this.subscription.unsubscribe();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
ReportComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportComponent, deps: [{ token: i1.HttpClient }, { token: i2.SharedService }], target: i0.ɵɵFactoryTarget.Component });
|
|
69
|
+
ReportComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ReportComponent, selector: "lib-report", inputs: { config: "config" }, viewQueries: [{ propertyName: "renderFrame", first: true, predicate: ["renderFrame"], descendants: true }], ngImport: i0, template: `
|
|
70
|
+
<div class="wrapper">
|
|
71
|
+
<div class="status" *ngIf="status === 'empty'">
|
|
72
|
+
This user doesn't have a report.
|
|
73
|
+
</div>
|
|
74
|
+
<div class="status" *ngIf="status === 'nouser'">
|
|
75
|
+
There is no user specified as the data owner.
|
|
76
|
+
</div>
|
|
77
|
+
<div class="status" *ngIf="status === 'loading'">
|
|
78
|
+
Loading report for user...
|
|
79
|
+
</div>
|
|
80
|
+
<div class="status" *ngIf="status === 'error'">
|
|
81
|
+
An error occured while trying to get the report.
|
|
82
|
+
</div>
|
|
83
|
+
<div
|
|
84
|
+
class="aspect-ratio-container"
|
|
85
|
+
[ngStyle]="{ 'display': status === 'success' ? 'block' : 'none' }"
|
|
86
|
+
>
|
|
87
|
+
<iframe #renderFrame title="PDF Report"></iframe>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
`, isInline: true, styles: [".wrapper{width:100%;height:100%}.status{font-size:2rem;margin:5rem auto;text-align:center}.aspect-ratio-container{width:100%;position:relative;max-height:1000px;aspect-ratio:1 / 1}iframe{top:0;left:0;width:100%;height:100%;border:none;position:absolute}\n"], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
91
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportComponent, decorators: [{
|
|
92
|
+
type: Component,
|
|
93
|
+
args: [{ selector: 'lib-report', template: `
|
|
94
|
+
<div class="wrapper">
|
|
95
|
+
<div class="status" *ngIf="status === 'empty'">
|
|
96
|
+
This user doesn't have a report.
|
|
97
|
+
</div>
|
|
98
|
+
<div class="status" *ngIf="status === 'nouser'">
|
|
99
|
+
There is no user specified as the data owner.
|
|
100
|
+
</div>
|
|
101
|
+
<div class="status" *ngIf="status === 'loading'">
|
|
102
|
+
Loading report for user...
|
|
103
|
+
</div>
|
|
104
|
+
<div class="status" *ngIf="status === 'error'">
|
|
105
|
+
An error occured while trying to get the report.
|
|
106
|
+
</div>
|
|
107
|
+
<div
|
|
108
|
+
class="aspect-ratio-container"
|
|
109
|
+
[ngStyle]="{ 'display': status === 'success' ? 'block' : 'none' }"
|
|
110
|
+
>
|
|
111
|
+
<iframe #renderFrame title="PDF Report"></iframe>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
`, styles: [".wrapper{width:100%;height:100%}.status{font-size:2rem;margin:5rem auto;text-align:center}.aspect-ratio-container{width:100%;position:relative;max-height:1000px;aspect-ratio:1 / 1}iframe{top:0;left:0;width:100%;height:100%;border:none;position:absolute}\n"] }]
|
|
115
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.SharedService }]; }, propDecorators: { config: [{
|
|
116
|
+
type: Input
|
|
117
|
+
}], renderFrame: [{
|
|
118
|
+
type: ViewChild,
|
|
119
|
+
args: ['renderFrame', { static: false }]
|
|
120
|
+
}] } });
|
|
121
|
+
|
|
122
|
+
class ReportModule {
|
|
123
|
+
}
|
|
124
|
+
ReportModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
125
|
+
ReportModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, declarations: [ReportComponent], imports: [CommonModule], exports: [ReportComponent] });
|
|
126
|
+
ReportModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, imports: [CommonModule] });
|
|
127
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ReportModule, decorators: [{
|
|
128
|
+
type: NgModule,
|
|
129
|
+
args: [{
|
|
130
|
+
declarations: [
|
|
131
|
+
ReportComponent
|
|
132
|
+
],
|
|
133
|
+
imports: [
|
|
134
|
+
CommonModule
|
|
135
|
+
],
|
|
136
|
+
exports: [
|
|
137
|
+
ReportComponent
|
|
138
|
+
]
|
|
139
|
+
}]
|
|
140
|
+
}] });
|
|
141
|
+
|
|
142
|
+
/*
|
|
143
|
+
* Public API Surface of report
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Generated bundle index. Do not edit.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
export { ReportComponent, ReportModule, ReportService };
|
|
151
|
+
//# sourceMappingURL=alimetry-report.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alimetry-report.mjs","sources":["../../../projects/report/src/lib/report.service.ts","../../../projects/report/src/lib/report.component.ts","../../../projects/report/src/lib/report.module.ts","../../../projects/report/src/public-api.ts","../../../projects/report/src/alimetry-report.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ReportService {\n\n constructor() { }\n}\n","import { Component, ElementRef, Input, ViewChild } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { map, of, Subscription } from 'rxjs';\nimport { Observable } from 'rxjs';\nimport { switchMap } from 'rxjs';\nimport { OnDestroy } from '@angular/core';\nimport { Config, SharedService } from 'shared';\n\n@Component({\n selector: 'lib-report', template: `\n <div class=\"wrapper\">\n <div class=\"status\" *ngIf=\"status === 'empty'\">\n This user doesn't have a report.\n </div>\n <div class=\"status\" *ngIf=\"status === 'nouser'\">\n There is no user specified as the data owner.\n </div>\n <div class=\"status\" *ngIf=\"status === 'loading'\">\n Loading report for user...\n </div>\n <div class=\"status\" *ngIf=\"status === 'error'\">\n An error occured while trying to get the report.\n </div>\n <div\n class=\"aspect-ratio-container\"\n [ngStyle]=\"{ 'display': status === 'success' ? 'block' : 'none' }\"\n >\n <iframe #renderFrame title=\"PDF Report\"></iframe>\n </div>\n </div>\n `,\n styleUrls: [\n \"./report.component.css\"\n ]\n})\nexport class ReportComponent implements OnDestroy {\n @Input() config!: Config;\n\n @ViewChild('renderFrame', { static: false })\n renderFrame: ElementRef<HTMLIFrameElement> | undefined;\n\n reportDataUrl: string | undefined;\n subscription: Subscription;\n status: 'error' | 'loading' | 'success' | 'empty' | 'nouser' = 'loading';\n\n constructor(private http: HttpClient, private shared: SharedService) { }\n\n private getReportUrl(): Observable<string | null> {\n return this.shared.getDeviceData(\n this.config.deviceDataModelId,\n this.config.owners[0].userId,\n ['PdfReport']\n ).pipe(\n map(res => res?.data?.['PdfReport']?.link || null)\n );\n }\n\n private getReportDataUrl(link: string): Observable<string> {\n return this.http.get(link, { responseType: 'blob' }).pipe(\n map(res => {\n const pdfBlob = new Blob([res], { type: 'application/pdf' });\n return URL.createObjectURL(pdfBlob);\n })\n );\n }\n\n ngAfterViewInit() {\n if (this.status === 'nouser') return;\n\n this.subscription = this.getReportUrl().pipe(\n switchMap(link => link ? this.getReportDataUrl(link) : of(null)),\n ).subscribe({\n next: (url) => {\n this.status = url ? \"success\" : \"empty\";\n this.renderFrame!.nativeElement.src = url;\n this.reportDataUrl = url\n },\n error: (err) => {\n if (err.error == \"ItemNotFoundException: none-found\") {\n this.status = \"empty\";\n } else {\n console.error(err);\n this.status = \"error\";\n }\n },\n });\n }\n\n ngOnInit() {\n if (!this.config?.owners?.[0]?.userId) {\n this.status = 'nouser';\n }\n }\n\n ngOnDestroy() {\n if (this.reportDataUrl) URL.revokeObjectURL(this.reportDataUrl);\n if (this.subscription) this.subscription.unsubscribe();\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ReportComponent } from './report.component';\n\n\n\n@NgModule({\n declarations: [\n ReportComponent\n ],\n imports: [\n CommonModule\n ],\n exports: [\n ReportComponent\n ]\n})\nexport class ReportModule { }\n","/*\n * Public API Surface of report\n */\n\nexport * from './lib/report.service';\nexport * from './lib/report.component';\nexport * from './lib/report.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAKa,aAAa,CAAA;AAExB,IAAA,WAAA,GAAA,GAAiB;;2GAFN,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAb,aAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cAFZ,MAAM,EAAA,CAAA,CAAA;4FAEP,aAAa,EAAA,UAAA,EAAA,CAAA;kBAHzB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA,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AA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,EATrB,YAAA,EAAA,CAAA,eAAe,CAGf,EAAA,OAAA,EAAA,CAAA,YAAY,aAGZ,eAAe,CAAA,EAAA,CAAA,CAAA;AAGN,YAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YANrB,YAAY,CAAA,EAAA,CAAA,CAAA;4FAMH,YAAY,EAAA,UAAA,EAAA,CAAA;kBAXxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,eAAe;AAChB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,eAAe;AAChB,qBAAA;AACF,iBAAA,CAAA;;;AChBD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ElementRef } from '@angular/core';
|
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
|
3
|
+
import { Subscription } from 'rxjs';
|
|
4
|
+
import { OnDestroy } from '@angular/core';
|
|
5
|
+
import { Config, SharedService } from 'shared';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export declare class ReportComponent implements OnDestroy {
|
|
8
|
+
private http;
|
|
9
|
+
private shared;
|
|
10
|
+
config: Config;
|
|
11
|
+
renderFrame: ElementRef<HTMLIFrameElement> | undefined;
|
|
12
|
+
reportDataUrl: string | undefined;
|
|
13
|
+
subscription: Subscription;
|
|
14
|
+
status: 'error' | 'loading' | 'success' | 'empty' | 'nouser';
|
|
15
|
+
constructor(http: HttpClient, shared: SharedService);
|
|
16
|
+
private getReportUrl;
|
|
17
|
+
private getReportDataUrl;
|
|
18
|
+
ngAfterViewInit(): void;
|
|
19
|
+
ngOnInit(): void;
|
|
20
|
+
ngOnDestroy(): void;
|
|
21
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ReportComponent, never>;
|
|
22
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ReportComponent, "lib-report", never, { "config": "config"; }, {}, never, never, false, never>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./report.component";
|
|
3
|
+
import * as i2 from "@angular/common";
|
|
4
|
+
export declare class ReportModule {
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ReportModule, never>;
|
|
6
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ReportModule, [typeof i1.ReportComponent], [typeof i2.CommonModule], [typeof i1.ReportComponent]>;
|
|
7
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ReportModule>;
|
|
8
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "alimetry-report",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^15.2.0",
|
|
6
|
+
"@angular/core": "^15.2.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2015/alimetry-report.mjs",
|
|
13
|
+
"es2020": "fesm2020/alimetry-report.mjs",
|
|
14
|
+
"esm2020": "esm2020/alimetry-report.mjs",
|
|
15
|
+
"fesm2020": "fesm2020/alimetry-report.mjs",
|
|
16
|
+
"fesm2015": "fesm2015/alimetry-report.mjs",
|
|
17
|
+
"typings": "index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": {
|
|
20
|
+
"default": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./index.d.ts",
|
|
24
|
+
"esm2020": "./esm2020/alimetry-report.mjs",
|
|
25
|
+
"es2020": "./fesm2020/alimetry-report.mjs",
|
|
26
|
+
"es2015": "./fesm2015/alimetry-report.mjs",
|
|
27
|
+
"node": "./fesm2015/alimetry-report.mjs",
|
|
28
|
+
"default": "./fesm2020/alimetry-report.mjs"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/public-api.d.ts
ADDED