|
|
@@ -1,11 +1,33 @@
|
|
|
-import { Component, Input } from '@angular/core';
|
|
|
+import { Component, Input, OnInit } from '@angular/core';
|
|
|
+import { Router } from '@angular/router';
|
|
|
+import { TracksApiService } from 'src/app/tracks-api.service';
|
|
|
+import { Track } from '../track';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-track-edit',
|
|
|
templateUrl: './track-edit.component.html',
|
|
|
styleUrls: ['./track-edit.component.scss']
|
|
|
})
|
|
|
-export class TrackEditComponent {
|
|
|
+export class TrackEditComponent implements OnInit {
|
|
|
@Input()
|
|
|
public trackId: string = '';
|
|
|
+
|
|
|
+ public track: Track = {} as Track;
|
|
|
+
|
|
|
+ public constructor(
|
|
|
+ private readonly tracksApi: TracksApiService,
|
|
|
+ private readonly router: Router
|
|
|
+ ) { }
|
|
|
+
|
|
|
+ public ngOnInit(): void {
|
|
|
+ this.tracksApi.getTrack(this.trackId).then(track => {
|
|
|
+ this.track = track;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public updateTrack(event: SubmitEvent): void {
|
|
|
+ this.tracksApi.updateTrack(this.track).then(result => {
|
|
|
+ this.track = result;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|