diff --git a/dashboard/src/app/dashboard.component.html b/dashboard/src/app/dashboard.component.html
index 4dded5e..9fda40a 100644
--- a/dashboard/src/app/dashboard.component.html
+++ b/dashboard/src/app/dashboard.component.html
@@ -11,7 +11,5 @@
-
-
{{e.Name}}
-
+
{{e['Play Count']}}: {{e.Name}} - {{e.Artist}}
\ No newline at end of file
diff --git a/dashboard/src/app/dashboard.component.ts b/dashboard/src/app/dashboard.component.ts
index fa2b737..45e4c19 100644
--- a/dashboard/src/app/dashboard.component.ts
+++ b/dashboard/src/app/dashboard.component.ts
@@ -36,15 +36,8 @@ export class DashboardComponent implements OnInit {
this.elsService.getTrackCount("album")
.then(result => this.trackCountAlbum = result);
- this.elsService.getMostPlayedTrackO().subscribe(
- data => {
- data.forEach(element => {
- this.mostPlayedSongs.push(element._source);
- });
- this.mostPlayedSongs.forEach(element => {
- console.log(element.Name)
- });
- }
+ this.elsService.getMostPlayedTrack().subscribe(
+ data => this.mostPlayedSongs = data
);
}
diff --git a/dashboard/src/app/els.service.ts b/dashboard/src/app/els.service.ts
index 54ef5c2..fe75908 100644
--- a/dashboard/src/app/els.service.ts
+++ b/dashboard/src/app/els.service.ts
@@ -30,27 +30,32 @@ export class ElsService {
.catch(this.handleError);
}
- getTrackCountO(type: string): Observable {
- return this.http.get(this.elsUrl + type + "/_count")
- .map(res => res.json().count as number);
- }
+ getMostPlayedTrack(): Observable {
+ // Thank to http://chariotsolutions.com/blog/post/angular2-observables-http-separating-services-components/
- getMostPlayedTrack(): Promise {
- return this.http.post(this.elsUrl + "song/_search",
- JSON.stringify({"sort":[{"Play Count":{"order":"desc"}}],"size": 5}),
- {headers: this.headers})
- .toPromise()
- .then(res => res.json().hits.hits)
- .catch(this.handleError);
- }
-
- getMostPlayedTrackO(): Observable