diff --git a/dashboard/src/app/album/album.component.ts b/dashboard/src/app/album/album.component.ts
index 7a359d6..d60fdc5 100644
--- a/dashboard/src/app/album/album.component.ts
+++ b/dashboard/src/app/album/album.component.ts
@@ -1,11 +1,13 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
-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';
+import { TsService } from '../ts-service/ts.service';
+import { TsAlbumService } from '../ts-service/ts-album.service';
+
@Component({
selector: 'app-album',
templateUrl: './album.component.html',
@@ -25,7 +27,7 @@ export class AlbumComponent implements OnInit {
lockLoadData = false;
constructor(
- private elsService: ElsService,
+ private tsAlbumService: TsAlbumService,
private route: ActivatedRoute
) { }
@@ -35,7 +37,7 @@ export class AlbumComponent implements OnInit {
this.loadSongs();
- this.elsService.getAlbum(this.albumName).subscribe(data => this.album = data);
+ this.tsAlbumService.getAlbum(this.albumName).subscribe(data => this.album = data);
}
loadSongs(): void {
@@ -49,9 +51,9 @@ export class AlbumComponent implements OnInit {
}
this.lockLoadData = true;
- this.elsService.getAlbumSongs(this.albumName, this.songs.length, this.sortFilter).subscribe(
+ this.tsAlbumService.getAlbumSongs(this.albumName, this.songs.length, this.sortFilter).subscribe(
data => {
- this.moreDataAvailable = data.length === ElsService.DEFAULT_SIZE;
+ this.moreDataAvailable = data.length === TsService.DEFAULT_SIZE;
// 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
diff --git a/dashboard/src/app/albums/albums.component.ts b/dashboard/src/app/albums/albums.component.ts
index f10c20c..d3b9bdf 100644
--- a/dashboard/src/app/albums/albums.component.ts
+++ b/dashboard/src/app/albums/albums.component.ts
@@ -1,27 +1,28 @@
-import { Component, OnInit } from '@angular/core';
-import { ElsAlbumService } from '../els-service/els-album.service';
+import { Component, OnInit } from "@angular/core";
-import { Album } from '../model/album';
+import { Album } from "../model/album";
-import { Utils } from '../utils';
+import { Utils } from "../utils";
+
+import { TsAlbumService } from "../ts-service/ts-album.service";
enum query_edit_type {
- exclude = 'must_not',
- select = 'must'
+ exclude = "must_not",
+ select = "must",
}
@Component({
- selector: 'app-albums',
- templateUrl: './albums.component.html',
- styleUrls: ['./albums.component.css']
+ selector: "app-albums",
+ templateUrl: "./albums.component.html",
+ styleUrls: ["./albums.component.css"],
})
export class AlbumsComponent implements OnInit {
- numberToArray = Utils.numberToArray;
+ numberToArray = Utils.numberToArray; // For star representation
albums: Album[] = [];
- filterQuery = Object.assign({}, ElsAlbumService.GET_ALBUMS_DEFAULT_QUERY);
- queryEdited = false;
+ filterParams = TsAlbumService.GET_ALBUMS_DEFAULT_PARAMS();
+ queryEdited = false; // Show reset button if true
- constructor(private elsService : ElsAlbumService) { }
+ constructor(private tsService: TsAlbumService) {}
ngOnInit(): void {
this.loadData();
@@ -30,42 +31,47 @@ export class AlbumsComponent implements OnInit {
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]
+ value[field] = value[field][0];
}
- // If firt edit, add needed fields in ELS Query
- if (!this.filterQuery['query']) {
- this.filterQuery['query']['bool'][type].push({ 'must': [] })
- this.filterQuery['query']['bool'][type].push({ 'must_not': [] })
+ if (type == query_edit_type.exclude) {
+ // Filter can be cumulated
+ // TODO Specific treatment for array? https://typesense.org/docs/0.25.1/api/search.html#filter-parameters
+ this.filterParams = this.filterParams.append(
+ "filter_by",
+ field + ":!=`" + value[field] + "`"
+ );
}
-
- this.filterQuery['query']['bool'][type].push({
- 'match_phrase': {
- [field]: value[field]
- }
- })
-
+ if (type == query_edit_type.select) {
+ this.filterParams = this.filterParams
+ .delete("q")
+ .append("q", value[field])
+ .delete("query_by")
+ .append("query_by", field);
+ }
this.queryEdited = true;
}
exlude(field: string, value: Album): void {
- this.editQuery(field, value, query_edit_type.exclude)
- this.loadData()
+ this.editQuery(field, value, query_edit_type.exclude);
+ this.loadData();
}
select(field: string, value: Album): void {
- this.editQuery(field, value, query_edit_type.select)
- this.loadData()
+ this.editQuery(field, value, query_edit_type.select);
+ this.loadData();
}
resetQuery(): void {
- this.filterQuery = Object.assign({}, ElsAlbumService.GET_ALBUMS_DEFAULT_QUERY);
+ this.filterParams = TsAlbumService.GET_ALBUMS_DEFAULT_PARAMS();
this.loadData();
}
loadData(): void {
- // console.log(JSON.stringify(this.filterQuery))
- this.elsService.getAlbums(this.filterQuery).subscribe(data => this.albums = data);
+ console.log(this.filterParams.toString());
+ this.tsService
+ .getAlbums(this.filterParams)
+ .subscribe((data) => (this.albums = data));
}
}
diff --git a/dashboard/src/app/app.module.ts b/dashboard/src/app/app.module.ts
index c76632c..f652625 100644
--- a/dashboard/src/app/app.module.ts
+++ b/dashboard/src/app/app.module.ts
@@ -11,8 +11,9 @@ 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/els.service';
-import { ElsAlbumService } from './els-service/els-album.service';
+import { TsService } from './ts-service/ts.service';
+import { TsAlbumService } from './ts-service/ts-album.service';
+import { TsArtistService } from './ts-service/ts-artist.service';
import { AppRoutingModule } from './app-routing.module';
@@ -25,7 +26,6 @@ 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: [
@@ -52,9 +52,9 @@ import { ElsArtistService } from './els-service/els-artist.service';
ToSortComponent
],
providers: [
- ElsService,
- ElsAlbumService,
- ElsArtistService
+ TsService,
+ TsAlbumService,
+ TsArtistService
],
bootstrap: [ AppComponent ]
})
diff --git a/dashboard/src/app/artist/artist.component.ts b/dashboard/src/app/artist/artist.component.ts
index 9c3f53a..7a3675c 100644
--- a/dashboard/src/app/artist/artist.component.ts
+++ b/dashboard/src/app/artist/artist.component.ts
@@ -4,8 +4,9 @@ import { ActivatedRoute, Params } from '@angular/router';
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';
+
+import { TsService } from '../ts-service/ts.service';
+import { TsArtistService } from '../ts-service/ts-artist.service';
@Component({
selector: 'app-artist',
@@ -28,7 +29,7 @@ export class ArtistComponent implements OnInit {
toSortFilter: boolean = false; // Show only song to sort
constructor(
- private elsService: ElsArtistService,
+ private elsService: TsArtistService,
private route: ActivatedRoute,
) { }
@@ -63,7 +64,7 @@ export class ArtistComponent implements OnInit {
this.lockLoadData = true;
this.elsService.getArtistSongs(this.artistName, this.songs.length, this.toSortFilter).subscribe(
data => {
- this.moreDataAvailable = data.length === ElsService.DEFAULT_SIZE;
+ this.moreDataAvailable = data.length === TsService.DEFAULT_SIZE;
console.log(data.length)
console.log(this.moreDataAvailable)
diff --git a/dashboard/src/app/dashboard/dashboard.component.html b/dashboard/src/app/dashboard/dashboard.component.html
index 1d07c6b..984979f 100644
--- a/dashboard/src/app/dashboard/dashboard.component.html
+++ b/dashboard/src/app/dashboard/dashboard.component.html
@@ -82,7 +82,7 @@