;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [TrackListItemComponent],
12 | }).compileComponents();
13 | });
14 |
15 | beforeEach(() => {
16 | fixture = TestBed.createComponent(TrackListItemComponent);
17 | component = fixture.componentInstance;
18 | fixture.detectChanges();
19 | });
20 |
21 | it('should create', () => {
22 | expect(component).toBeTruthy();
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/src/app/core/dialogs/confirm.component.ts:
--------------------------------------------------------------------------------
1 | import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
2 | import { Icons } from '@app/core/utils/icons.util';
3 | import { MAT_DIALOG_DATA } from '@angular/material/dialog';
4 |
5 | export interface ConfirmData {
6 | text: string;
7 | action: string;
8 | }
9 |
10 | @Component({
11 | selector: 'app-confirm',
12 | template: `
13 | Please confirm
14 |
15 | {{ data.text }}
16 |
17 |
18 |
19 |
22 |
23 | `,
24 | styles: [
25 | `
26 | :host {
27 | display: block;
28 | }
29 | .mat-dialog-container {
30 | padding-bottom: 0 !important;
31 | }
32 | .dialog-actions {
33 | text-align: right;
34 | margin: 0 -24px -24px;
35 | padding: 1em;
36 | }
37 | .mat-dialog-content {
38 | border-bottom: solid rgba(255, 255, 255, 0.1);
39 | border-width: 1px 0;
40 | padding: 0 24px 24px;
41 | }
42 | button {
43 | margin-left: 1em;
44 | }
45 | `,
46 | ],
47 | changeDetection: ChangeDetectionStrategy.OnPush,
48 | })
49 | export class ConfirmComponent {
50 | icons = Icons;
51 |
52 | constructor(@Inject(MAT_DIALOG_DATA) public data: ConfirmData) {}
53 | }
54 |
--------------------------------------------------------------------------------
/src/app/core/dialogs/playlist-add.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { PlaylistAddComponent } from './playlist-add.component';
4 |
5 | describe('AddToPlaylistComponent', () => {
6 | let component: PlaylistAddComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [PlaylistAddComponent],
12 | }).compileComponents();
13 | });
14 |
15 | beforeEach(() => {
16 | fixture = TestBed.createComponent(PlaylistAddComponent);
17 | component = fixture.componentInstance;
18 | fixture.detectChanges();
19 | });
20 |
21 | it('should create', () => {
22 | expect(component).toBeTruthy();
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/src/app/core/dialogs/playlist-add.component.ts:
--------------------------------------------------------------------------------
1 | import { ChangeDetectionStrategy, Component } from '@angular/core';
2 | import { Icons } from '@app/core/utils/icons.util';
3 | import { Observable } from 'rxjs';
4 | import { Playlist } from '@app/database/playlists/playlist.model';
5 | import { PlaylistFacade } from '@app/database/playlists/playlist.facade';
6 |
7 | @Component({
8 | selector: 'app-playlist-add',
9 | template: `
10 | My playlists
11 |
12 |
13 |
17 |
18 |
19 |
20 |
23 |
24 | `,
25 | styles: [
26 | `
27 | :host {
28 | display: block;
29 | }
30 | app-icon {
31 | margin-right: 8px;
32 | }
33 | .mat-dialog-container {
34 | padding-bottom: 0 !important;
35 | }
36 | .dialog-actions {
37 | text-align: right;
38 | margin: 0 -24px 0;
39 | }
40 | .new-playlist {
41 | width: 100%;
42 | height: 52px;
43 | text-transform: uppercase;
44 | }
45 | .mat-dialog-content {
46 | padding: 0 !important;
47 | border: solid rgba(255, 255, 255, 0.1);
48 | border-width: 1px 0;
49 | }
50 | `,
51 | ],
52 | changeDetection: ChangeDetectionStrategy.OnPush,
53 | })
54 | export class PlaylistAddComponent {
55 | icons = Icons;
56 |
57 | playlists$: Observable = this.playlists.getAll('title');
58 |
59 | constructor(private playlists: PlaylistFacade) {}
60 | }
61 |
--------------------------------------------------------------------------------
/src/app/core/dialogs/playlist-new.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { PlaylistNewComponent } from './playlist-new.component';
4 |
5 | describe('PlaylistDialogComponent', () => {
6 | let component: PlaylistNewComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [PlaylistNewComponent],
12 | }).compileComponents();
13 | });
14 |
15 | beforeEach(() => {
16 | fixture = TestBed.createComponent(PlaylistNewComponent);
17 | component = fixture.componentInstance;
18 | fixture.detectChanges();
19 | });
20 |
21 | it('should create', () => {
22 | expect(component).toBeTruthy();
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/src/app/core/pipes/duration.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core';
2 |
3 | export const toDuration = (value: number | null | undefined): string => {
4 | if (!value) {
5 | return '0:00';
6 | }
7 |
8 | const hours = Math.floor(value / 3600);
9 | const minutes = Math.floor(value / 60) % 60;
10 | const seconds = Math.floor(value) % 60;
11 |
12 | const format = (num: number) => num.toString(10).padStart(2, '0');
13 |
14 | let result = `${minutes}:${format(seconds)}`;
15 | if (hours > 0) {
16 | result = format(hours) + ':' + result;
17 | }
18 |
19 | return result;
20 | };
21 |
22 | @Pipe({
23 | name: 'duration',
24 | })
25 | export class DurationPipe implements PipeTransform {
26 | transform(value: number | null | undefined): string {
27 | return toDuration(value);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/core/services/history.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { HistoryService } from './history.service';
4 |
5 | describe('HistoryService', () => {
6 | let service: HistoryService;
7 |
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({});
10 | service = TestBed.inject(HistoryService);
11 | });
12 |
13 | it('should be created', () => {
14 | expect(service).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/src/app/core/services/history.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Album } from '@app/database/albums/album.model';
3 | import { Artist } from '@app/database/artists/artist.model';
4 | import { EMPTY, Observable } from 'rxjs';
5 |
6 | @Injectable()
7 | export class HistoryService {
8 | latestPlayedAlbums$(): Observable {
9 | return EMPTY;
10 | // return this.library.getAlbums('listenedOn', undefined, 'prev');
11 | }
12 |
13 | latestPlayedArtists$(): Observable {
14 | return EMPTY;
15 | // return this.library.getArtists('listenedOn', undefined, 'prev');
16 | }
17 |
18 | // albumPlayed(album: Album): void {
19 | // this.storage
20 | // .update$('albums', { listenedOn: new Date() }, album.hash)
21 | // .subscribe();
22 | // }
23 | //
24 | // artistPlayed(artist: Artist): void {
25 | // this.storage
26 | // .update$('artists', { listenedOn: new Date() }, artist.hash)
27 | // .subscribe();
28 | // }
29 | }
30 |
--------------------------------------------------------------------------------
/src/app/core/services/spotify.service.ts:
--------------------------------------------------------------------------------
1 | // import { Injectable } from '@angular/core';
2 | // import { HttpClient } from '@angular/common/http';
3 | // import { Observable } from 'rxjs';
4 | // import { Store } from '@ngrx/store';
5 | // import { selectSpotifyToken } from '@app/store/core.selectors';
6 | // import { concatMap, filter, take } from 'rxjs/operators';
7 | //
8 | // @Injectable({
9 | // providedIn: 'root',
10 | // })
11 | // export class SpotifyService {
12 | // constructor(private http: HttpClient, private store: Store) {}
13 | //
14 | // search(query: string, type: string): Observable