(front) Albums: Add select button
Improve edit ELS Query method
This commit is contained in:
@@ -25,14 +25,16 @@
|
|||||||
<td>
|
<td>
|
||||||
<!-- {{album['Album Artist'] ? album['Album Artist'] : album.Artist}} -->
|
<!-- {{album['Album Artist'] ? album['Album Artist'] : album.Artist}} -->
|
||||||
<span *ngIf="album['Album Artist']; else artistSection">
|
<span *ngIf="album['Album Artist']; else artistSection">
|
||||||
<a [routerLink]="['/artist', album['Album Artist']]">{{album['Album Artist']}}</a>
|
|
||||||
<span class="glyphicon glyphicon-ban-circle" style="cursor:pointer" (click)="exlude('Album Artist', album)"></span>
|
<span class="glyphicon glyphicon-ban-circle" style="cursor:pointer" (click)="exlude('Album Artist', album)"></span>
|
||||||
|
<span class="glyphicon glyphicon-zoom-in" style="cursor:pointer" (click)="select('Album Artist', album)"></span>
|
||||||
|
<a [routerLink]="['/artist', album['Album Artist']]">{{album['Album Artist']}}</a>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<ng-template #artistSection>
|
<ng-template #artistSection>
|
||||||
<span>
|
<span>
|
||||||
<a [routerLink]="['/artist', album.Artist[0]]">{{album.Artist}}</a>
|
|
||||||
<span class="glyphicon glyphicon-ban-circle" style="cursor:pointer" (click)="exlude('Artist', album)"></span>
|
<span class="glyphicon glyphicon-ban-circle" style="cursor:pointer" (click)="exlude('Artist', album)"></span>
|
||||||
|
<span class="glyphicon glyphicon-zoom-in" style="cursor:pointer" (click)="select('Artist', album)"></span>
|
||||||
|
<a [routerLink]="['/artist', album.Artist[0]]">{{album.Artist}}</a>
|
||||||
</span>
|
</span>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ import { Album } from '../model/album';
|
|||||||
|
|
||||||
import { Utils } from '../utils';
|
import { Utils } from '../utils';
|
||||||
|
|
||||||
|
enum query_edit_type {
|
||||||
|
exclude = 'must_not',
|
||||||
|
select = 'must'
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-albums',
|
selector: 'app-albums',
|
||||||
templateUrl: './albums.component.html',
|
templateUrl: './albums.component.html',
|
||||||
@@ -21,34 +26,37 @@ export class AlbumsComponent implements OnInit {
|
|||||||
this.loadData();
|
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
|
// TODO Move this method to a service
|
||||||
if (value[field] instanceof Array) {
|
if (value[field] instanceof Array) {
|
||||||
value[field] = value[field][0]
|
value[field] = value[field][0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.filterQuery['query']) {
|
// If firt edit, add needed fields in ELS Query
|
||||||
this.filterQuery['query']['bool']['must_not'].push({
|
if (!this.filterQuery['query']) {
|
||||||
'match_phrase': {
|
|
||||||
[field]: value[field]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.filterQuery['query'] = {
|
this.filterQuery['query'] = {
|
||||||
'bool': {
|
'bool': {
|
||||||
'must': [],
|
'must': [],
|
||||||
'filter': [ { 'match_all': {} } ],
|
'must_not': []
|
||||||
'should': [],
|
|
||||||
'must_not': [
|
|
||||||
{
|
|
||||||
'match_phrase': {
|
|
||||||
[field]: value[field]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
this.loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user