-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from hurry-harry/hf-create-stats-page
Start with Stats page
- Loading branch information
Showing
22 changed files
with
250 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface HomeCard { | ||
imageSource: string; | ||
title: string; | ||
description: string; | ||
url: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export interface ExternalUrls { | ||
spotify: string; | ||
} | ||
|
||
export interface Followers { | ||
href: string; // will always be null, Spotify Web API currently does not support it | ||
total: number; | ||
} | ||
|
||
export interface Image { | ||
url: string; | ||
height: number; // in pixels | ||
width: number; // in pixels | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { ExternalUrls, Followers, Image } from "./spotify-shared.model"; | ||
|
||
export interface UserTopItems { | ||
href: string; | ||
limit: number; | ||
offset: number; | ||
total: number; | ||
next: string; | ||
previous: string; | ||
items: Artist[] | Track[]; | ||
} | ||
|
||
export interface Artist { | ||
external_urls: ExternalUrls; | ||
followers: Followers; | ||
genres: string[]; | ||
href: string; | ||
id: string; | ||
images: Image[]; | ||
name: string; | ||
popularity: number; | ||
type: string; | ||
uri: string; | ||
} | ||
|
||
export interface Track { | ||
album: Album; | ||
artists: Artist[]; | ||
available_markets: string[]; | ||
disc_number: number; | ||
duration_ms: number; | ||
explicit: boolean; | ||
external_ids: ExternalIds; | ||
external_urls: ExternalUrls; | ||
href: string; | ||
id: string; | ||
is_playable: boolean; | ||
linked_from: LinkedFrom; | ||
restrictions: Restriction; | ||
name: string; | ||
popularity: number; | ||
preview_url: string; | ||
track_number: number; | ||
type: string; | ||
uri: string; | ||
is_local: boolean; | ||
} | ||
|
||
export interface Album { | ||
album_type: string; | ||
total_tracks: number; | ||
available_markets: string[]; | ||
external_urls: ExternalUrls; | ||
href: string; | ||
id: string; | ||
images: Image[]; | ||
name: string; | ||
release_date: string; | ||
release_date_precision: string; | ||
restrictions: Restriction; | ||
type: string; | ||
uri: string; | ||
artists: SimplifiedArtist[]; | ||
} | ||
|
||
export interface Restriction { | ||
reason: string; | ||
} | ||
|
||
export interface SimplifiedArtist { | ||
external_urls: ExternalUrls; | ||
href: string; | ||
id: string; | ||
name: string; | ||
type: string; | ||
uri: string; | ||
} | ||
|
||
export interface ExternalIds { | ||
isrc: string; | ||
ean: string; | ||
upc: string; | ||
} | ||
|
||
export interface LinkedFrom { | ||
external_urls: ExternalUrls; | ||
href: string; | ||
id: string; | ||
type: string; | ||
uri: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
<app-nav-bar></app-nav-bar> | ||
<router-outlet></router-outlet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<div class="card"> | ||
<img class="image" src="/assets/headphones.png"> | ||
<h2>Play Heardle</h2> | ||
<div class="card" (click)="navigateTo()"> | ||
<img class="image card__item" src="{{ card.imageSource }}"> | ||
<h2 class="card__item">{{ card.title }}</h2> | ||
<p class="card__description">{{ card.description }}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<app-nav-bar></app-nav-bar> | ||
<div class="card-container"> | ||
<app-home-card></app-home-card> | ||
<app-home-card></app-home-card> | ||
<app-home-card [card]="playCard"></app-home-card> | ||
<app-home-card [card]="statsCard"></app-home-card> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
flex-direction: row; | ||
align-content: center; | ||
justify-content: center; | ||
padding-top: 3rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>stats works!</p> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { StatsComponent } from './stats.component'; | ||
|
||
describe('StatsComponent', () => { | ||
let component: StatsComponent; | ||
let fixture: ComponentFixture<StatsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [StatsComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(StatsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { SpotifyService } from '../../_shared/services/spotify.service'; | ||
import { UserService } from '../../_shared/services/user.service'; | ||
import { UserTopItems } from '../../_shared/models/user-top-items-response.model'; | ||
|
||
@Component({ | ||
selector: 'app-stats', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './stats.component.html', | ||
styleUrl: './stats.component.scss' | ||
}) | ||
export class StatsComponent implements OnInit { | ||
topItems!: UserTopItems; | ||
|
||
timeRange: string; | ||
offset: number; | ||
topItemMode: string; | ||
|
||
TimeRangeMap = { | ||
"4 weeks": "short_term", | ||
"6 weeks": "medium_term", | ||
Lifetime: "long_term" | ||
} | ||
|
||
TopItemModeMap = { | ||
Artists: "artists", | ||
Tracks: "tracks" | ||
} | ||
|
||
constructor( | ||
private spotifyService: SpotifyService, | ||
private userService: UserService) { | ||
this.timeRange = this.TimeRangeMap['4 weeks']; | ||
this.offset = 0; | ||
this.topItemMode = this.TopItemModeMap.Tracks; | ||
} | ||
|
||
ngOnInit(): void { | ||
this.spotifyService.getTopItems(this.userService.authTokenSignal(), this.timeRange, this.offset, this.topItemMode) | ||
.subscribe((response) => { | ||
this.topItems = response; | ||
console.log('total', this.topItems.total); | ||
console.log('first', this.topItems.items[0].name); | ||
}); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.