From 6803ad535ddf3a56fd52e57b4957732aa5160bb7 Mon Sep 17 00:00:00 2001 From: tito Date: Wed, 3 May 2023 12:02:45 +0200 Subject: [PATCH] detail data is no more hardcoded :) --- .../component/detail/detail.component.html | 8 ++-- src/app/component/detail/detail.component.ts | 39 +++---------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/src/app/component/detail/detail.component.html b/src/app/component/detail/detail.component.html index 8e66e4d..f6c0e69 100644 --- a/src/app/component/detail/detail.component.html +++ b/src/app/component/detail/detail.component.html @@ -1,10 +1,10 @@
-
+
-

{{ test.name }}

+

{{ waypointInfo?.locationName }}

@@ -23,11 +23,11 @@ {{distance === undefined ? '' : distance}} Km
-

{{ test.description }}

+

{{ waypointInfo.description }}

- diff --git a/src/app/component/detail/detail.component.ts b/src/app/component/detail/detail.component.ts index ee8d078..c0da104 100755 --- a/src/app/component/detail/detail.component.ts +++ b/src/app/component/detail/detail.component.ts @@ -23,6 +23,8 @@ export class DetailComponent implements OnInit { description: "Lorem ipsum" } + waypointInfo: any; + embed: any; cord: any; @@ -48,6 +50,8 @@ export class DetailComponent implements OnInit { this.waypointService.getWaypoint(this.URLParams.location, this.URLParams.id).subscribe(waypoint => { console.log("waypoint", waypoint) + this.waypointInfo = waypoint; + console.log("waypointInfo", this.waypointInfo.locationName) }); //this.URLParams = this.route.snapshot.url.slice(-2).map(segment => segment.path); @@ -61,7 +65,7 @@ export class DetailComponent implements OnInit { //set interval let intervalID = setInterval(() => { this.cord = this.positionService.getLocationWithoutPromise(); - this.embed = `https://www.google.com/maps/embed/v1/directions?key=AIzaSyBJL4FWmG032BG6KXxTb4faxpO_ccyaP3o&origin=${this.cord.lat},${this.cord.lon}&destination=${this.test.lat},${this.test.lng}`; + this.embed = `https://www.google.com/maps/embed/v1/directions?key=AIzaSyBJL4FWmG032BG6KXxTb4faxpO_ccyaP3o&origin=${this.cord.lat},${this.cord.lon}&destination=${this.waypointInfo.lat},${this.waypointInfo.lon}`; this.myModal.nativeElement.checked = false; if (this.cord?.lat && this.cord?.lon) { this.distance = this.positionService.getDistanceBetweenCoordinates(this.cord?.lat, this.cord?.lon, this.test.lat, this.test.lng); @@ -158,40 +162,9 @@ export class DetailComponent implements OnInit { public downloadImage(): void { const link = document.createElement('a'); - link.download = this.test.name; + link.download = this.waypointInfo.locationName; link.href = this.img; link.click(); } - - /*async addQRCodeToImage(url: string, imagePath: string, outputPath: string): Promise { - // Generate QR code - const qrCode = await qrcode.toBuffer(url); - - // Load input image using Sharp - const image = sharp(imagePath); - - // Get input image dimensions - const { width, height } = await image.metadata(); - - // Resize QR code to 25% of input image height - const qrCodeHeight = Math.round(height * 0.25); - const qrCodeBuffer = await sharp(qrCode) - .resize(qrCodeHeight, qrCodeHeight) - .toBuffer(); - - // Composite QR code onto input image at bottom-right corner - await image.composite([ - { - input: qrCodeBuffer, - gravity: 'southeast', - top: height - qrCodeHeight, - left: width - qrCodeHeight, - }, - ]); - - // Save output image to file - await image.toFile(outputPath); - }*/ - }