diff --git a/dashboard/src/app/dashboard.component.html b/dashboard/src/app/dashboard.component.html
index 4ec9fb9..22ade66 100644
--- a/dashboard/src/app/dashboard.component.html
+++ b/dashboard/src/app/dashboard.component.html
@@ -120,6 +120,31 @@
+
+
Top Played Album
+
+
+
+ | Album |
+ Artist Name |
+ Track Count |
+ Play Count |
+ Average Play |
+
+
+
+
+ | {{album.Name}} |
+ {{album['Album Artist'] ? album['Album Artist'] : album.Artist}} |
+ {{album['Track Count']}} |
+ {{album['Play Count']}} |
+ {{album['Play Count'] / album['Track Count']}} |
+
+
+
+
+
+
Top Genres
diff --git a/dashboard/src/app/dashboard.component.ts b/dashboard/src/app/dashboard.component.ts
index 1faa577..76dfcdf 100644
--- a/dashboard/src/app/dashboard.component.ts
+++ b/dashboard/src/app/dashboard.component.ts
@@ -27,6 +27,8 @@ export class DashboardComponent implements OnInit {
mostPlayedSongs: Song[] = [];
+ mostPlayedAlbums: Album[] = [];
+
lastAddedAlbums: Bucket[] = [];
albumArtists = [];
@@ -53,6 +55,16 @@ export class DashboardComponent implements OnInit {
data => this.mostPlayedSongs = data
);
+ this.elsService.getMostPlayedAlbum()
+ .then(result => {
+ result.forEach(album => {
+ if (album.Artist.length <= 10) {
+ this.mostPlayedAlbums.push(album);
+ }
+ });
+
+ });
+
this.elsService.getGenres().subscribe(data => this.topGenres = data);
this.elsService.getGenres('asc').subscribe(data => this.bottomGenres = data);
// this.elsService.getGenreCount().subscribe(data => console.log(data));
diff --git a/dashboard/src/app/els.service.ts b/dashboard/src/app/els.service.ts
index 46a3df6..b366f99 100644
--- a/dashboard/src/app/els.service.ts
+++ b/dashboard/src/app/els.service.ts
@@ -114,6 +114,15 @@ export class ElsService {
.map(res => this.responseToSongs(res));
}
+ getMostPlayedAlbum(): Promise {
+ return this.http
+ .get(this.elsUrl + 'album' + ElsService.ACTION_SEARCH + '?sort=Play Count:desc&size=20')
+ .toPromise()
+ .then(res => this.responseToAlbums(res))
+ .catch(this.handleError);
+ // TODO Excluse 'Divers' + compilation
+ }
+
getAlbumSongs(albumName: string, from: number = 0): Observable {
console.info('getAlbumSongs- Album name: ' + albumName + ' - from: ' + from);
return this.http
@@ -327,6 +336,19 @@ export class ElsService {
return result;
}
+ /** Process a response to a array of songs.
+ *
+ * @param res Response to process
+ */
+ private responseToAlbums(res: Response): Album[] {
+ const result: Array = [];
+ res.json().hits.hits.forEach((hit) => {
+ result.push(hit._source);
+ });
+ return result;
+ }
+
+
/** Process an aggregation response to an array of Bucket.
*
* @param res Response to process