diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index 01f1ece..cb9e14d 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -14,6 +14,7 @@ const routes: Routes = [ path: 'artists', loadChildren: () => import('./pages/artists/artists.module').then(m => m.ArtistsModule) }, + { path: 'tracks', loadChildren: () => import('./pages/tracks/tracks.module').then(m => m.TracksModule) diff --git a/client/src/app/models/artist.model.ts b/client/src/app/models/artist.model.ts index 3fe112a..53be8e3 100644 --- a/client/src/app/models/artist.model.ts +++ b/client/src/app/models/artist.model.ts @@ -1,10 +1,13 @@ export class Artist { + id: string; name: string; image: string; url: string; - constructor(name: string, image: string, url: string) { + constructor(id: string, name: string, image: string, url: string) { + this.id = id; this.name = name; this.image = image; this.url = url; } + } diff --git a/client/src/app/pages/artists/artist-details/artist-details.component.css b/client/src/app/pages/artists/artist-details/artist-details.component.css new file mode 100644 index 0000000..225741c --- /dev/null +++ b/client/src/app/pages/artists/artist-details/artist-details.component.css @@ -0,0 +1,20 @@ +.overlay { + display: flex; + -webkit-box-pack: center; + justify-content: center; + -webkit-box-align: center; + align-items: center; + position: absolute; + width: 100%; + height: 100%; + border-radius: 50%; + background-color: rgba(0, 0, 0, 0.5); + inset: 0; + color: rgb(255, 255, 255); + opacity: 0; + transition: all 0.25s cubic-bezier(0.3, 0, 0.4, 1) 0s; +} + +.img-container:hover .overlay { + opacity: 1; +} diff --git a/client/src/app/pages/artists/artist-details/artist-details.component.html b/client/src/app/pages/artists/artist-details/artist-details.component.html new file mode 100644 index 0000000..e4ba32f --- /dev/null +++ b/client/src/app/pages/artists/artist-details/artist-details.component.html @@ -0,0 +1,17 @@ +
+ +
+
+ artist +
+
+ info +
+
+
+

+ {{ artist.name }}

+
+ +
diff --git a/client/src/app/pages/artists/artist-details/artist-details.component.ts b/client/src/app/pages/artists/artist-details/artist-details.component.ts new file mode 100644 index 0000000..de230f5 --- /dev/null +++ b/client/src/app/pages/artists/artist-details/artist-details.component.ts @@ -0,0 +1,35 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from "@angular/router"; +import { Observable } from "rxjs"; +import { Artist } from "../../../models/artist.model"; +import { NgxUiLoaderService } from "ngx-ui-loader"; +import { ArtistService } from "../../../services/artist.service"; + +@Component({ + selector: 'app-artist-details', + templateUrl: './artist-details.component.html', + styleUrls: ['./artist-details.component.css'] +}) +export class ArtistDetailsComponent implements OnInit { + id = ''; + isLoading: boolean = true; + artist$!: Observable; + + constructor(private route: ActivatedRoute, private artistService: ArtistService, private ngxService: NgxUiLoaderService) { + this.route.params.subscribe(params => { + this.id = params['id']; + }); + } + + ngOnInit(): void { + this.ngxService.startLoader("in-app-loader"); + this.artist$ = this.getArtist(); + this.isLoading = false; + this.ngxService.stopLoader("in-app-loader"); + } + + getArtist(): Observable { + return this.artistService.getArtist(this.id); + } + +} diff --git a/client/src/app/pages/artists/artists-routing.module.ts b/client/src/app/pages/artists/artists-routing.module.ts index f6afebe..043bf76 100644 --- a/client/src/app/pages/artists/artists-routing.module.ts +++ b/client/src/app/pages/artists/artists-routing.module.ts @@ -2,6 +2,7 @@ import { NgModule } from "@angular/core"; import { RouterModule, Routes } from "@angular/router"; import { ArtistsComponent } from "./artists.component"; import { authGuard } from "../../guards/auth.guard"; +import { ArtistDetailsComponent } from "./artist-details/artist-details.component"; const routes: Routes = [ @@ -9,6 +10,10 @@ const routes: Routes = [ path: '', component: ArtistsComponent, canActivate: [authGuard] }, + { + path: ':id', component: ArtistDetailsComponent, + canActivate: [authGuard] + } ]; @NgModule({ diff --git a/client/src/app/pages/artists/artists.component.html b/client/src/app/pages/artists/artists.component.html index 5bc2993..c105bf6 100644 --- a/client/src/app/pages/artists/artists.component.html +++ b/client/src/app/pages/artists/artists.component.html @@ -20,8 +20,7 @@

Top Artists

- +
artist diff --git a/client/src/app/pages/artists/artists.module.ts b/client/src/app/pages/artists/artists.module.ts index d3d7e50..087a2dd 100644 --- a/client/src/app/pages/artists/artists.module.ts +++ b/client/src/app/pages/artists/artists.module.ts @@ -2,9 +2,10 @@ import { NgModule } from '@angular/core'; import { ArtistsComponent } from './artists.component'; import { SharedModule } from 'src/app/shared/shared.module'; import { ArtistsRoutingModule } from "./artists-routing.module"; +import { ArtistDetailsComponent } from './artist-details/artist-details.component'; @NgModule({ - declarations: [ArtistsComponent], + declarations: [ArtistsComponent, ArtistDetailsComponent], imports: [SharedModule, ArtistsRoutingModule], exports: [ArtistsComponent] }) diff --git a/client/src/app/services/artist.service.ts b/client/src/app/services/artist.service.ts index 0a9f6cd..cf5514c 100644 --- a/client/src/app/services/artist.service.ts +++ b/client/src/app/services/artist.service.ts @@ -21,6 +21,7 @@ export class ArtistService { map((response: any) => { return response.items.map((item: any) => { return { + id: item.id, name: item.name, image: item.images[2].url, url: item.external_urls.spotify @@ -39,6 +40,7 @@ export class ArtistService { map((response: any) => { return response.items.map((item: any) => { return { + id: item.id, name: item.name, image: item.images[0].url, url: item.external_urls.spotify @@ -52,4 +54,21 @@ export class ArtistService { ) } + getArtist(id: string): Observable { + return this.http.get(`/artists/${id}`).pipe( + map((response: any) => { + return { + id: response.id, + name: response.name, + image: response.images[0].url, + url: response.external_urls.spotify + }; + }), + catchError((error) => { + console.error(error); + return of(undefined); + }) + ) + } + }