diff --git a/dashboard/src/app/albums/albums.component.css b/dashboard/src/app/albums/albums.component.css new file mode 100644 index 0000000..e69de29 diff --git a/dashboard/src/app/albums/albums.component.html b/dashboard/src/app/albums/albums.component.html new file mode 100644 index 0000000..bc81ce3 --- /dev/null +++ b/dashboard/src/app/albums/albums.component.html @@ -0,0 +1,20 @@ +
+ + + + + + + + + + + + + + + + + +
AlbumTrack CountAlbum ArtistAvg. Bit Rate
{{album.Album}}{{album['Track Count']}}{{album['Album Artist'] ? album['Album Artist'] : album.Artist }}{{album['Avg Bit Rate']}}
+
diff --git a/dashboard/src/app/albums/albums.component.spec.ts b/dashboard/src/app/albums/albums.component.spec.ts new file mode 100644 index 0000000..f08c8c5 --- /dev/null +++ b/dashboard/src/app/albums/albums.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AlbumsComponent } from './albums.component'; + +describe('AlbumsComponent', () => { + let component: AlbumsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ AlbumsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AlbumsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/dashboard/src/app/albums/albums.component.ts b/dashboard/src/app/albums/albums.component.ts new file mode 100644 index 0000000..aed8557 --- /dev/null +++ b/dashboard/src/app/albums/albums.component.ts @@ -0,0 +1,21 @@ +import { Component, OnInit } from '@angular/core'; + +import { ElsService } from "../els.service"; +import { Album } from '../model/album'; + +@Component({ + selector: 'app-albums', + templateUrl: './albums.component.html', + styleUrls: ['./albums.component.css'] +}) +export class AlbumsComponent implements OnInit { + + albums: Album[] = []; + + constructor(private elsService: ElsService) { } + + ngOnInit(): void { + this.elsService.getAlbums(20).subscribe(data => { this.albums = data; console.log(data);}); + } + +} diff --git a/dashboard/src/app/app-routing.module.ts b/dashboard/src/app/app-routing.module.ts index bb4b0f2..6b31b0e 100644 --- a/dashboard/src/app/app-routing.module.ts +++ b/dashboard/src/app/app-routing.module.ts @@ -6,11 +6,13 @@ import { AlbumComponent } from './album/album.component'; import { ArtistComponent } from './artist/artist.component'; import { GenreComponent } from './genre/genre.component'; import { TopPlayedComponent } from './top-played/top-played.component'; +import { AlbumsComponent } from './albums/albums.component'; const routes: Routes = [ { path: '', redirectTo: '/dashboard', pathMatch: 'full' }, { path: 'dashboard', component: DashboardComponent }, { path: 'album/:name', component: AlbumComponent }, + { path: 'album', component: AlbumsComponent }, { path: 'artist/:name', component: ArtistComponent }, { path: 'genre/:name', component: GenreComponent }, { path: 'top-played', component: TopPlayedComponent } diff --git a/dashboard/src/app/app.component.html b/dashboard/src/app/app.component.html index b5353c5..2005326 100644 --- a/dashboard/src/app/app.component.html +++ b/dashboard/src/app/app.component.html @@ -1,4 +1,5 @@ diff --git a/dashboard/src/app/app.module.ts b/dashboard/src/app/app.module.ts index eba8a48..b6db76e 100644 --- a/dashboard/src/app/app.module.ts +++ b/dashboard/src/app/app.module.ts @@ -19,6 +19,7 @@ import { ConvertMoreExactPipe } from './pipes/convert-more-exact.pipe'; import { SortByPipe } from './pipes/sort-by.pipe'; import { ConvertSizeToStringPipe } from './pipes/convert-size-to-string.pipe'; import { RoundPipe } from './pipes/round.pipe'; +import { AlbumsComponent } from './albums/albums.component'; @NgModule({ imports: [ @@ -30,6 +31,7 @@ import { RoundPipe } from './pipes/round.pipe'; AppComponent, DashboardComponent, AlbumComponent, + AlbumsComponent, ArtistComponent, GenreComponent, SongTableComponent, diff --git a/dashboard/src/app/dashboard/dashboard.component.html b/dashboard/src/app/dashboard/dashboard.component.html index 5c56bd9..41d65c3 100644 --- a/dashboard/src/app/dashboard/dashboard.component.html +++ b/dashboard/src/app/dashboard/dashboard.component.html @@ -96,6 +96,8 @@ + +

Top Played Songs

diff --git a/dashboard/src/app/els.service.ts b/dashboard/src/app/els.service.ts index a19286f..7839501 100644 --- a/dashboard/src/app/els.service.ts +++ b/dashboard/src/app/els.service.ts @@ -244,6 +244,25 @@ export class ElsService { ); } + getAlbums(size: number): Observable { + // http://localhost:9200/itunes-albums/_search + console.info('getAlbums'); + return this.http + .post(this.elsUrl + ElsService.ALBUM_INDEX_NAME + ElsService.ACTION_SEARCH, + JSON.stringify({ + 'sort': [ { + 'Avg Bit Rate': { + 'order': 'asc' + } + } ], + 'size': size + }), {headers: this.headers}) + .pipe( + map(res => this.responseToAlbums(res)), + catchError(error => this.handleError(error, 'getAlbums')) + ); + } + getArtist(artistName: string): Observable { return this.http .post(this.elsUrl + ElsService.ARTIST_INDEX_NAME + ElsService.ACTION_SEARCH,