diff --git a/dashboard/src/app/albums/albums.component.html b/dashboard/src/app/albums/albums.component.html index 302392c..914eacf 100644 --- a/dashboard/src/app/albums/albums.component.html +++ b/dashboard/src/app/albums/albums.component.html @@ -25,14 +25,16 @@ - {{album['Album Artist']}}  + + {{album['Album Artist']}}  - {{album.Artist}}  + + {{album.Artist}}  diff --git a/dashboard/src/app/albums/albums.component.ts b/dashboard/src/app/albums/albums.component.ts index ac29c55..f9c3d05 100644 --- a/dashboard/src/app/albums/albums.component.ts +++ b/dashboard/src/app/albums/albums.component.ts @@ -5,6 +5,11 @@ import { Album } from '../model/album'; import { Utils } from '../utils'; +enum query_edit_type { + exclude = 'must_not', + select = 'must' +} + @Component({ selector: 'app-albums', templateUrl: './albums.component.html', @@ -21,34 +26,37 @@ export class AlbumsComponent implements OnInit { this.loadData(); } - exlude(field: string, value: string): void { + private editQuery(field: string, value: string, type: query_edit_type): void { // TODO Move this method to a service if (value[field] instanceof Array) { value[field] = value[field][0] } - if (this.filterQuery['query']) { - this.filterQuery['query']['bool']['must_not'].push({ - 'match_phrase': { - [field]: value[field] - } - }) - } else { + // If firt edit, add needed fields in ELS Query + if (!this.filterQuery['query']) { this.filterQuery['query'] = { 'bool': { 'must': [], - 'filter': [ { 'match_all': {} } ], - 'should': [], - 'must_not': [ - { - 'match_phrase': { - [field]: value[field] - } - } - ] + 'must_not': [] } } } + + + this.filterQuery['query']['bool'][type].push({ + 'match_phrase': { + [field]: value[field] + } + }) + } + + exlude(field: string, value: string): void { + this.editQuery(field, value, query_edit_type.exclude) + this.loadData() + } + + select(field: string, value: string): void { + this.editQuery(field, value, query_edit_type.select) this.loadData() }