BP 735: added service and button to download help pdf
diff --git a/package-lock.json b/package-lock.json
index 329fd81..14a27e6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3616,6 +3616,11 @@
"schema-utils": "0.4.5"
}
},
+ "file-saver": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.0.tgz",
+ "integrity": "sha512-cYM1ic5DAkg25pHKgi5f10ziAM7RJU37gaH1XQlyNDrtUnzhC/dfoV9zf2OmF0RMKi42jG5B0JWBnPQqyj/G6g=="
+ },
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
diff --git a/package.json b/package.json
index d425597..fb5ebe9 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"bootstrap": "4.1.1",
"classlist.js": "1.1.20150312",
"core-js": "2.5.4",
+ "file-saver": "^2.0.0",
"font-awesome": "4.7.0",
"primeicons": "1.0.0-beta.9",
"primeng": "6.1.3",
diff --git a/src/app/core/components/navigation/navigation.component.html b/src/app/core/components/navigation/navigation.component.html
index e881d91..b7e8fc1 100644
--- a/src/app/core/components/navigation/navigation.component.html
+++ b/src/app/core/components/navigation/navigation.component.html
@@ -39,7 +39,7 @@
(click)="navbarCollapsed = true">Stammdatenverwaltung</a>
</li>
<li class="nav-item">
- <a class="nav-link" href="http://www.google.de" target="_blank" id="navHelp" (click)="navbarCollapsed = true">Hilfe</a>
+ <a class="nav-link" target="_blank" id="navHelp" (click)="navbarCollapsed = true;downloadPdf()">Hilfe</a>
</li>
<li class="nav-item dropdown mb-2 mb-lg-0" ngbDropdown>
<button class="btn btn-ok dropdown-toggle w-100" ngbDropdownToggle type="button" id="dropdownMenuButton">
diff --git a/src/app/core/components/navigation/navigation.component.ts b/src/app/core/components/navigation/navigation.component.ts
index 2d485cb..7dc864f 100644
--- a/src/app/core/components/navigation/navigation.component.ts
+++ b/src/app/core/components/navigation/navigation.component.ts
@@ -11,7 +11,10 @@
import { Router, NavigationCancel, NavigationEnd } from '@angular/router';
import { Subscription } from 'rxjs';
+import { saveAs } from 'file-saver';
+
import { AuthenticationService } from '@core/services/authentication.service';
+import { UtilService } from '@core/services/util.service';
@Component({
selector: 'ok-navigation',
@@ -24,7 +27,8 @@
constructor(
public authService: AuthenticationService,
- private router: Router
+ private router: Router,
+ private utilService: UtilService
) { }
ngOnInit() {
@@ -48,4 +52,11 @@
this.routerEvent$.unsubscribe();
}
}
+
+ downloadPdf() {
+ this.utilService.getDocuAsPdf('/documents/user/documentation').subscribe((pdf: any) => {
+ // const blob = new Blob([pdf], { type: 'application/octet-stream' });
+ saveAs(pdf, 'TechnischeDokumentation.pdf');
+ });
+ }
}
diff --git a/src/app/core/services/util.service.ts b/src/app/core/services/util.service.ts
index d911add..70bd8f6 100644
--- a/src/app/core/services/util.service.ts
+++ b/src/app/core/services/util.service.ts
@@ -8,11 +8,11 @@
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
import { environment } from '@env/environment';
import { Subject, BehaviorSubject } from 'rxjs';
import { ErrorObject } from '@shared/model/ErrorObject';
-import { MessageService } from 'primeng/components/common/messageservice';
@Injectable({
providedIn: 'root'
@@ -21,7 +21,9 @@
error$: Subject<ErrorObject> = new Subject();
loadingState$: BehaviorSubject<boolean> = new BehaviorSubject(false);
- constructor() { }
+ constructor(
+ private http: HttpClient
+ ) { }
readConfig(key: string) {
if (environment.hasOwnProperty(key)) {
@@ -35,4 +37,11 @@
throwError(errorObject: ErrorObject) {
this.error$.next(errorObject);
}
+
+ getDocuAsPdf(path: string) {
+ return this.http.get(
+ `${this.readConfig('basePath')}${path}`,
+ { responseType: 'blob' }
+ );
+ }
}