|
@@ -1,10 +1,33 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
|
|
-
|
|
|
|
|
-@Component({
|
|
|
|
|
- selector: 'app-track-view',
|
|
|
|
|
- templateUrl: './track-view.component.html',
|
|
|
|
|
- styleUrls: ['./track-view.component.scss']
|
|
|
|
|
-})
|
|
|
|
|
-export class TrackViewComponent {
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import { Component, Input } from '@angular/core';
|
|
|
|
|
+import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
|
|
|
|
+import { TracksApiService } from 'src/app/tracks-api.service';
|
|
|
|
|
+import { Track } from '../track';
|
|
|
|
|
+
|
|
|
|
|
+@Component({
|
|
|
|
|
+ selector: 'app-track-view',
|
|
|
|
|
+ templateUrl: './track-view.component.html',
|
|
|
|
|
+ styleUrls: ['./track-view.component.scss']
|
|
|
|
|
+})
|
|
|
|
|
+export class TrackViewComponent {
|
|
|
|
|
+ @Input()
|
|
|
|
|
+ public trackId: string = '';
|
|
|
|
|
+
|
|
|
|
|
+ public track: Track = {} as Track;
|
|
|
|
|
+ public gpxStudioEmbedUrl: SafeResourceUrl | null = null;
|
|
|
|
|
+
|
|
|
|
|
+ public constructor(
|
|
|
|
|
+ private readonly tracksApi: TracksApiService,
|
|
|
|
|
+ private readonly sanitizer: DomSanitizer
|
|
|
|
|
+ ) { }
|
|
|
|
|
+
|
|
|
|
|
+ public ngOnInit(): void {
|
|
|
|
|
+ this.tracksApi.getTrack(this.trackId).then(track => {
|
|
|
|
|
+ this.track = track;
|
|
|
|
|
+ // See https://gpx.studio/about.html#embed
|
|
|
|
|
+ const state = encodeURIComponent(JSON.stringify({
|
|
|
|
|
+ urls: [this.tracksApi.getTrackGpxUrl(this.track)]
|
|
|
|
|
+ }));
|
|
|
|
|
+ this.gpxStudioEmbedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`https://gpx.studio/?state=${state}&embed&running&distance&direction`);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+}
|