diff --git a/src/app/main/main-center/main-center.component.html b/src/app/main/main-center/main-center.component.html index 35923f7..1a12322 100644 --- a/src/app/main/main-center/main-center.component.html +++ b/src/app/main/main-center/main-center.component.html @@ -1,8 +1,17 @@ + -

Current node is {{this.currentNode.label}}

- +
+

{{this.currentNode.label}}

+ + + +
-

No node selected

-
\ No newline at end of file +

No node selected

+ + + +

PDF not found

+
diff --git a/src/app/main/main-center/main-center.component.ts b/src/app/main/main-center/main-center.component.ts index 337a70b..a60a11b 100644 --- a/src/app/main/main-center/main-center.component.ts +++ b/src/app/main/main-center/main-center.component.ts @@ -4,6 +4,7 @@ import { Subscription } from 'rxjs'; import { TreeNode } from 'primeng/api'; import { ResourceService } from 'src/app/services/api/resource.service'; import { HttpErrorResponse } from '@angular/common/http'; +import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; @Component({ selector: 'app-main-center', @@ -14,10 +15,13 @@ export class MainCenterComponent implements OnInit, OnDestroy { private treeSubscription: Subscription; currentNode: TreeNode; + blobUrl: SafeResourceUrl; + notFound = false; constructor( private treeService: TreeService, - private resourceService: ResourceService + private resourceService: ResourceService, + private domSanitizer: DomSanitizer ) { } ngOnInit() { @@ -25,21 +29,20 @@ export class MainCenterComponent implements OnInit, OnDestroy { if (node == null) { return; } + this.notFound = false; console.log('Selected node is', node); this.currentNode = node; const data = node.data as { pdfName: string }; try { - console.log('I will load', data.pdfName); - const pdfData = await this.resourceService.getResourcePDF(data.pdfName); - // render pdf to screen - + const pdfData = await this.resourceService.getResourcePDF(data.pdfName).toPromise(); + this.blobUrl = this.domSanitizer.bypassSecurityTrustResourceUrl( + URL.createObjectURL(new Blob([pdfData], { type: 'application/pdf' }))); } catch (err) { console.log(err); if ((err as HttpErrorResponse).status === 404) { - // handle not found + this.notFound = true; } } - }); } diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html index 89b5a69..425ed99 100644 --- a/src/app/main/main.component.html +++ b/src/app/main/main.component.html @@ -1,2 +1,4 @@ - - \ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/src/app/main/tree/tree.component.css b/src/app/main/tree/tree.component.css index e69de29..9ea0083 100644 --- a/src/app/main/tree/tree.component.css +++ b/src/app/main/tree/tree.component.css @@ -0,0 +1,5 @@ +.tree { + height: 100%; + display: flex; + justify-content: space-between; +} \ No newline at end of file diff --git a/src/app/main/tree/tree.component.html b/src/app/main/tree/tree.component.html index 19c0f99..1246370 100644 --- a/src/app/main/tree/tree.component.html +++ b/src/app/main/tree/tree.component.html @@ -1 +1,7 @@ - \ No newline at end of file + + +
+
{{ node.label }}
+
+
+
\ No newline at end of file diff --git a/src/assets/files.json b/src/assets/files.json index dfaed6c..d77a9ba 100644 --- a/src/assets/files.json +++ b/src/assets/files.json @@ -12,7 +12,7 @@ { "label": "32-11 Main Landing Gear", "data": { - "pdfName": "radar.pdf" + "pdfName": "radar2.pdf" }, "expandedIcon": "fa fa-folder-open", "collapsedIcon": "fa fa-folder", diff --git a/src/styles.css b/src/styles.css index 90d4ee0..0d458dd 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1 +1,11 @@ /* You can add global styles to this file, and also import other style files */ +html, body, app-root { + height: 100%; + width: 100%; + margin: 0; +} + +app-tree .ui-tree { + height: 100%; + width: 100%; +} \ No newline at end of file