Skip to content

Commit

Permalink
Issue #554
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-stastny committed Oct 19, 2024
1 parent e716b56 commit 79bf459
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import cz.inovatika.sdnnt.utils.MarcRecordFields;
import cz.inovatika.sdnnt.utils.NotificationUtils;
import cz.inovatika.sdnnt.utils.SearchResultsUtils;
import cz.inovatika.sdnnt.utils.StringUtils;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
Expand Down Expand Up @@ -104,18 +106,22 @@ public JSONObject facetSearch(HttpServletRequest req) {
User user = new UserControlerImpl(req).getUser();
String facetSearchField = req.getParameter("facetSearchField");
String facetSearchOffset = req.getParameter("facetSearchOffset");
return facetSearch(resmap, new ArrayList<>(), user, facetSearchField, facetSearchOffset);
String facetPrefix = req.getParameter("facetSearchPrefix");
return facetSearch(resmap, new ArrayList<>(), user, facetSearchField, facetSearchOffset,facetPrefix);
}


public JSONObject facetSearch(Map<String, List<String>> req, List<String> filters, User user, String facetField, String offset) {
public JSONObject facetSearch(Map<String, List<String>> req, List<String> filters, User user, String facetField, String offset, String facetPrefix) {
JSONObject ret = new JSONObject();
try {
SolrClient solr = Indexer.getClient();

SolrQuery query = doQuery(req, filters, user, (solrQuery)->{
solrQuery.setFacet(true).addFacetField(facetField);
solrQuery.setFacetMinCount(1);
if (StringUtils.isAnyString(facetPrefix)) {
solrQuery.setFacetPrefix(facetPrefix);
}
solrQuery.setParam(FacetParams.FACET_OFFSET, offset);
});

Expand Down
11 changes: 10 additions & 1 deletion sdnnt/src/main/ui/src/app/app.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ export class AppState {
this.currentLang = cfg.lang;
}


processParams(searchParams: ParamMap, url: string) {

let navigationKey = this.navigationstore.findKey(url);
let navigationKey = this.navigationstore.findKeyFromUrl(url);

this.usedFilters = [];

Expand Down Expand Up @@ -187,4 +188,12 @@ export class AppState {
this.loggedSubject.next(changed === this.logged);
}


isNavigationStoreKeyInitialized(key:string){
return this.navigationstore.contains(key);
}

initDefaultNavitionStoreKey(key:string) {
this.navigationstore.initDefault(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ <h1 mat-dialog-title>{{ 'desc.all_publishers' | translate }}</h1>
<h3>{{ 'desc.vybrano' | translate }}<strong>:&nbsp; {{ selectedFacetsNames }}</strong></h3>
</div>

<div>
<mat-form-field>
<input matInput placeholder="{{ 'desc.prefixsearch' | translate }}" (keyup)="onFilterByPrefixKeyUp($event.target)" />
</mat-form-field>
</div>


<div mat-dialog-content class="mat-dialog-content--scrollbar-fix">
<table class="app-table" cellpadding="0" cellspacing="0">
<tbody>
Expand All @@ -21,7 +28,6 @@ <h3>{{ 'desc.vybrano' | translate }}<strong>:&nbsp; {{ selectedFacetsNames }}</s


<div mat-dialog-actions>

<button mat-flat-button color="primary" (click)="applyAndClose()">{{ 'desc.vybrat' | translate }}</button>
<button mat-button mat-dialog-close cdkFocusInitial>{{ 'desc.zavrit' | translate }}</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { SolrResponse } from 'src/app/shared/solr-response';
import { DataDialogData } from '../dialog-identifier/dialog-identifier.component';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { AppState } from 'src/app/app.state';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';

@Component({
selector: 'app-dialog-all-publishers',
Expand All @@ -13,12 +15,17 @@ import { AppState } from 'src/app/app.state';
})
export class DialogAllPublishersComponent implements OnInit {

private subject: Subject<string> = new Subject();


visibleShowMoreButton:boolean = true;

facetSearchOffset=0;
facetFieldsInDialog:any;
selectedFacets: any[] = [];

searchTerm:string;

constructor(
public dialogRef: MatDialogRef<DialogAllPublishersComponent>,
@Inject(MAT_DIALOG_DATA) public data: DataDialogData,
Expand All @@ -28,15 +35,37 @@ export class DialogAllPublishersComponent implements OnInit {

ngOnInit(): void {

const p = Object.assign({}, this.data['queryParams'], {
let p = Object.assign({}, this.data['queryParams'], {
facetSearchField: 'nakladatel',
facetSearchOffset: this.facetSearchOffset
facetSearchOffset: this.facetSearchOffset,
...(this.searchTerm && { facetSearchPrefix: this.searchTerm })
});

this.service.facetSearch(p as HttpParams).subscribe((resp: SolrResponse) => {
this.facetFieldsInDialog = resp.facet_counts.facet_fields['nakladatel'];

});

this.subject.pipe(
debounceTime(600)
).subscribe(searchTextValue => {

this.searchTerm = searchTextValue;

const p = Object.assign({}, this.data['queryParams'], {
facetSearchField: 'nakladatel',
facetSearchOffset: this.facetSearchOffset,
...(this.searchTerm && { facetSearchPrefix: this.searchTerm })
});

this.service.facetSearch(p as HttpParams).subscribe((resp: SolrResponse) => {
this.facetFieldsInDialog = resp.facet_counts.facet_fields['nakladatel'];
});
});

}

onFilterByPrefixKeyUp(target) {
this.subject.next(target.value);
}

onCheckboxChange(facet: any, isChecked: boolean) {
Expand All @@ -63,7 +92,8 @@ export class DialogAllPublishersComponent implements OnInit {

const p = Object.assign({}, this.data['queryParams'], {
facetSearchField: 'nakladatel',
facetSearchOffset: this.facetSearchOffset
facetSearchOffset: this.facetSearchOffset,
...(this.searchTerm && { facetSearchPrefix: this.searchTerm })
});

this.service.facetSearch(p as HttpParams).subscribe((resp: SolrResponse) => {
Expand Down
3 changes: 2 additions & 1 deletion sdnnt/src/main/ui/src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,8 @@
"off_the_list": "Mimo seznam",
"all": "Vše",
"show_all": "Zobrazit vše",
"all_publishers": "Všichni nakladatelé"
"all_publishers": "Všichni nakladatelé",
"prefixsearch": "Vyhledávání dle prefixu"
},

"tooltip": {
Expand Down
4 changes: 3 additions & 1 deletion sdnnt/src/main/ui/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,9 @@
"off_the_list": "Off the list",
"all": "All",
"show_all": "Show all",
"all_publishers": "All publishers"
"all_publishers": "All publishers",
"prefixsearch": "Prefix search"

},

"tooltip": {
Expand Down

0 comments on commit 79bf459

Please sign in to comment.