fix search scores

This commit is contained in:
jonaswinkler 2021-04-03 21:50:05 +02:00
parent b7063b199a
commit be87caf7f6
2 changed files with 12 additions and 13 deletions

View File

@ -62,10 +62,6 @@
</div> </div>
<div class="list-group list-group-horizontal border-0 card-info ml-md-auto mt-2 mt-md-0"> <div class="list-group list-group-horizontal border-0 card-info ml-md-auto mt-2 mt-md-0">
<div *ngIf="document.__search_hit__" class="list-group-item bg-light text-dark p-1 mr-5 border-0 d-flex search-score">
<small class="text-muted" i18n>Score:</small>
<ngb-progressbar [type]="searchScoreClass" [value]="document.__search_hit__.score" class="search-score-bar mx-2 mt-1" [max]="1"></ngb-progressbar>
</div>
<button *ngIf="document.document_type" type="button" class="list-group-item btn btn-sm bg-light text-dark p-1 border-0 mr-2" title="Filter by document type" <button *ngIf="document.document_type" type="button" class="list-group-item btn btn-sm bg-light text-dark p-1 border-0 mr-2" title="Filter by document type"
(click)="clickDocumentType.emit(document.document_type);$event.stopPropagation()"> (click)="clickDocumentType.emit(document.document_type);$event.stopPropagation()">
<svg class="metadata-icon mr-2 text-muted bi bi-file-earmark" viewBox="0 0 16 16" fill="currentColor"> <svg class="metadata-icon mr-2 text-muted bi bi-file-earmark" viewBox="0 0 16 16" fill="currentColor">
@ -86,6 +82,10 @@
</svg> </svg>
<small>{{document.created | customDate:'mediumDate'}}</small> <small>{{document.created | customDate:'mediumDate'}}</small>
</div> </div>
<div *ngIf="document.__search_hit__" class="list-group-item bg-light text-dark border-0 d-flex search-score">
<small class="text-muted" i18n>Score:</small>
<ngb-progressbar [type]="searchScoreClass" [value]="document.__search_hit__.score" class="search-score-bar mx-2 mt-1" [max]="1"></ngb-progressbar>
</div>
</div> </div>
</div> </div>

View File

@ -41,21 +41,20 @@ export class DocumentCardLargeComponent implements OnInit {
@Output() @Output()
clickMoreLike= new EventEmitter() clickMoreLike= new EventEmitter()
@Input()
searchScore: number
@ViewChild('popover') popover: NgbPopover @ViewChild('popover') popover: NgbPopover
mouseOnPreview = false mouseOnPreview = false
popoverHidden = true popoverHidden = true
get searchScoreClass() { get searchScoreClass() {
if (this.searchScore > 0.7) { if (this.document.__search_hit__) {
return "success" if (this.document.__search_hit__.score > 0.7) {
} else if (this.searchScore > 0.3) { return "success"
return "warning" } else if (this.document.__search_hit__.score > 0.3) {
} else { return "warning"
return "danger" } else {
return "danger"
}
} }
} }