diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java index a1d358a713..10dda38ffb 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java @@ -187,7 +187,8 @@ private QueryResponse querySolrServer(final SolrQuery query) throws RestServiceE } catch (IOException e) { throw new RestServiceException(e, new ErrorModel(500, "Error querying Solr")); } catch (SolrException | SolrServerException e) { - ErrorModel error = new ErrorModel(HttpStatus.UNPROCESSABLE_ENTITY.value(), "solr query failed"); + String errorMessage = e.getMessage().substring(e.getMessage().indexOf("shanoir") + 9); + ErrorModel error = new ErrorModel(HttpStatus.UNPROCESSABLE_ENTITY.value(), errorMessage); throw new RestServiceException(e, error); } return response; diff --git a/shanoir-ng-front/src/app/solr/solr.search.component.html b/shanoir-ng-front/src/app/solr/solr.search.component.html index 4436033a20..550d341af3 100644 --- a/shanoir-ng-front/src/app/solr/solr.search.component.html +++ b/shanoir-ng-front/src/app/solr/solr.search.component.html @@ -205,7 +205,8 @@

Solr Search

(onType)="syntaxError = false" (onChange)="refreshTable()" [syntaxError]="syntaxError" - [expertMode]="solrRequest.expertMode"> + [syntaxErrorMsg]="syntaxErrorMsg" + (expertModeChange)="setExpertMode($event)"> = new Set(); syntaxError: boolean = false; + syntaxErrorMsg : string = ""; dateOpen: boolean = false; importDateOpen: boolean = false; public downloadState: TaskState = new TaskState(); @@ -274,6 +275,10 @@ export class SolrSearchComponent implements AfterViewChecked, AfterContentInit { this.table.refresh(1); } + setExpertMode(value: boolean): void { + this.solrRequest.expertMode = value; + } + openResultTab() { this.tab = 'results'; } @@ -321,11 +326,13 @@ export class SolrSearchComponent implements AfterViewChecked, AfterContentInit { } this.firstPageLoaded = true; this.contentPage.push(solrResultPage); + this.syntaxErrorMsg = ""; return solrResultPage; }).catch(reason => { - if (reason?.error?.code == 422 && reason.error.message == 'solr query failed') { - this.syntaxError = true; + if (reason?.error?.code == 422) { + this.syntaxError = true; + this.syntaxErrorMsg = reason?.error?.message; return new SolrResultPage(); } else throw reason; }); diff --git a/shanoir-ng-front/src/app/solr/text-search/solr.text-search-mode.component.ts b/shanoir-ng-front/src/app/solr/text-search/solr.text-search-mode.component.ts index 3dd061c860..80baa4230d 100644 --- a/shanoir-ng-front/src/app/solr/text-search/solr.text-search-mode.component.ts +++ b/shanoir-ng-front/src/app/solr/text-search/solr.text-search-mode.component.ts @@ -2,12 +2,12 @@ * Shanoir NG - Import, manage and share neuroimaging data * Copyright (C) 2009-2019 Inria - https://www.inria.fr/ * Contact us on https://project.inria.fr/shanoir/ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ @@ -26,7 +26,7 @@ import { slideDown } from '../../shared/animations/animations'; provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => SolrTextSearchModeComponent), multi: true, - }] + }] }) export class SolrTextSearchModeComponent implements ControlValueAccessor { @@ -37,8 +37,16 @@ export class SolrTextSearchModeComponent implements ControlValueAccessor { protected propagateChange = (_: any) => {}; protected propagateTouched = () => {}; + ngOnChanges(changes: SimpleChanges): void { + if (changes['expertMode']) { + setTimeout(() => { + this.onExpertModeChange(); + }, 0); + } + } + onExpertModeChange() { - this.propagateChange(this.expertMode); + this.propagateChange(this.expertMode); } onExpertModeUserChange() { @@ -57,4 +65,4 @@ export class SolrTextSearchModeComponent implements ControlValueAccessor { registerOnTouched(fn: any): void { this.propagateTouched = fn; } -} \ No newline at end of file +} diff --git a/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.html b/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.html index 8f02dc352d..43fa9f88cb 100644 --- a/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.html +++ b/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.html @@ -13,7 +13,7 @@ -->
- + clear
-
syntax error
\ No newline at end of file +
{{syntaxErrorMsg}}
diff --git a/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts b/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts index 0ead179326..eaee95a055 100644 --- a/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts +++ b/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts @@ -2,18 +2,20 @@ * Shanoir NG - Import, manage and share neuroimaging data * Copyright (C) 2009-2019 Inria - https://www.inria.fr/ * Contact us on https://project.inria.fr/shanoir/ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ -import { Component, EventEmitter, forwardRef, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; +import {Component, EventEmitter, forwardRef, Input, OnChanges, Output, SimpleChanges, ViewChild} from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { slideDown } from '../../shared/animations/animations'; +import {TableComponent} from "../../shared/components/table/table.component"; +import {ToggleSwitchComponent} from "../../shared/switch/switch.component"; @Component({ @@ -26,23 +28,32 @@ import { slideDown } from '../../shared/animations/animations'; provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => SolrTextSearchComponent), multi: true, - }] + }] }) export class SolrTextSearchComponent implements ControlValueAccessor { showInfo: boolean = false; searchText: string = ""; + searchKeyWords: string[] = ["centerName", "datasetCreationDate", "studyName", "subjectName", "subjectType", "acquisitionEquipmentName", "datasetId", "datasetName", "datasetNature", "datasetType", "processed", "examinationComment", "examinationDate", "importDate", "tags", "magneticFieldStrength", "pixelBandwidth", "sliceThickness", "studyId"]; @Output() onChange: EventEmitter = new EventEmitter(); @Output() onType: EventEmitter = new EventEmitter(); + @Output() expertModeChange: EventEmitter = new EventEmitter(); @Input() syntaxError: boolean = false; - @Input() expertMode: boolean = false; + @Input() syntaxErrorMsg: string; + expertMode: boolean = false; protected propagateChange = (_: any) => {}; protected propagateTouched = () => {}; + inputTextChange() { + if (this.searchKeyWords.some(word => this.searchText.includes(word))) { + this.expertModeChange.emit(true); + } + } + onChangeSearch() { if (!this.syntaxError) { - this.propagateChange(this.searchText); + this.propagateChange(this.searchText); this.onChange.emit(this.searchText); } } @@ -68,4 +79,4 @@ export class SolrTextSearchComponent implements ControlValueAccessor { registerOnTouched(fn: any): void { this.propagateTouched = fn; } -} \ No newline at end of file +}