diff --git a/dashboard/src/app/app-routing.module.ts b/dashboard/src/app/app-routing.module.ts index 72804be..a26d87b 100644 --- a/dashboard/src/app/app-routing.module.ts +++ b/dashboard/src/app/app-routing.module.ts @@ -3,6 +3,7 @@ import { RouterModule, Routes } from '@angular/router'; import { DashboardComponent } from './dashboard.component'; import { AlbumComponent } from './album.component'; +import { ArtistComponent } from './artist.component'; import { HeroesComponent } from './heroes.component'; import { HeroDetailComponent } from './hero-detail.component'; @@ -12,6 +13,7 @@ const routes: Routes = [ { path: 'detail/:id', component: HeroDetailComponent }, { path: 'heroes', component: HeroesComponent }, { path: 'album/:name', component: AlbumComponent } + { path: 'artist/:name', component: ArtistComponent } ]; @NgModule({ diff --git a/dashboard/src/app/app.module.ts b/dashboard/src/app/app.module.ts index 89112ca..d5507aa 100644 --- a/dashboard/src/app/app.module.ts +++ b/dashboard/src/app/app.module.ts @@ -11,7 +11,8 @@ import { AppComponent } from './app.component'; import { HeroDetailComponent } from './hero-detail.component'; import { HeroesComponent } from './heroes.component'; import { DashboardComponent } from './dashboard.component' -import { AlbumComponent } from './album.component' +import { AlbumComponent } from './album.component' +import { ArtistComponent } from './artist.component' import { HeroService } from './hero.service'; import { ElsService } from './els.service'; @@ -34,6 +35,7 @@ import { SortPipe } from './sortby.pipe' HeroesComponent, DashboardComponent, AlbumComponent, + ArtistComponent, SortPipe ], providers: [ diff --git a/dashboard/src/app/artist.component.html b/dashboard/src/app/artist.component.html new file mode 100644 index 0000000..444f4c1 --- /dev/null +++ b/dashboard/src/app/artist.component.html @@ -0,0 +1,7 @@ +

{{albumName}}

+ + \ No newline at end of file diff --git a/dashboard/src/app/artist.component.ts b/dashboard/src/app/artist.component.ts new file mode 100644 index 0000000..0d3ba73 --- /dev/null +++ b/dashboard/src/app/artist.component.ts @@ -0,0 +1,35 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Params } from '@angular/router' +import { Location } from '@angular/common' + +import { ElsService } from './els.service' +import { Song } from './object/song'; + +@Component({ + selector: 'artist-component', + templateUrl: './artist.component.html' +// styleUrls: [ './album.component.css' ] +}) + +export class ArtistComponent implements OnInit { + constructor( + private elsService: ElsService, + private route: ActivatedRoute, + private location: Location + ) { } + + artistName = ""; + + songs: Array = []; + + ngOnInit(): void { + this.route.params + .subscribe((params: Params) => this.artistName = params['name']); + + this.elsService.getArtistSongs(this.artistName).subscribe( + data => { + this.songs = data; + } + ); + } +} \ No newline at end of file diff --git a/dashboard/src/app/els.service.ts b/dashboard/src/app/els.service.ts index eb64904..d524712 100644 --- a/dashboard/src/app/els.service.ts +++ b/dashboard/src/app/els.service.ts @@ -103,6 +103,24 @@ export class ElsService { }); } + getArtistSongs(artistName: string, from: number = 0): Observable { + console.debug("Artist name: " + artistName + " - from: " + from); + return this.http + .post(this.elsUrl + "song/_search", + JSON.stringify({"query":{"match_phrase":{"Artist":artistName}},"size": ElsService.DEFAULT_SIZE, "from": from}), // TODO Dynamic size + {headers: this.headers}) + .map(res => { + return res.json().hits.hits; + }) + .map((hits: Array) => { + let result:Array = []; + hits.forEach((hit) => { + result.push(hit._source); + }); + return result; + }); + } + getAlbum(albumName: string): Observable { return this.http .post(this.elsUrl + "album/_search",