diff --git a/src/app/classes/entities.ts b/src/app/classes/entities.ts
index 48deefb..3b0d2a9 100644
--- a/src/app/classes/entities.ts
+++ b/src/app/classes/entities.ts
@@ -65,8 +65,9 @@ export class Album {
// The following list are identical to the items returned from the api.
id: number;
name: string;
- artist: number;
+ artist: number[];
image: string;
+ song: number[];
type = 'Album';
data: DataService;
@@ -76,10 +77,7 @@ export class Album {
this.name = data.data.result[0].name;
this.artist = data.data.result[0].artist;
this.image = data.data.result[0].image;
- }
-
- async getArtist() {
- return new Artist(await this.data.getArtist(this.artist));
+ this.song = data.data.result[0].song;
}
// There will be more functions here...
diff --git a/src/app/components/albums/albums.component.html b/src/app/components/albums/albums.component.html
index 667310d..c878568 100644
--- a/src/app/components/albums/albums.component.html
+++ b/src/app/components/albums/albums.component.html
@@ -1 +1,40 @@
-
albums works!
+
+
+
+
+
+
+
+
+
+
+
{{ albumData.name }}'s data
+
+
+
+
+
+
+
Artists of {{ albumData.name }}
+
+
+
+
+
{{ albumData.name }}'s songs
+
+
+
+
+
+
+
+
+
diff --git a/src/app/components/albums/albums.component.scss b/src/app/components/albums/albums.component.scss
index e69de29..c2a1f59 100644
--- a/src/app/components/albums/albums.component.scss
+++ b/src/app/components/albums/albums.component.scss
@@ -0,0 +1,4 @@
+div.content {
+ display: grid;
+ grid-template-columns: auto auto;
+}
diff --git a/src/app/components/albums/albums.component.ts b/src/app/components/albums/albums.component.ts
index 843b3df..307619c 100644
--- a/src/app/components/albums/albums.component.ts
+++ b/src/app/components/albums/albums.component.ts
@@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
+import { ApiService } from 'src/app/services/api.service';
+import { Artist, Song, Album } from '../../classes/entities';
@Component({
selector: 'app-albums',
@@ -7,9 +10,41 @@ import { Component, OnInit } from '@angular/core';
})
export class AlbumsComponent implements OnInit {
- constructor() { }
+ albumData: Album;
+ albums: Promise>;
+ songs: Array;
+ artists: Array;
+
+ constructor(
+ private api: ApiService,
+ private route: ActivatedRoute
+ ) { }
ngOnInit() {
+
+ this.route.paramMap.subscribe(params => {
+
+ // If the id argument is given...
+ if (params.has('id')) {
+
+ // ... then get artist data ...
+ this.api.getAlbum(Number(params.get('id'))).then(async res => {
+ this.albumData = res;
+ const songs = await this.api.getSong(res.song.join());
+ this.songs = songs.length ? songs : [songs];
+ const artists = await this.api.getArtist(res.artist.join());
+ this.artists = artists.length ? artists : [artists];
+ });
+
+ } else {
+
+ // Otherwise, get all artists and list them out.
+ this.albums = this.api.getAllAlbums();
+
+ }
+
+ });
+
}
}