Compare commits
19 Commits
poc/sugges
...
25828bb789
| Author | SHA1 | Date | |
|---|---|---|---|
| 25828bb789 | |||
| 29350c36cd | |||
| 9f4ef952b3 | |||
| 2ddafaff1b | |||
| 7e0a791fbe | |||
| cf8cd046f4 | |||
| a10c9ae060 | |||
| 754ee9213c | |||
| 40aed6039d | |||
| 4399018b4a | |||
| bb51af68cd | |||
| 5ee9781463 | |||
| 00a5427950 | |||
| fada5f475b | |||
| d307012aca | |||
| 755f5e5c24 | |||
| f40ee2b6d2 | |||
| d011d5738f | |||
| e5de38b9d9 |
21
README.md
Normal file
21
README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Classic data
|
||||
|
||||
1. Analyze data :
|
||||
|
||||
```sh
|
||||
python3 iTunesParser.py
|
||||
```
|
||||
2. Send data to ELS :
|
||||
|
||||
```sh
|
||||
python3 send_data.py -D -A
|
||||
```
|
||||
|
||||
# Suggester
|
||||
|
||||
To use suggester, create index with data in `suggester.es` file.
|
||||
Then :
|
||||
|
||||
```sh
|
||||
python3 suggester.py
|
||||
```
|
||||
1
dashboard/.gitignore
vendored
1
dashboard/.gitignore
vendored
@@ -25,6 +25,7 @@
|
||||
!.vscode/extensions.json
|
||||
|
||||
# misc
|
||||
/.angular/cache
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
|
||||
1
dashboard/.nvmrc
Normal file
1
dashboard/.nvmrc
Normal file
@@ -0,0 +1 @@
|
||||
14
|
||||
@@ -18,7 +18,6 @@
|
||||
"main": "src/main.ts",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"aot": true,
|
||||
"assets": [
|
||||
"src/assets",
|
||||
"src/favicon.ico"
|
||||
@@ -27,7 +26,13 @@
|
||||
"src/styles.css",
|
||||
"node_modules/bootstrap/dist/css/bootstrap.min.css"
|
||||
],
|
||||
"scripts": []
|
||||
"scripts": [],
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"buildOptimizer": false,
|
||||
"sourceMap": true,
|
||||
"optimization": false,
|
||||
"namedChunks": true
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
@@ -57,7 +62,8 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": ""
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
@@ -94,19 +100,6 @@
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"tsconfig.app.json",
|
||||
"tsconfig.spec.json",
|
||||
"e2e/tsconfig.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
},
|
||||
"e2e": {
|
||||
"builder": "@angular-devkit/build-angular:protractor",
|
||||
"options": {
|
||||
|
||||
31056
dashboard/package-lock.json
generated
31056
dashboard/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,31 +11,31 @@
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "~11.0.4",
|
||||
"@angular/common": "~11.0.4",
|
||||
"@angular/compiler": "~11.0.4",
|
||||
"@angular/core": "~11.0.4",
|
||||
"@angular/forms": "~11.0.4",
|
||||
"@angular/platform-browser": "~11.0.4",
|
||||
"@angular/platform-browser-dynamic": "~11.0.4",
|
||||
"@angular/router": "~11.0.4",
|
||||
"@ng-bootstrap/ng-bootstrap": "^9.1.3",
|
||||
"@angular/animations": "~13.3.11",
|
||||
"@angular/common": "~13.3.11",
|
||||
"@angular/compiler": "~13.3.11",
|
||||
"@angular/core": "~13.3.11",
|
||||
"@angular/forms": "~13.3.11",
|
||||
"@angular/localize": "~13.3.11",
|
||||
"@angular/platform-browser": "~13.3.11",
|
||||
"@angular/platform-browser-dynamic": "~13.3.11",
|
||||
"@angular/router": "~13.3.11",
|
||||
"@ng-bootstrap/ng-bootstrap": "^10.0.0",
|
||||
"bootstrap": "^3.3.7",
|
||||
"rxjs": "~6.6.0",
|
||||
"tslib": "^2.0.0",
|
||||
"zone.js": "~0.10.2"
|
||||
"zone.js": "~0.11.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "~0.1100.4",
|
||||
"@angular/cli": "~11.0.4",
|
||||
"@angular/compiler-cli": "~11.0.4",
|
||||
"@angular/localize": "^11.0.4",
|
||||
"@angular-devkit/build-angular": "~13.3.9",
|
||||
"@angular/cli": "~13.3.9",
|
||||
"@angular/compiler-cli": "~13.3.11",
|
||||
"@types/jasmine": "~3.6.0",
|
||||
"@types/node": "^12.11.1",
|
||||
"codelyzer": "^6.0.0",
|
||||
"jasmine-core": "~3.6.0",
|
||||
"jasmine-spec-reporter": "~5.0.0",
|
||||
"karma": "~5.1.0",
|
||||
"karma": "~6.3.4",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.0.3",
|
||||
"karma-jasmine": "~4.0.0",
|
||||
@@ -43,6 +43,6 @@
|
||||
"protractor": "~7.0.0",
|
||||
"ts-node": "~8.3.0",
|
||||
"tslint": "~6.1.0",
|
||||
"typescript": "~4.0.2"
|
||||
"typescript": "~4.6.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
<div class="container">
|
||||
<h1>{{albumName}}</h1>
|
||||
|
||||
<div *ngIf="sortFilter" class="alert alert-danger">
|
||||
To sort filter applyed. Songs are filter on location. <br/>
|
||||
Album folder: {{album['Location']}}
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning">
|
||||
<h3>Debug Zone</h3>
|
||||
Returned song: {{songs.length}}<br />
|
||||
@@ -20,7 +25,7 @@
|
||||
<div class="col-xs-9 text-right">
|
||||
<div>
|
||||
<h3 *ngIf="!album"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="album">{{album.Rating}}/100</h3>
|
||||
<h3 *ngIf="album">{{album['Album Rating']}}/100</h3>
|
||||
</div>
|
||||
<div><br>Rating</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
import { ElsService } from './../els.service';
|
||||
import { ElsService } from '../els-service/els.service';
|
||||
import { Song } from './../model/song';
|
||||
import { Album } from './../model/album';
|
||||
import { SongTableComponent } from '../song-table/song-table.component';
|
||||
@@ -19,6 +18,7 @@ export class AlbumComponent implements OnInit {
|
||||
albumName = '';
|
||||
songs: Array<Song> = [];
|
||||
album: Album = new Album(); // If album not found, will be replaced by 'undefined'
|
||||
sortFilter: boolean = false; // Show only song to sort
|
||||
|
||||
// Prevent useless data load + activate button in interface var
|
||||
moreDataAvailable = true;
|
||||
@@ -26,13 +26,12 @@ export class AlbumComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private elsService: ElsService,
|
||||
private route: ActivatedRoute,
|
||||
private location: Location
|
||||
private route: ActivatedRoute
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.params
|
||||
.subscribe((params: Params) => this.albumName = params['name']);
|
||||
this.route.params.subscribe((params: Params) => this.albumName = params['name']);
|
||||
this.route.queryParams.subscribe(params => { this.sortFilter = params.tosort ?? false; });
|
||||
|
||||
this.loadSongs();
|
||||
|
||||
@@ -50,7 +49,7 @@ export class AlbumComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.lockLoadData = true;
|
||||
this.elsService.getAlbumSongs(this.albumName, this.songs.length).subscribe(
|
||||
this.elsService.getAlbumSongs(this.albumName, this.songs.length, this.sortFilter).subscribe(
|
||||
data => {
|
||||
this.moreDataAvailable = data.length === ElsService.DEFAULT_SIZE;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ElsAlbumService } from '../els-album.service';
|
||||
import { ElsAlbumService } from '../els-service/els-album.service';
|
||||
|
||||
import { Album } from '../model/album';
|
||||
|
||||
@@ -27,7 +27,7 @@ export class AlbumsComponent implements OnInit {
|
||||
this.loadData();
|
||||
}
|
||||
|
||||
private editQuery(field: string, value: string, type: query_edit_type): void {
|
||||
private editQuery(field: string, value: Album, type: query_edit_type): void {
|
||||
// TODO Move this method to a service
|
||||
if (value[field] instanceof Array) {
|
||||
value[field] = value[field][0]
|
||||
@@ -49,12 +49,12 @@ export class AlbumsComponent implements OnInit {
|
||||
this.queryEdited = true;
|
||||
}
|
||||
|
||||
exlude(field: string, value: string): void {
|
||||
exlude(field: string, value: Album): void {
|
||||
this.editQuery(field, value, query_edit_type.exclude)
|
||||
this.loadData()
|
||||
}
|
||||
|
||||
select(field: string, value: string): void {
|
||||
select(field: string, value: Album): void {
|
||||
this.editQuery(field, value, query_edit_type.select)
|
||||
this.loadData()
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ 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';
|
||||
import { ToSortComponent } from './to-sort/to-sort.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
|
||||
@@ -15,7 +16,8 @@ const routes: Routes = [
|
||||
{ path: 'album', component: AlbumsComponent },
|
||||
{ path: 'artist/:name', component: ArtistComponent },
|
||||
{ path: 'genre/:name', component: GenreComponent },
|
||||
{ path: 'top-played', component: TopPlayedComponent }
|
||||
{ path: 'top-played', component: TopPlayedComponent },
|
||||
{ path: 'to-sort', component: ToSortComponent }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -36,7 +36,8 @@ nav a.active {
|
||||
|
||||
/* FIXME Code Repetition */
|
||||
.btn-top {
|
||||
display: inline-block;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
-webkit-transition: opacity .3s 0s, visibility 0s 0s;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<nav>
|
||||
<a class="btn-top" routerLink="/dashboard" routerLinkActive="active"><span class="glyphicon glyphicon-home"></span></a><br />
|
||||
<a class="btn-top" routerLink="/album" routerLinkActive="active"><span class="glyphicon glyphicon-cd"></span></a>
|
||||
<div class="btn-top">
|
||||
<a routerLink="/dashboard" routerLinkActive="active"><span class="glyphicon glyphicon-home"></span></a><br />
|
||||
<a routerLink="/album" routerLinkActive="active"><span class="glyphicon glyphicon-cd"></span></a>
|
||||
<a routerLink="/to-sort" routerLinkActive="active"><span class="glyphicon glyphicon-sort"></span></a>
|
||||
</div>
|
||||
</nav>
|
||||
<router-outlet></router-outlet>
|
||||
|
||||
@@ -11,8 +11,8 @@ import { GenreComponent } from './genre/genre.component';
|
||||
import { SongTableComponent } from './song-table/song-table.component';
|
||||
import { TopPlayedComponent } from './top-played/top-played.component';
|
||||
|
||||
import { ElsService } from './els.service';
|
||||
import { ElsAlbumService } from './els-album.service';
|
||||
import { ElsService } from './els-service/els.service';
|
||||
import { ElsAlbumService } from './els-service/els-album.service';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
||||
@@ -22,8 +22,10 @@ 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';
|
||||
import { ToSortComponent } from './to-sort/to-sort.component';
|
||||
|
||||
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ElsArtistService } from './els-service/els-artist.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -46,11 +48,13 @@ import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
|
||||
SortByPipe,
|
||||
ConvertSizeToStringPipe,
|
||||
TopPlayedComponent,
|
||||
RoundPipe
|
||||
RoundPipe,
|
||||
ToSortComponent
|
||||
],
|
||||
providers: [
|
||||
ElsService,
|
||||
ElsAlbumService
|
||||
ElsAlbumService,
|
||||
ElsArtistService
|
||||
],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
import { ElsService } from './../els.service';
|
||||
import { Song } from './../model/song';
|
||||
import { Artist } from './../model/artist';
|
||||
import { SongTableComponent } from '../song-table/song-table.component';
|
||||
import { ElsArtistService } from '../els-service/els-artist.service';
|
||||
import { ElsService } from '../els-service/els.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-artist',
|
||||
@@ -25,19 +25,26 @@ export class ArtistComponent implements OnInit {
|
||||
artist: Artist = new Artist();
|
||||
lockLoadData = false;
|
||||
countSong: number;
|
||||
toSortFilter: boolean = false; // Show only song to sort
|
||||
|
||||
constructor(
|
||||
private elsService: ElsService,
|
||||
private elsService: ElsArtistService,
|
||||
private route: ActivatedRoute,
|
||||
private location: Location
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.params.subscribe((params: Params) => this.artistName = params['name']);
|
||||
this.route.queryParams.subscribe(params => { this.toSortFilter = params.tosort ?? false; });
|
||||
|
||||
this.elsService.getArtist(this.artistName).subscribe(data => this.artist = data);
|
||||
|
||||
this.elsService.getCountArtistSong(this.artistName).subscribe(data => this.countSong = data);
|
||||
this.elsService.getCountArtistSong(this.artistName, this.toSortFilter).subscribe(data => {
|
||||
this.countSong = data
|
||||
this.artist['Track Count'] = this.countSong;
|
||||
// TODO Async problem: some time, get updated data, some time no
|
||||
// TODO Use only this value?
|
||||
// TODO ==> Show each time if there are unsorted songs
|
||||
});
|
||||
|
||||
this.loadSongs();
|
||||
}
|
||||
@@ -54,9 +61,11 @@ export class ArtistComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.lockLoadData = true;
|
||||
this.elsService.getArtistSongs(this.artistName, this.songs.length).subscribe(
|
||||
this.elsService.getArtistSongs(this.artistName, this.songs.length, this.toSortFilter).subscribe(
|
||||
data => {
|
||||
this.moreDataAvailable = data.length === ElsService.DEFAULT_SIZE;
|
||||
console.log(data.length)
|
||||
console.log(this.moreDataAvailable)
|
||||
|
||||
// Erase song array with result for first load, then add elements one by one
|
||||
// instead use concat => concat will sort table at each load, very consuming! and not user friendly
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { ElsService } from './../els.service';
|
||||
import { ElsService } from '../els-service/els.service';
|
||||
import { Song } from './../model/song';
|
||||
import { Bucket } from './../model/bucket';
|
||||
import { Suggested } from '../model/suggested';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http'
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
import { Album } from './model/album';
|
||||
import { Album } from './../model/album';
|
||||
import { ElsService } from './els.service';
|
||||
|
||||
@Injectable()
|
||||
16
dashboard/src/app/els-service/els-artist.service.spec.ts
Normal file
16
dashboard/src/app/els-service/els-artist.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ElsArtistService } from './els-artist.service';
|
||||
|
||||
describe('ElsArtistService', () => {
|
||||
let service: ElsArtistService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ElsArtistService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
121
dashboard/src/app/els-service/els-artist.service.ts
Normal file
121
dashboard/src/app/els-service/els-artist.service.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Observable } from "rxjs";
|
||||
import { catchError, map } from "rxjs/operators";
|
||||
import { Artist } from "../model/artist";
|
||||
import { Song } from "../model/song";
|
||||
import { ElsService } from "./els.service";
|
||||
|
||||
@Injectable()
|
||||
export class ElsArtistService extends ElsService {
|
||||
constructor(protected http: HttpClient) {
|
||||
super(http);
|
||||
}
|
||||
|
||||
private getQuerySongsWithArtistName(
|
||||
artistName: string,
|
||||
sortFilter: boolean = false,
|
||||
size: number = 0,
|
||||
from: number = 0
|
||||
) {
|
||||
let query = {
|
||||
query: {
|
||||
bool: {
|
||||
should: [
|
||||
{ match_phrase: { "Album Artist": artistName } },
|
||||
{ match_phrase: { Artist: artistName } },
|
||||
],
|
||||
must_not: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (sortFilter) {
|
||||
console.log("ElsArtistService- TO SORT filter enabled");
|
||||
query = this.addSortFilterToQuery(query);
|
||||
}
|
||||
|
||||
if (size) {
|
||||
query["size"] = size;
|
||||
}
|
||||
|
||||
if (from) {
|
||||
query["from"] = from;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
public getArtist(artistName: string): Observable<Artist> {
|
||||
return this.http
|
||||
.post(
|
||||
this.elsUrl + ElsService.ARTIST_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
query: {
|
||||
match_phrase: { Artist: artistName },
|
||||
},
|
||||
size: ElsService.DEFAULT_SIZE,
|
||||
}),
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map((res) => this.responseToOneTypedResult<Artist>(res, artistName)),
|
||||
catchError((error) =>
|
||||
this.handleError(error, "getArtist(" + artistName + ")")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public getArtistSongs(
|
||||
artistName: string,
|
||||
from: number = 0,
|
||||
sortFilter = false
|
||||
): Observable<Song[]> {
|
||||
console.info(
|
||||
"getArtistSongs- Artist name: " + artistName + " - from: " + from
|
||||
);
|
||||
|
||||
let query = this.getQuerySongsWithArtistName(
|
||||
artistName,
|
||||
sortFilter,
|
||||
ElsService.DEFAULT_SIZE,
|
||||
from
|
||||
);
|
||||
|
||||
return this.http
|
||||
.post(
|
||||
this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify(query),
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map((res) => this.responseToSongs(res)),
|
||||
catchError((error) =>
|
||||
this.handleError(
|
||||
error,
|
||||
"getArtistSongs(" + artistName + "," + from + ")"
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public getCountArtistSong(
|
||||
artistName: string,
|
||||
sortFilter = false
|
||||
): Observable<number> {
|
||||
console.log("artistname: " + artistName);
|
||||
const query = this.getQuerySongsWithArtistName(artistName, sortFilter);
|
||||
|
||||
return this.http
|
||||
.post<any>(
|
||||
this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_COUNT,
|
||||
JSON.stringify(query),
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map((res) => res.count as number),
|
||||
catchError((error) =>
|
||||
this.handleError(error, "getCountArtistSong" + artistName + ")")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
16
dashboard/src/app/els-service/els-sort.service.spec.ts
Normal file
16
dashboard/src/app/els-service/els-sort.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ElsSortService } from './els-sort.service';
|
||||
|
||||
describe('ElsSortService', () => {
|
||||
let service: ElsSortService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ElsSortService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
169
dashboard/src/app/els-service/els-sort.service.ts
Normal file
169
dashboard/src/app/els-service/els-sort.service.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { ElsService } from './els.service';
|
||||
import { Album } from './../model/album';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ElsSortService extends ElsService {
|
||||
|
||||
constructor(protected http: HttpClient) {
|
||||
super(http);
|
||||
}
|
||||
|
||||
getTime(): Promise<number> {
|
||||
return this.http
|
||||
.post<any>(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
query: {
|
||||
bool: {
|
||||
must_not: [
|
||||
{
|
||||
term: {
|
||||
"Location.tree": "/F:/Musique"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
aggs: {
|
||||
sum_time: {
|
||||
sum: { field: 'Total Time'}
|
||||
}
|
||||
},
|
||||
'size': 0
|
||||
}), {headers: this.headers})
|
||||
.toPromise()
|
||||
.then(res => res.aggregations.sum_time.value as number)
|
||||
.catch(error => this.handleError(error, 'getTime()'));
|
||||
}
|
||||
|
||||
getSize(): Promise<number> {
|
||||
return this.http
|
||||
.post<any>(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
query: {
|
||||
bool: {
|
||||
must_not: [
|
||||
{
|
||||
term: {
|
||||
"Location.tree": "/F:/Musique"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
aggs: {
|
||||
sum_time: {
|
||||
sum: { field: 'Size' }
|
||||
}
|
||||
},
|
||||
'size': 0
|
||||
}), {headers: this.headers})
|
||||
.toPromise()
|
||||
.then(res => res.aggregations.sum_time.value as number)
|
||||
.catch(error => this.handleError(error, 'getSize()'));
|
||||
}
|
||||
|
||||
getCountSong(): Promise<number> {
|
||||
return this.http
|
||||
.post<any>(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_COUNT,
|
||||
JSON.stringify({
|
||||
query: {
|
||||
bool: {
|
||||
must_not: [
|
||||
{
|
||||
term: {
|
||||
"Location.tree": "/F:/Musique"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}), {headers: this.headers})
|
||||
.toPromise()
|
||||
.then(res => res.count as number)
|
||||
.catch(error => this.handleError(error, 'getCountSong()'));
|
||||
}
|
||||
|
||||
getCountNeverListenSong(): Promise<number> {
|
||||
return this.http
|
||||
.post<any>(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_COUNT,
|
||||
JSON.stringify({
|
||||
'query': {
|
||||
'bool': {
|
||||
'must_not': [
|
||||
{
|
||||
'exists': { 'field': 'Play Count'}
|
||||
}, {
|
||||
term: {
|
||||
"Location.tree": "/F:/Musique"
|
||||
} }
|
||||
]
|
||||
}
|
||||
}
|
||||
}), {headers: this.headers})
|
||||
.toPromise()
|
||||
.then(res => res.count as number)
|
||||
.catch(error => this.handleError(error, 'getCountNeverListenSong()'));
|
||||
}
|
||||
|
||||
getNbAlbums(): Promise<number> {
|
||||
return this.http
|
||||
.post<any>(this.elsUrl + ElsService.ALBUM_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
'query': {
|
||||
'bool': {
|
||||
'must_not': [
|
||||
{
|
||||
term: {
|
||||
"Location.tree": "/F:/Musique"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
size: 0,
|
||||
"aggs": {
|
||||
"album_count": {
|
||||
"cardinality": {
|
||||
"field": "Album.raw"
|
||||
}
|
||||
}
|
||||
}
|
||||
}), {headers: this.headers})
|
||||
.toPromise()
|
||||
.then(res => res.aggregations.album_count.value as number )
|
||||
.catch(error => this.handleError(error, 'getNbAlbums()'));
|
||||
}
|
||||
|
||||
getAlbums(): Observable<Album[]> {
|
||||
return this.http
|
||||
.post(this.elsUrl + ElsService.ALBUM_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
query: {
|
||||
bool: {
|
||||
must_not: [
|
||||
{
|
||||
term: {
|
||||
"Location.tree": "/F:/Musique"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
'size': 550,
|
||||
"sort": [
|
||||
{ "Play Count": "desc"}
|
||||
]
|
||||
}), {headers: this.headers})
|
||||
.pipe(
|
||||
map(res => this.responseToAlbums(res)),
|
||||
catchError(error => this.handleError(error, 'getAlbums'))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http'
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
import { Song } from './model/song';
|
||||
import { Album } from './model/album';
|
||||
import { Artist } from './model/artist';
|
||||
import { Bucket } from './model/bucket';
|
||||
import { Suggested } from './model/suggested';
|
||||
import { Song } from '../model/song';
|
||||
import { Album } from '../model/album';
|
||||
import { Artist } from '../model/artist';
|
||||
import { Bucket } from '../model/bucket';
|
||||
import { Suggested } from '../model/suggested';
|
||||
|
||||
@Injectable()
|
||||
export class ElsService {
|
||||
@@ -21,8 +21,9 @@ export class ElsService {
|
||||
protected static readonly ACTION_SEARCH = '/_search';
|
||||
protected static readonly ACTION_COUNT = '/_count';
|
||||
|
||||
protected elsUrl = 'http://localhost:9200';
|
||||
protected elsUrl = 'http://192.168.1.20:9200';
|
||||
protected headers = new HttpHeaders({'Content-Type': 'application/json'});
|
||||
protected defaultLocation = "/F:/Musique"; // TODO Use conf
|
||||
|
||||
constructor(protected http: HttpClient) { }
|
||||
|
||||
@@ -172,20 +173,48 @@ export class ElsService {
|
||||
);
|
||||
}
|
||||
|
||||
getAlbumSongs(albumName: string, from: number = 0): Observable<Song[]> {
|
||||
console.info('getAlbumSongs- Album name: ' + albumName + ' - from: ' + from);
|
||||
return this.http
|
||||
.post(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
'query': {
|
||||
'match_phrase': { 'Album': albumName }
|
||||
getAlbumSongs(albumName: string, from: number = 0, toSortFilter = false): Observable<Song[]> {
|
||||
// TODO Move in els-album service
|
||||
console.info(
|
||||
"getAlbumSongs- Album name: " + albumName + " - from: " + from
|
||||
);
|
||||
|
||||
let query = {
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
{
|
||||
match_phrase: {
|
||||
"Album.raw": albumName,
|
||||
},
|
||||
'size': ElsService.DEFAULT_SIZE,
|
||||
'from': from
|
||||
}), {headers: this.headers})
|
||||
},
|
||||
],
|
||||
must_not: [],
|
||||
},
|
||||
},
|
||||
size: ElsService.DEFAULT_SIZE,
|
||||
from: from,
|
||||
};
|
||||
|
||||
if (toSortFilter) {
|
||||
console.log("getAlbumSongs- TO SORT filter enabled");
|
||||
query = this.addSortFilterToQuery(query)
|
||||
}
|
||||
|
||||
return this.http
|
||||
.post(
|
||||
this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify(query),
|
||||
{ headers: this.headers }
|
||||
)
|
||||
.pipe(
|
||||
map(res => this.responseToSongs(res)),
|
||||
catchError(error => this.handleError(error, 'getAlbumSongs(' + albumName + ',' + from + ')'))
|
||||
map((res) => this.responseToSongs(res)),
|
||||
catchError((error) =>
|
||||
this.handleError(
|
||||
error,
|
||||
"getAlbumSongs(" + albumName + "," + from + ")"
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -203,31 +232,11 @@ export class ElsService {
|
||||
}), {headers: this.headers})
|
||||
.pipe(
|
||||
map(res => this.responseToSongs(res)),
|
||||
catchError(error => this.handleError(error, 'getAlbumSongs(' + genreName + ',' + from + ')'))
|
||||
catchError(error => this.handleError(error, 'getGenreSongs(' + genreName + ',' + from + ')'))
|
||||
);
|
||||
}
|
||||
|
||||
getArtistSongs(artistName: string, from: number = 0): Observable<Song[]> {
|
||||
console.info('getArtistSongs- Artist name: ' + artistName + ' - from: ' + from);
|
||||
return this.http
|
||||
.post(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
'query': {
|
||||
'bool': {
|
||||
'should': [
|
||||
{'match_phrase' : { 'Album Artist' : artistName }},
|
||||
{'match_phrase' : { 'Artist' : artistName }}
|
||||
]
|
||||
}
|
||||
},
|
||||
'size': ElsService.DEFAULT_SIZE,
|
||||
'from': from
|
||||
}), {headers: this.headers})
|
||||
.pipe(
|
||||
map(res => this.responseToSongs(res)),
|
||||
catchError(error => this.handleError(error, 'getArtistSongs(' + artistName + ',' + from + ')'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
getAlbum(albumName: string): Observable<Album> {
|
||||
// TODO Why this is used on album pages?
|
||||
@@ -246,21 +255,6 @@ export class ElsService {
|
||||
);
|
||||
}
|
||||
|
||||
getArtist(artistName: string): Observable<Artist> {
|
||||
return this.http
|
||||
.post(this.elsUrl + ElsService.ARTIST_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
'query': {
|
||||
'match_phrase': { 'Artist': artistName }
|
||||
},
|
||||
'size': ElsService.DEFAULT_SIZE
|
||||
}), {headers: this.headers})
|
||||
.pipe(
|
||||
map(res => this.responseToOneTypedResult<Artist>(res, artistName)),
|
||||
catchError(error => this.handleError(error, 'getArtist(' + artistName + ')'))
|
||||
);
|
||||
}
|
||||
|
||||
getGenres(ordering: string = 'desc'): Observable<Bucket[]> {
|
||||
return this.http
|
||||
.post(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
@@ -283,25 +277,6 @@ export class ElsService {
|
||||
);
|
||||
}
|
||||
|
||||
// getGenreCount(): Observable<number> {
|
||||
// return this.http
|
||||
// .post<any>(this.elsUrl + 'song' + ElsService.ACTION_SEARCH,
|
||||
// JSON.stringify({
|
||||
// 'aggs' : {
|
||||
// 'genres' : {
|
||||
// 'cardinality' : {
|
||||
// 'field' : 'Genre.original',
|
||||
// 'missing': 'N/A',
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// 'size': 0
|
||||
// }), {headers: this.headers})
|
||||
// .pipe(
|
||||
// map(res => res.aggregations.genres.value)
|
||||
// );
|
||||
// }
|
||||
|
||||
getLastAddedAlbums(month: number): Observable<Bucket[]> {
|
||||
return this.http
|
||||
.post(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
@@ -319,7 +294,7 @@ export class ElsService {
|
||||
'date' : {
|
||||
'terms': {
|
||||
'field' : 'Date Added',
|
||||
'order': { '_term': 'desc' },
|
||||
'order': { '_key': 'desc' },
|
||||
'size': 20
|
||||
},
|
||||
'aggs': {
|
||||
@@ -339,7 +314,7 @@ export class ElsService {
|
||||
// TODO Take in consideration "sum_other_doc_count"
|
||||
}
|
||||
|
||||
getArtistFromAlbumName(albumname: string): Observable<Album[]> {
|
||||
getArtistFromAlbumName(albumname: string): Observable<Album[]> { // TODO Rename ?
|
||||
return this.http
|
||||
.post<any>(this.elsUrl + ElsService.ALBUM_INDEX_NAME + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify({
|
||||
@@ -363,26 +338,6 @@ export class ElsService {
|
||||
);
|
||||
}
|
||||
|
||||
getCountArtistSong(artistName: string): Observable<number> {
|
||||
console.log('artistname: ' + artistName);
|
||||
return this.http
|
||||
.post<any>(this.elsUrl + ElsService.SONG_INDEX_NAME + ElsService.ACTION_COUNT,
|
||||
JSON.stringify({
|
||||
'query': {
|
||||
'bool': {
|
||||
'should': [
|
||||
{'match_phrase' : { 'Album Artist' : artistName }},
|
||||
{'match_phrase' : { 'Artist' : artistName }}
|
||||
]
|
||||
}
|
||||
}
|
||||
}), {headers: this.headers})
|
||||
.pipe(
|
||||
map(res => res.count as number),
|
||||
catchError(error => this.handleError(error, 'getCountArtistSong' + artistName + ')'))
|
||||
);
|
||||
}
|
||||
|
||||
getSuggest(text: string): Observable<Suggested[]> {
|
||||
console.log('search sugget: ' + text);
|
||||
return this.http
|
||||
@@ -418,7 +373,7 @@ export class ElsService {
|
||||
* @param res Response to process
|
||||
* @param name The searched name - for console output
|
||||
*/
|
||||
private responseToOneTypedResult<T>(res: any, name: string): T {
|
||||
protected responseToOneTypedResult<T>(res: any, name: string): T {
|
||||
const hits = res.hits.hits;
|
||||
|
||||
if (hits.length < 1) {
|
||||
@@ -436,7 +391,7 @@ export class ElsService {
|
||||
*
|
||||
* @param res Response to process
|
||||
*/
|
||||
private responseToSongs(res: any): Song[] {
|
||||
protected responseToSongs(res: any): Song[] {
|
||||
const result: Array<Song> = [];
|
||||
res.hits.hits.forEach((hit) => {
|
||||
result.push(hit._source);
|
||||
@@ -474,7 +429,7 @@ export class ElsService {
|
||||
* @param res Response to process
|
||||
* @param name Name of aggregation
|
||||
*/
|
||||
private responseAggregationToBucket(res: any, name: string): Bucket[] {
|
||||
protected responseAggregationToBucket(res: any, name: string): Bucket[] {
|
||||
const result: Array<Bucket> = [];
|
||||
res.aggregations[name].buckets.forEach((bucket) => {
|
||||
result.push(bucket);
|
||||
@@ -513,4 +468,13 @@ export class ElsService {
|
||||
console.error(error); // for demo purposes only
|
||||
return Promise.reject(error.message || error);
|
||||
}
|
||||
|
||||
protected addSortFilterToQuery(query) {
|
||||
query.query.bool.must_not.push({
|
||||
term: {
|
||||
"Location.tree": this.defaultLocation,
|
||||
},
|
||||
});
|
||||
return query;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
|
||||
import { ElsService } from '../els.service';
|
||||
import { ElsService } from '../els-service/els.service';
|
||||
import { SongTableComponent } from '../song-table/song-table.component';
|
||||
|
||||
import { Song } from '../model/song';
|
||||
|
||||
38
dashboard/src/app/to-sort/to-sort.component.css
Normal file
38
dashboard/src/app/to-sort/to-sort.component.css
Normal file
@@ -0,0 +1,38 @@
|
||||
.panel-stat {
|
||||
min-height: 102px;
|
||||
}
|
||||
|
||||
.panel-green {
|
||||
background-color: #16a085;
|
||||
color:white;
|
||||
}
|
||||
.panel-yellow {
|
||||
background-color: #f1c40f;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.panel-red {
|
||||
background-color: #d9534f;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.panel-purple {
|
||||
background-color: #9b59b6;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.panel-blue {
|
||||
background-color: #3498db;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.stats_icon {
|
||||
font-size: 3em;
|
||||
}
|
||||
|
||||
.circle {
|
||||
border-radius: 50%;
|
||||
background-color: #9b59b6;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
132
dashboard/src/app/to-sort/to-sort.component.html
Normal file
132
dashboard/src/app/to-sort/to-sort.component.html
Normal file
@@ -0,0 +1,132 @@
|
||||
<div class="container">
|
||||
<h1>To sort Songs - </h1>
|
||||
|
||||
<br />
|
||||
<div class="row cardAdmin">
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-yellow">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-xs-3">
|
||||
<span class="glyphicon glyphicon-play stats_icon"></span>
|
||||
</div>
|
||||
<div class="col-xs-9 text-right">
|
||||
<div>
|
||||
<h3 *ngIf="!trackCountSong"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="trackCountSong">{{trackCountSong}} songs</h3>
|
||||
</div>
|
||||
<div>Total songs
|
||||
<br>~{{totalTime | convertMs}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-blue">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-xs-3">
|
||||
<span class="glyphicon glyphicon-cd stats_icon"></span>
|
||||
</div>
|
||||
<div class="col-xs-9 text-right">
|
||||
<div>
|
||||
<h3 *ngIf="!neverListenSong"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="neverListenSong">{{nbAlbums}}</h3>
|
||||
</div>
|
||||
<div><br>Albums</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-green">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-xs-3">
|
||||
<span class="glyphicon glyphicon-hdd stats_icon"></span>
|
||||
</div>
|
||||
<div class="col-xs-9 text-right">
|
||||
<div>
|
||||
<h3 *ngIf="!totalSize"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="totalSize">{{totalSize | convertSizeToString}}</h3>
|
||||
</div>
|
||||
<div><br>Total size</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-red">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-xs-3">
|
||||
<span class="glyphicon glyphicon-stop stats_icon"></span>
|
||||
</div>
|
||||
<div class="col-xs-9 text-right">
|
||||
<div>
|
||||
<h3 *ngIf="!neverListenSong"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="neverListenSong">{{neverListenSong}}</h3>
|
||||
</div>
|
||||
<div><br>Never list. songs (~{{neverListenSong / trackCountSong * 100 | round}}%)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<table class="table table-striped" style="white-space: nowrap;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Album</th>
|
||||
<th>Track Count</th>
|
||||
<th>Artist/Album Artist</th>
|
||||
<th>Play Count</th>
|
||||
<th>Rating</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let album of albums">
|
||||
<td>
|
||||
<a [routerLink]="['/album', album.Name]" [queryParams]="{tosort: true}">{{album.Name}}</a>
|
||||
</td>
|
||||
|
||||
<td>{{album['Track Count']}}</td>
|
||||
|
||||
<ng-template [ngIf]="album['Album Artist']" [ngIfElse]="artistSection">
|
||||
<td>
|
||||
<a [routerLink]="['/artist', album['Album Artist']]" [queryParams]="{tosort: true}">{{album['Album Artist']}}</a>
|
||||
</td>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #artistSection>
|
||||
<td>
|
||||
<a [routerLink]="['/artist', album.Artist[0]]">{{album.Artist}}</a>
|
||||
</td>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #artistSection>
|
||||
<td>
|
||||
<a [routerLink]="['/artist', albums[album.key].Artist[0]]">{{albums[album.key].Artist}}</a>
|
||||
</td>
|
||||
</ng-template>
|
||||
|
||||
<td>
|
||||
{{album['Play Count']}} ({{album['Play Count']/album['Track Count'] | number:'1.0-0'}}/songs)
|
||||
</td>
|
||||
|
||||
<td class="star" [title]="(album['Album Rating Computed']?'Computed Rating: ':'Rating: ') + album['Album Rating']">
|
||||
<span *ngFor="let item of numberToArray(album['Album Rating'], 20)">
|
||||
<span class="glyphicon" [ngClass]="album['Album Rating Computed']?'glyphicon-star-empty':'glyphicon-star'"></span>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
25
dashboard/src/app/to-sort/to-sort.component.spec.ts
Normal file
25
dashboard/src/app/to-sort/to-sort.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ToSortComponent } from './to-sort.component';
|
||||
|
||||
describe('ToSortComponent', () => {
|
||||
let component: ToSortComponent;
|
||||
let fixture: ComponentFixture<ToSortComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ToSortComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ToSortComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
38
dashboard/src/app/to-sort/to-sort.component.ts
Normal file
38
dashboard/src/app/to-sort/to-sort.component.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ElsSortService } from '../els-service/els-sort.service';
|
||||
import { Bucket } from '../model/bucket';
|
||||
|
||||
import { Utils } from '../utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-to-sort',
|
||||
templateUrl: './to-sort.component.html',
|
||||
styleUrls: ['./to-sort.component.css']
|
||||
})
|
||||
export class ToSortComponent implements OnInit {
|
||||
numberToArray = Utils.numberToArray;
|
||||
// Stats var
|
||||
totalTime = 0;
|
||||
totalSize = 0;
|
||||
trackCountSong = 0;
|
||||
neverListenSong = 0;
|
||||
nbAlbums = 0;
|
||||
|
||||
// Global var
|
||||
toSortAlbum: Bucket[] = [];
|
||||
albums = []
|
||||
|
||||
constructor(private elsService: ElsSortService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
// **** GET STATS ****//
|
||||
this.elsService.getTime().then(result => this.totalTime = result);
|
||||
this.elsService.getSize().then(result => this.totalSize = result);
|
||||
this.elsService.getCountSong().then(result => this.trackCountSong = result);
|
||||
this.elsService.getCountNeverListenSong().then(result => this.neverListenSong = result);
|
||||
this.elsService.getNbAlbums().then(result => this.nbAlbums = result);
|
||||
|
||||
this.elsService.getAlbums().subscribe(data => this.albums = data)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { ElsService } from '../els.service';
|
||||
import { ElsService } from '../els-service/els.service';
|
||||
import { Album } from '../model/album';
|
||||
import { Artist } from '../model/artist';
|
||||
|
||||
|
||||
@@ -13,4 +13,4 @@ export const environment = {
|
||||
* This import should be commented out in production mode because it will have a negative impact
|
||||
* on performance if an error is thrown.
|
||||
*/
|
||||
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
||||
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
|
||||
|
||||
@@ -22,16 +22,6 @@ import '@angular/localize/init';
|
||||
* BROWSER POLYFILLS
|
||||
*/
|
||||
|
||||
/** IE11 requires the following for NgClass support on SVG elements */
|
||||
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
||||
|
||||
/**
|
||||
* Web Animations `@angular/platform-browser/animations`
|
||||
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||
*/
|
||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||
|
||||
/**
|
||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||
@@ -59,7 +49,7 @@ import '@angular/localize/init';
|
||||
/***************************************************************************************************
|
||||
* Zone JS is required by default for Angular itself.
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
import 'zone.js'; // Included with Angular CLI.
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import 'zone.js/testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
@@ -17,7 +17,9 @@ declare const require: {
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
platformBrowserDynamicTesting(), {
|
||||
teardown: { destroyAfterEach: false }
|
||||
}
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
|
||||
@@ -16,5 +16,8 @@
|
||||
"es2018",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,8 @@ class ITunesParser:
|
||||
'Avg Bit Rate': track['Bit Rate'],
|
||||
'Min Bit Rate': track['Bit Rate'],
|
||||
# 'Album Artist': '',
|
||||
'Total Time': 0
|
||||
'Total Time': 0,
|
||||
'Location': ''
|
||||
}
|
||||
|
||||
# Compute information
|
||||
@@ -207,6 +208,8 @@ class ITunesParser:
|
||||
self._albums[akey]['Play Count'] += play_count
|
||||
self._albums[akey]['Total Time'] += total_time
|
||||
|
||||
self._albums[akey]['Location'] = os.path.dirname(track['Location'])
|
||||
|
||||
if self._albums[akey]['Min Bit Rate'] > track['Bit Rate']:
|
||||
self._albums[akey]['Min Bit Rate'] = track['Bit Rate']
|
||||
|
||||
|
||||
@@ -1,4 +1,28 @@
|
||||
{
|
||||
"settings": {
|
||||
"analysis": {
|
||||
"analyzer": {
|
||||
"custom_path_tree": {
|
||||
"tokenizer": "custom_hierarchy"
|
||||
},
|
||||
"custom_path_tree_reversed": {
|
||||
"tokenizer": "custom_hierarchy_reversed"
|
||||
}
|
||||
},
|
||||
"tokenizer": {
|
||||
"custom_hierarchy": {
|
||||
"type": "path_hierarchy",
|
||||
"delimiter": "/",
|
||||
"skip": 3
|
||||
},
|
||||
"custom_hierarchy_reversed": {
|
||||
"type": "path_hierarchy",
|
||||
"delimiter": "/",
|
||||
"reverse": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mappings" : {
|
||||
"properties": {
|
||||
"Artist": {
|
||||
@@ -21,6 +45,19 @@
|
||||
},
|
||||
"Genre": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"Location": {
|
||||
"type": "text",
|
||||
"fields": {
|
||||
"tree": {
|
||||
"type": "text",
|
||||
"analyzer": "custom_path_tree"
|
||||
},
|
||||
"tree_reversed": {
|
||||
"type": "text",
|
||||
"analyzer": "custom_path_tree_reversed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
{
|
||||
"settings": {
|
||||
"analysis": {
|
||||
"analyzer": {
|
||||
"custom_path_tree": {
|
||||
"tokenizer": "custom_hierarchy"
|
||||
"analyzer": {
|
||||
"custom_path_tree": { "tokenizer": "custom_hierarchy" },
|
||||
"custom_path_tree_reversed": { "tokenizer": "custom_hierarchy_reversed" }
|
||||
},
|
||||
"custom_path_tree_reversed": {
|
||||
"tokenizer": "custom_hierarchy_reversed"
|
||||
"tokenizer": {
|
||||
"custom_hierarchy": {
|
||||
"type": "path_hierarchy",
|
||||
"delimiter": "/",
|
||||
"skip": 3
|
||||
},
|
||||
"custom_hierarchy_reversed": {
|
||||
"type": "path_hierarchy",
|
||||
"delimiter": "/",
|
||||
"reverse": "true"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tokenizer": {
|
||||
"custom_hierarchy": {
|
||||
"type": "path_hierarchy",
|
||||
"delimiter": "/",
|
||||
"skip": 3
|
||||
},
|
||||
"custom_hierarchy_reversed": {
|
||||
"type": "path_hierarchy",
|
||||
"delimiter": "/",
|
||||
"reverse": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
"mappings" : {
|
||||
"properties": {
|
||||
"Artist": {
|
||||
|
||||
Reference in New Issue
Block a user