|
|
@@ -1,4 +1,4 @@
|
|
|
-import { Component, Input } from '@angular/core';
|
|
|
+import { Component, Input, OnInit } from '@angular/core';
|
|
|
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
|
|
import { TracksApiService } from 'src/app/tracks-api.service';
|
|
|
import { Track } from '../track';
|
|
|
@@ -8,24 +8,27 @@ import { Track } from '../track';
|
|
|
templateUrl: './track-list-item.component.html',
|
|
|
styleUrls: ['./track-list-item.component.scss']
|
|
|
})
|
|
|
-export class TrackListItemComponent {
|
|
|
+export class TrackListItemComponent implements OnInit {
|
|
|
@Input()
|
|
|
public track?: Track;
|
|
|
|
|
|
public downloadUrl: SafeUrl | null = null;
|
|
|
- public downloadFileName?: string;
|
|
|
|
|
|
public constructor(
|
|
|
private readonly tracksApi: TracksApiService,
|
|
|
private readonly sanitizer: DomSanitizer
|
|
|
) { }
|
|
|
|
|
|
- public downloadGpx(): void {
|
|
|
- this.tracksApi.downloadTrack(this.track!).then(file => {
|
|
|
- if (file.blob) {
|
|
|
- this.downloadUrl = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file.blob));
|
|
|
- this.downloadFileName = file.filename
|
|
|
- }
|
|
|
- });
|
|
|
+ public ngOnInit(): void {
|
|
|
+ this.downloadUrl = this.tracksApi.getTrackGpxUrl(this.track!);
|
|
|
}
|
|
|
+
|
|
|
+ // public downloadGpx(): void {
|
|
|
+ // this.tracksApi.downloadTrack(this.track!).then(file => {
|
|
|
+ // if (file.blob) {
|
|
|
+ // this.downloadUrl = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file.blob));
|
|
|
+ // this.downloadFileName = file.filename
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
}
|