|
@@ -5,6 +5,7 @@ import { ConfigService } from './config.service';
|
|
|
import { ResultPage } from './result-page';
|
|
import { ResultPage } from './result-page';
|
|
|
import { Track } from './tracks/track';
|
|
import { Track } from './tracks/track';
|
|
|
import { TrackSearchParams } from './tracks/track-search-params';
|
|
import { TrackSearchParams } from './tracks/track-search-params';
|
|
|
|
|
+import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
|
|
|
|
|
|
|
@Injectable({
|
|
@Injectable({
|
|
|
providedIn: 'root'
|
|
providedIn: 'root'
|
|
@@ -13,7 +14,8 @@ export class TracksApiService {
|
|
|
|
|
|
|
|
public constructor(
|
|
public constructor(
|
|
|
private readonly config: ConfigService,
|
|
private readonly config: ConfigService,
|
|
|
- private readonly http: HttpClient
|
|
|
|
|
|
|
+ private readonly http: HttpClient,
|
|
|
|
|
+ private readonly sanitizer: DomSanitizer
|
|
|
) { }
|
|
) { }
|
|
|
|
|
|
|
|
public getTracks(searchParams: TrackSearchParams): Promise<ResultPage<Track>> {
|
|
public getTracks(searchParams: TrackSearchParams): Promise<ResultPage<Track>> {
|
|
@@ -44,6 +46,14 @@ export class TracksApiService {
|
|
|
return this.config.apiUri(`/api/tracks/download/${track.fileHash}`);
|
|
return this.config.apiUri(`/api/tracks/download/${track.fileHash}`);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public getTrackGpxStudioEmbedUrl(track: Track): SafeResourceUrl | null {
|
|
|
|
|
+ // See https://gpx.studio/about.html#embed
|
|
|
|
|
+ const state = encodeURIComponent(JSON.stringify({
|
|
|
|
|
+ urls: [this.getTrackGpxUrl(track)]
|
|
|
|
|
+ }));
|
|
|
|
|
+ return this.sanitizer.bypassSecurityTrustResourceUrl(`https://gpx.studio/?state=${state}&embed&running&distance&direction`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public downloadTrack(track: Track): Promise<{ blob: Blob | null, filename?: string }> {
|
|
public downloadTrack(track: Track): Promise<{ blob: Blob | null, filename?: string }> {
|
|
|
return lastValueFrom(this.http.get(this.config.apiUri(`/api/tracks/download/${track.fileHash}`), {
|
|
return lastValueFrom(this.http.get(this.config.apiUri(`/api/tracks/download/${track.fileHash}`), {
|
|
|
responseType: 'blob',
|
|
responseType: 'blob',
|