From 39e571189f1735f8d7dc6f00d6e4c2855f153ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Agneray?= <francois.agneray@lam.fr> Date: Mon, 16 May 2022 22:12:51 +0200 Subject: [PATCH] Refactor search types => WIP --- client/src/app/instance/instance.reducer.ts | 3 - .../criteria/criteria-by-family.component.ts | 5 +- .../criteria/criteria-tabs.component.html | 3 - .../criteria/criteria-tabs.component.ts | 3 - .../criteria/criterion.component.ts | 89 ++----------------- .../search-type/between-date.component.html | 4 +- .../search-type/between.component.html | 6 +- .../search-type/checkbox.component.html | 2 +- .../search-type/datalist.component.html | 2 +- .../criteria/search-type/date.component.html | 2 +- .../search-type/datetime.component.html | 2 +- .../criteria/search-type/field.component.html | 2 +- .../components/criteria/search-type/index.ts | 74 ++++++++++++++- .../criteria/search-type/json.component.html | 2 +- .../criteria/search-type/list.component.html | 2 +- .../criteria/search-type/radio.component.html | 2 +- .../select-multiple.component.html | 2 +- .../search-type/select.component.html | 2 +- .../search-type/svom-json-kw.component.html | 2 +- .../search-type/svom-json-kw.component.ts | 39 +++++++- .../criteria/search-type/time.component.html | 2 +- .../search/containers/criteria.component.html | 3 - .../search/containers/criteria.component.ts | 12 --- .../store/actions/svom-json-kw.actions.ts | 18 ---- .../src/app/instance/store/effects/index.ts | 2 - .../effects/svom-json-kw.effects.spec.ts | 44 --------- .../store/effects/svom-json-kw.effects.ts | 71 --------------- .../reducers/svom-json-kw.reducer.spec.ts | 82 ----------------- .../store/reducers/svom-json-kw.reducer.ts | 64 ------------- .../selectors/svom-json-kw.selector.spec.ts | 24 ----- .../store/selectors/svom-json-kw.selector.ts | 38 -------- .../src/app/instance/store/services/index.ts | 2 - .../services/svom-json-kw.service.spec.ts | 48 ---------- .../store/services/svom-json-kw.service.ts | 39 -------- 34 files changed, 136 insertions(+), 561 deletions(-) delete mode 100644 client/src/app/instance/store/actions/svom-json-kw.actions.ts delete mode 100644 client/src/app/instance/store/effects/svom-json-kw.effects.spec.ts delete mode 100644 client/src/app/instance/store/effects/svom-json-kw.effects.ts delete mode 100644 client/src/app/instance/store/reducers/svom-json-kw.reducer.spec.ts delete mode 100644 client/src/app/instance/store/reducers/svom-json-kw.reducer.ts delete mode 100644 client/src/app/instance/store/selectors/svom-json-kw.selector.spec.ts delete mode 100644 client/src/app/instance/store/selectors/svom-json-kw.selector.ts delete mode 100644 client/src/app/instance/store/services/svom-json-kw.service.spec.ts delete mode 100644 client/src/app/instance/store/services/svom-json-kw.service.ts diff --git a/client/src/app/instance/instance.reducer.ts b/client/src/app/instance/instance.reducer.ts index be6b9a59..d80f4abc 100644 --- a/client/src/app/instance/instance.reducer.ts +++ b/client/src/app/instance/instance.reducer.ts @@ -14,7 +14,6 @@ import * as search from './store/reducers/search.reducer'; import * as searchMultiple from './store/reducers/search-multiple.reducer'; import * as coneSearch from './store/reducers/cone-search.reducer'; import * as detail from './store/reducers/detail.reducer'; -import * as svomJsonKw from './store/reducers/svom-json-kw.reducer'; import * as archive from './store/reducers/archive.reducer'; /** @@ -27,7 +26,6 @@ export interface State { searchMultiple: searchMultiple.State, coneSearch: coneSearch.State detail: detail.State, - svomJsonKw: svomJsonKw.State, archive: archive.State } @@ -36,7 +34,6 @@ const reducers = { searchMultiple: searchMultiple.searchMultipleReducer, coneSearch: coneSearch.coneSearchReducer, detail: detail.detailReducer, - svomJsonKw: svomJsonKw.svomJsonKwReducer, archive: archive.archiveReducer }; diff --git a/client/src/app/instance/search/components/criteria/criteria-by-family.component.ts b/client/src/app/instance/search/components/criteria/criteria-by-family.component.ts index c7204f8e..edc3ae5c 100644 --- a/client/src/app/instance/search/components/criteria/criteria-by-family.component.ts +++ b/client/src/app/instance/search/components/criteria/criteria-by-family.component.ts @@ -9,7 +9,7 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; -import { Criterion, SvomKeyword } from 'src/app/instance/store/models'; +import { Criterion } from 'src/app/instance/store/models'; import { Attribute, Option } from 'src/app/metamodel/models'; /** @@ -24,9 +24,6 @@ import { Attribute, Option } from 'src/app/metamodel/models'; export class CriteriaByFamilyComponent { @Input() attributeList: Attribute[]; @Input() criteriaList: Criterion[]; - @Input() svomKeywords: SvomKeyword[]; - @Output() selectSvomAcronym: EventEmitter<string> = new EventEmitter(); - @Output() resetSvomKeywords: EventEmitter<{}> = new EventEmitter(); @Output() addCriterion: EventEmitter<Criterion> = new EventEmitter(); @Output() deleteCriterion: EventEmitter<number> = new EventEmitter(); diff --git a/client/src/app/instance/search/components/criteria/criteria-tabs.component.html b/client/src/app/instance/search/components/criteria/criteria-tabs.component.html index d659ea65..fa9d3aef 100644 --- a/client/src/app/instance/search/components/criteria/criteria-tabs.component.html +++ b/client/src/app/instance/search/components/criteria/criteria-tabs.component.html @@ -16,9 +16,6 @@ <app-criteria-by-family [attributeList]="attributeList | attributeListByFamily:family.id" [criteriaList]="criteriaList" - [svomKeywords]="svomKeywords" - (selectSvomAcronym)="selectSvomAcronym.emit($event)" - (resetSvomKeywords)="resetSvomKeywords.emit()" (addCriterion)="emitAdd($event)" (deleteCriterion)="emitDelete($event)"> </app-criteria-by-family> diff --git a/client/src/app/instance/search/components/criteria/criteria-tabs.component.ts b/client/src/app/instance/search/components/criteria/criteria-tabs.component.ts index 7ed5b94d..f781372a 100644 --- a/client/src/app/instance/search/components/criteria/criteria-tabs.component.ts +++ b/client/src/app/instance/search/components/criteria/criteria-tabs.component.ts @@ -25,9 +25,6 @@ export class CriteriaTabsComponent { @Input() attributeList: Attribute[]; @Input() criteriaFamilyList: CriteriaFamily[]; @Input() criteriaList: Criterion[]; - @Input() svomKeywords: SvomKeyword[]; - @Output() selectSvomAcronym: EventEmitter<string> = new EventEmitter(); - @Output() resetSvomKeywords: EventEmitter<{}> = new EventEmitter(); @Output() addCriterion: EventEmitter<Criterion> = new EventEmitter(); @Output() deleteCriterion: EventEmitter<number> = new EventEmitter(); diff --git a/client/src/app/instance/search/components/criteria/criterion.component.ts b/client/src/app/instance/search/components/criteria/criterion.component.ts index 6145ccb5..c2c9c0ff 100644 --- a/client/src/app/instance/search/components/criteria/criterion.component.ts +++ b/client/src/app/instance/search/components/criteria/criterion.component.ts @@ -11,21 +11,7 @@ import { Component, Input, Output, EventEmitter, ViewChild, SimpleChanges, OnIni import { Attribute } from 'src/app/metamodel/models'; import { Criterion } from 'src/app/instance/store/models'; -import { SearchTypeLoaderDirective } from './search-type/search-type-loader.directive'; -import { AbstractSearchTypeComponent } from './search-type/abstract-search-type.component'; -import { FieldComponent } from './search-type/field.component'; -import { BetweenComponent } from './search-type/between.component'; -import { SelectComponent } from './search-type/select.component'; -import { SelectMultipleComponent } from './search-type/select-multiple.component'; -import { DatalistComponent } from './search-type/datalist.component'; -import { ListComponent } from './search-type/list.component'; -import { RadioComponent } from './search-type/radio.component'; -import { CheckboxComponent } from './search-type/checkbox.component'; -import { BetweenDateComponent } from './search-type/between-date.component'; -import { DateComponent } from './search-type/date.component'; -import { TimeComponent } from './search-type/time.component'; -import { DateTimeComponent } from './search-type/datetime.component'; -import { JsonComponent } from './search-type/json.component'; +import { SearchTypeLoaderDirective, AbstractSearchTypeComponent, getSearchTypeComponent } from './search-type'; @Component({ selector: 'app-criterion', @@ -43,8 +29,10 @@ export class CriterionComponent implements OnInit, OnChanges { public searchTypeComponent: AbstractSearchTypeComponent; ngOnInit() { - const componentRef = this.SearchTypeLoaderDirective.viewContainerRef.createComponent<AbstractSearchTypeComponent>(this.getSearchTypeComponent()); - console.log(componentRef.instance); + const viewContainerRef = this.SearchTypeLoaderDirective.viewContainerRef; + const componentRef = viewContainerRef.createComponent<AbstractSearchTypeComponent>( + getSearchTypeComponent(this.attribute.search_type) + ); componentRef.instance.setAttribute(this.attribute); componentRef.instance.setCriterion(this.criterion); componentRef.instance.setCriteriaList(this.criteriaList); @@ -55,6 +43,10 @@ export class CriterionComponent implements OnInit, OnChanges { if (changes.criterion && !changes.criterion.firstChange) { this.searchTypeComponent.setCriterion(changes.criterion.currentValue); } + + if (changes.criteriaList && !changes.criteriaList.firstChange) { + this.searchTypeComponent.setCriteriaList(changes.criteriaList.currentValue); + } } /** @@ -65,67 +57,4 @@ export class CriterionComponent implements OnInit, OnChanges { emitAdd(): void { this.addCriterion.emit(this.searchTypeComponent.getCriterion()); } - - getSearchTypeComponent() { - let nameOfSearchTypeComponent = null; - switch(this.attribute.search_type) { - case 'field': { - nameOfSearchTypeComponent = FieldComponent; - break; - } - case 'between': { - nameOfSearchTypeComponent = BetweenComponent; - break; - } - case 'select': { - nameOfSearchTypeComponent = SelectComponent; - break; - } - case 'select-multiple': { - nameOfSearchTypeComponent = SelectMultipleComponent; - break; - } - case 'datalist': { - nameOfSearchTypeComponent = DatalistComponent; - break; - } - case 'list': { - nameOfSearchTypeComponent = ListComponent; - break; - } - case 'radio': { - nameOfSearchTypeComponent = RadioComponent; - break; - } - case 'checkbox': { - nameOfSearchTypeComponent = CheckboxComponent; - break; - } - case 'between-date': { - nameOfSearchTypeComponent = BetweenDateComponent; - break; - } - case 'date': { - nameOfSearchTypeComponent = DateComponent; - break; - } - case 'time': { - nameOfSearchTypeComponent = TimeComponent; - break; - } - case 'date-time': { - nameOfSearchTypeComponent = DateTimeComponent; - break; - } - case 'json': { - nameOfSearchTypeComponent = JsonComponent; - break; - } - default: { - nameOfSearchTypeComponent = null; - break; - } - } - return nameOfSearchTypeComponent; - } } diff --git a/client/src/app/instance/search/components/criteria/search-type/between-date.component.html b/client/src/app/instance/search/components/criteria/search-type/between-date.component.html index a0f84914..776a39f6 100644 --- a/client/src/app/instance/search/components/criteria/search-type/between-date.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/between-date.component.html @@ -1,7 +1,7 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-sm-0"> - <div class="operator_readonly">bw</div> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> + <div class="operator_readonly">BW</div> </div> <div class="w-100 d-block d-sm-none"></div> <div class="col pl-sm-1"> diff --git a/client/src/app/instance/search/components/criteria/search-type/between.component.html b/client/src/app/instance/search/components/criteria/search-type/between.component.html index ae9e68b6..d48fcb25 100644 --- a/client/src/app/instance/search/components/criteria/search-type/between.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/between.component.html @@ -1,7 +1,7 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-3 col-lg-auto pr-sm-1 mb-1 mb-lg-0"> - <div class="operator_readonly">min</div> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> + <div class="operator_readonly">Min</div> </div> <div class="w-100 d-block d-sm-none"></div> <div class="col pl-sm-1 mb-1 mb-sm-0"> @@ -9,7 +9,7 @@ </div> <div class="w-100 d-block d-lg-none"></div> <div class="col col-sm-3 col-lg-auto pr-sm-1 mb-1"> - <div class="operator_readonly">max</div> + <div class="operator_readonly">Max</div> </div> <div class="w-100 d-block d-sm-none"></div> <div class="col pl-sm-1"> diff --git a/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html b/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html index 9cae6f77..936cd878 100644 --- a/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/checkbox.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-lg-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <div class="operator_readonly">in</div> </div> <div class="w-100 d-block d-sm-none"></div> diff --git a/client/src/app/instance/search/components/criteria/search-type/datalist.component.html b/client/src/app/instance/search/components/criteria/search-type/datalist.component.html index 4af8b445..e0f39d83 100644 --- a/client/src/app/instance/search/components/criteria/search-type/datalist.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/datalist.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-sm-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/date.component.html b/client/src/app/instance/search/components/criteria/search-type/date.component.html index 8c2b7950..557801aa 100644 --- a/client/src/app/instance/search/components/criteria/search-type/date.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/date.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-sm-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/datetime.component.html b/client/src/app/instance/search/components/criteria/search-type/datetime.component.html index c199416c..45437cf8 100644 --- a/client/src/app/instance/search/components/criteria/search-type/datetime.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/datetime.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-lg-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/field.component.html b/client/src/app/instance/search/components/criteria/search-type/field.component.html index 84260fca..9d878f52 100644 --- a/client/src/app/instance/search/components/criteria/search-type/field.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/field.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-sm-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/index.ts b/client/src/app/instance/search/components/criteria/search-type/index.ts index 7150b01b..86a6b793 100644 --- a/client/src/app/instance/search/components/criteria/search-type/index.ts +++ b/client/src/app/instance/search/components/criteria/search-type/index.ts @@ -12,6 +12,10 @@ import { DateComponent } from './date.component'; import { TimeComponent } from './time.component'; import { DateTimeComponent } from './datetime.component'; import { JsonComponent }Â from './json.component'; +import { SvomJsonKwComponent } from './svom-json-kw.component'; + +export * from './abstract-search-type.component'; +export * from './search-type-loader.directive'; export const searchTypeComponents = [ SearchTypeLoaderDirective, @@ -27,5 +31,73 @@ export const searchTypeComponents = [ DateComponent, TimeComponent, DateTimeComponent, - JsonComponent + JsonComponent, + SvomJsonKwComponent ]; + +export const getSearchTypeComponent = (searchType: string) => { + let nameOfSearchTypeComponent = null; + switch(searchType) { + case 'field': { + nameOfSearchTypeComponent = FieldComponent; + break; + } + case 'between': { + nameOfSearchTypeComponent = BetweenComponent; + break; + } + case 'select': { + nameOfSearchTypeComponent = SelectComponent; + break; + } + case 'select-multiple': { + nameOfSearchTypeComponent = SelectMultipleComponent; + break; + } + case 'datalist': { + nameOfSearchTypeComponent = DatalistComponent; + break; + } + case 'list': { + nameOfSearchTypeComponent = ListComponent; + break; + } + case 'radio': { + nameOfSearchTypeComponent = RadioComponent; + break; + } + case 'checkbox': { + nameOfSearchTypeComponent = CheckboxComponent; + break; + } + case 'between-date': { + nameOfSearchTypeComponent = BetweenDateComponent; + break; + } + case 'date': { + nameOfSearchTypeComponent = DateComponent; + break; + } + case 'time': { + nameOfSearchTypeComponent = TimeComponent; + break; + } + case 'date-time': { + nameOfSearchTypeComponent = DateTimeComponent; + break; + } + case 'json': { + nameOfSearchTypeComponent = JsonComponent; + break; + } + case 'svom_json_kw': { + nameOfSearchTypeComponent = SvomJsonKwComponent; + break; + } + default: { + nameOfSearchTypeComponent = null; + break; + } + } + return nameOfSearchTypeComponent; +} diff --git a/client/src/app/instance/search/components/criteria/search-type/json.component.html b/client/src/app/instance/search/components/criteria/search-type/json.component.html index 4a3923a1..0c9b7b95 100644 --- a/client/src/app/instance/search/components/criteria/search-type/json.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/json.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-lg-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <div class="operator_readonly">json</div> </div> <div class="w-100 d-block d-sm-none"></div> diff --git a/client/src/app/instance/search/components/criteria/search-type/list.component.html b/client/src/app/instance/search/components/criteria/search-type/list.component.html index 259c3bd6..49e1f5f3 100644 --- a/client/src/app/instance/search/components/criteria/search-type/list.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/list.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-lg-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <div class="operator_readonly">=</div> </div> <div class="w-100 d-block d-sm-none"></div> diff --git a/client/src/app/instance/search/components/criteria/search-type/radio.component.html b/client/src/app/instance/search/components/criteria/search-type/radio.component.html index 77994fdb..3ace3b9b 100644 --- a/client/src/app/instance/search/components/criteria/search-type/radio.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/radio.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-sm-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/select-multiple.component.html b/client/src/app/instance/search/components/criteria/search-type/select-multiple.component.html index 48de3a3d..da9f1531 100644 --- a/client/src/app/instance/search/components/criteria/search-type/select-multiple.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/select-multiple.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-lg-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <div class="operator_readonly">in</div> </div> <div class="w-100 d-block d-sm-none"></div> diff --git a/client/src/app/instance/search/components/criteria/search-type/select.component.html b/client/src/app/instance/search/components/criteria/search-type/select.component.html index 3e74403c..e1d72d96 100644 --- a/client/src/app/instance/search/components/criteria/search-type/select.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/select.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-sm-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-sm-0"> <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> diff --git a/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.html b/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.html index 482a5029..07e277f1 100644 --- a/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-lg-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <div class="operator_readonly">json</div> </div> <div class="w-100 d-block d-sm-none"></div> diff --git a/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.ts b/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.ts index 6196a515..a0ec4f41 100644 --- a/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.ts +++ b/client/src/app/instance/search/components/criteria/search-type/svom-json-kw.component.ts @@ -1,15 +1,21 @@ -import { Component } from '@angular/core'; +import { Component, ChangeDetectorRef } from '@angular/core'; import { FormGroup, FormControl, Validators } from '@angular/forms'; +import { HttpClient } from '@angular/common/http'; + +import { map } from 'rxjs/operators'; import { AbstractSearchTypeComponent } from './abstract-search-type.component'; -import { Criterion, JsonCriterion } from 'src/app/instance/store/models'; +import { AppConfigService } from 'src/app/app-config.service'; +import { Criterion, FieldCriterion, JsonCriterion, SvomKeyword } from 'src/app/instance/store/models'; @Component({ selector: 'app-svom-json-kw', templateUrl: 'svom-json-kw.component.html' }) export class SvomJsonKwComponent extends AbstractSearchTypeComponent { - constructor() { + svomKeywords: SvomKeyword[] = []; + + constructor(private changeDetectorRef: ChangeDetectorRef, private http: HttpClient, private config: AppConfigService) { super(); this.form = new FormGroup({ path: new FormControl('', [Validators.required]), @@ -18,6 +24,23 @@ export class SvomJsonKwComponent extends AbstractSearchTypeComponent { }); } + setCriteriaList(criteriaList: Criterion[]): void { + super.setCriteriaList(criteriaList); + if (this.svomKeywords.length < 1 && criteriaList.find((c: Criterion) => c.id === 3)) { + const acronym = (criteriaList.find((c: Criterion) => c.id === 3) as FieldCriterion).value; + this.http.get<{search_kw: SvomKeyword[]}[]>(`${this.config.apiUrl}/search/sp_cards?a=8&c=1::eq::${acronym}`).pipe( + map(data => data[0].search_kw) + ).subscribe(svomKeywords => { + this.svomKeywords = svomKeywords; + this.changeDetectorRef.detectChanges(); + }); + } + + if (this.svomKeywords.length > 0 && !criteriaList.find((c: Criterion) => c.id === 3)) { + this.svomKeywords = []; + } + } + /** * Return new criterion * @@ -30,4 +53,14 @@ export class SvomJsonKwComponent extends AbstractSearchTypeComponent { ...this.form.value } as JsonCriterion; } + + /** + * Transform a SVOM json Keyword to as path value (anis json search) + * + * @param svomKeyword Keyword selected by user + * @returns string path value + */ + getKeywordValue(svomKeyword: SvomKeyword): string { + return `${svomKeyword.extension},${svomKeyword.name}` + } } diff --git a/client/src/app/instance/search/components/criteria/search-type/time.component.html b/client/src/app/instance/search/components/criteria/search-type/time.component.html index 4d940d45..4be22d32 100644 --- a/client/src/app/instance/search/components/criteria/search-type/time.component.html +++ b/client/src/app/instance/search/components/criteria/search-type/time.component.html @@ -1,6 +1,6 @@ <form [formGroup]="form" novalidate> <div class="row form-group"> - <div class="col col-sm-auto pr-sm-1 mb-1 mb-lg-0"> + <div class="col-md-3 col-sm-auto pr-sm-1 mb-1 mb-lg-0"> <select class="custom-select" formControlName="operator" (change)="operatorOnChange()"> <option *ngFor="let o of operators" [ngValue]="o.value">{{ o.label }}</option> </select> diff --git a/client/src/app/instance/search/containers/criteria.component.html b/client/src/app/instance/search/containers/criteria.component.html index 4562f36f..a9025abf 100644 --- a/client/src/app/instance/search/containers/criteria.component.html +++ b/client/src/app/instance/search/containers/criteria.component.html @@ -25,9 +25,6 @@ [attributeList]="attributeList | async | sortByCriteriaDisplay" [criteriaFamilyList]="criteriaFamilyList | async" [criteriaList]="criteriaList | async" - [svomKeywords]="svomKeywords | async" - (selectSvomAcronym)="selectSvomAcronym($event)" - (resetSvomKeywords)="resetSvomKeywords()" (addCriterion)="addCriterion($event)" (deleteCriterion)="deleteCriterion($event)"> </app-criteria-tabs> diff --git a/client/src/app/instance/search/containers/criteria.component.ts b/client/src/app/instance/search/containers/criteria.component.ts index 12508864..3735cba6 100644 --- a/client/src/app/instance/search/containers/criteria.component.ts +++ b/client/src/app/instance/search/containers/criteria.component.ts @@ -18,8 +18,6 @@ import { ConeSearch, Criterion, Resolver, SvomKeyword } from '../../store/models import * as searchActions from '../../store/actions/search.actions'; import * as coneSearchActions from '../../store/actions/cone-search.actions'; import * as coneSearchSelector from '../../store/selectors/cone-search.selector'; -import * as svomJsonKwActions from '../../store/actions/svom-json-kw.actions'; -import * as svomJsonKwSelector from '../../store/selectors/svom-json-kw.selector'; import * as coneSearchConfigActions from 'src/app/metamodel/actions/cone-search-config.actions'; import * as coneSearchConfigSelector from 'src/app/metamodel/selectors/cone-search-config.selector'; @@ -38,7 +36,6 @@ export class CriteriaComponent extends AbstractSearchComponent { public coneSearchConfig: Observable<ConeSearchConfig>; public coneSearchConfigIsLoading: Observable<boolean>; public coneSearchConfigIsLoaded: Observable<boolean>; - public svomKeywords: Observable<SvomKeyword[]>; constructor(protected store: Store<{ }>) { super(store); @@ -48,7 +45,6 @@ export class CriteriaComponent extends AbstractSearchComponent { this.coneSearchConfig = store.select(coneSearchConfigSelector.selectConeSearchConfig); this.coneSearchConfigIsLoading = store.select(coneSearchConfigSelector.selectConeSearchConfigIsLoading); this.coneSearchConfigIsLoaded = store.select(coneSearchConfigSelector.selectConeSearchConfigIsLoaded); - this.svomKeywords = this.store.select(svomJsonKwSelector.selectSvomKeywords); } ngOnInit(): void { @@ -102,12 +98,4 @@ export class CriteriaComponent extends AbstractSearchComponent { retrieveCoordinates(name: string): void { this.store.dispatch(coneSearchActions.retrieveCoordinates({ name })); } - - selectSvomAcronym(acronymSelected: string): void { - this.store.dispatch(svomJsonKwActions.selectAcronym({ acronymSelected })); - } - - resetSvomKeywords(): void { - Promise.resolve(null).then(() => this.store.dispatch(svomJsonKwActions.resetKw())); - } } diff --git a/client/src/app/instance/store/actions/svom-json-kw.actions.ts b/client/src/app/instance/store/actions/svom-json-kw.actions.ts deleted file mode 100644 index 4ce485e9..00000000 --- a/client/src/app/instance/store/actions/svom-json-kw.actions.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file is part of Anis Client. - * - * @copyright Laboratoire d'Astrophysique de Marseille / CNRS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { createAction, props } from '@ngrx/store'; - -import { SvomKeyword } from '../models'; - -export const resetKw = createAction('[SVOM Json Kw] Reset Kw'); -export const selectAcronym = createAction('[SVOM Json Kw] Select Acronym', props<{ acronymSelected: string }>()); -export const loadKwSearchable = createAction('[SVOM Json Kw] Load Kw Searchable'); -export const loadKwSearchableSuccess = createAction('[SVOM Json Kw] Load Kw Searchable Success', props<{ svomKeywords: SvomKeyword[] }>()); -export const loadKwSearchableFail = createAction('[SVOM Json Kw] Load Kw Searchable Fail'); \ No newline at end of file diff --git a/client/src/app/instance/store/effects/index.ts b/client/src/app/instance/store/effects/index.ts index 54904d02..b5889872 100644 --- a/client/src/app/instance/store/effects/index.ts +++ b/client/src/app/instance/store/effects/index.ts @@ -2,7 +2,6 @@ import { SearchEffects } from './search.effects'; import { SearchMultipleEffects } from './search-multiple.effects'; import { ConeSearchEffects } from './cone-search.effects'; import { DetailEffects } from './detail.effects'; -import { SvomJsonKwEffects } from './svom-json-kw.effects'; import { ArchiveEffects } from './archive.effects'; export const instanceEffects = [ @@ -10,6 +9,5 @@ export const instanceEffects = [ SearchMultipleEffects, ConeSearchEffects, DetailEffects, - SvomJsonKwEffects, ArchiveEffects ]; diff --git a/client/src/app/instance/store/effects/svom-json-kw.effects.spec.ts b/client/src/app/instance/store/effects/svom-json-kw.effects.spec.ts deleted file mode 100644 index ed3ca655..00000000 --- a/client/src/app/instance/store/effects/svom-json-kw.effects.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { provideMockActions } from '@ngrx/effects/testing'; -import { EffectsMetadata, getEffectsMetadata } from '@ngrx/effects'; -import { provideMockStore } from '@ngrx/store/testing'; -import { Observable } from 'rxjs'; -import { ToastrService } from 'ngx-toastr'; - -import { SvomJsonKwEffects } from './svom-json-kw.effects'; -import { SvomJsonKwService } from '../services/svom-json-kw.service'; -import * as fromSvomJsonKw from '../reducers/svom-json-kw.reducer'; - -describe('[Instance][Store] SvomJsonKwEffects', () => { - let actions = new Observable(); - let effects: SvomJsonKwEffects; - let metadata: EffectsMetadata<SvomJsonKwEffects>; - let svomJsonKwService: SvomJsonKwService; - let toastr: ToastrService; - const initialState = { - instance: { - svomJsonKw: { ...fromSvomJsonKw.initialState } - } - }; - - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [ - SvomJsonKwEffects, - { provide: SvomJsonKwService, useValue: { loadKwSearchable: jest.fn() }}, - { provide: ToastrService, useValue: { success: jest.fn(), error: jest.fn() }}, - provideMockActions(() => actions), - provideMockStore({ initialState }) - ] - }).compileComponents(); - effects = TestBed.inject(SvomJsonKwEffects); - metadata = getEffectsMetadata(effects); - svomJsonKwService = TestBed.inject(SvomJsonKwService); - toastr = TestBed.inject(ToastrService); - }); - - it('should be created', () => { - expect(effects).toBeTruthy(); - }); -}); diff --git a/client/src/app/instance/store/effects/svom-json-kw.effects.ts b/client/src/app/instance/store/effects/svom-json-kw.effects.ts deleted file mode 100644 index 2a50a0ed..00000000 --- a/client/src/app/instance/store/effects/svom-json-kw.effects.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This file is part of Anis Client. - * - * @copyright Laboratoire d'Astrophysique de Marseille / CNRS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { Injectable } from '@angular/core'; - -import { Actions, createEffect, ofType, concatLatestFrom } from '@ngrx/effects'; -import { Store } from '@ngrx/store'; -import { of } from 'rxjs'; -import { map, tap, mergeMap, catchError } from 'rxjs/operators'; -import { ToastrService } from 'ngx-toastr'; - -import * as svomJsonKwActions from '../actions/svom-json-kw.actions'; -import * as svomJsonKwSelector from '../selectors/svom-json-kw.selector'; - -import { SvomJsonKwService } from '../services/svom-json-kw.service'; - -/** - * @class - * @classdesc Svom Json Kw effects. - */ -@Injectable() -export class SvomJsonKwEffects { - selectAcronym$ = createEffect((): any => - this.actions$.pipe( - ofType(svomJsonKwActions.selectAcronym), - map(() => svomJsonKwActions.loadKwSearchable()) - ) - ); - - loadKwSearchable$ = createEffect(() => - this.actions$.pipe( - ofType(svomJsonKwActions.loadKwSearchable), - concatLatestFrom(() => this.store.select(svomJsonKwSelector.selectAcronymSelected)), - mergeMap(([, acronymSelected]) => this.svomJsonKwService.loadKwSearchable(acronymSelected) - .pipe( - map(svomKeywords => svomJsonKwActions.loadKwSearchableSuccess({ svomKeywords })), - catchError(() => of(svomJsonKwActions.loadKwSearchableFail())) - ) - ) - ) - ); - - loadKwSearchableSuccess$ = createEffect(() => - this.actions$.pipe( - ofType(svomJsonKwActions.loadKwSearchableSuccess), - tap(() => { - this.toastr.success('SVOM Json Keywords was loaded successfully and are now available to product criteria', 'SVOM Json Keywords loaded') - }) - ), { dispatch: false} - ); - - addDatabaseFail$ = createEffect(() => - this.actions$.pipe( - ofType(svomJsonKwActions.loadKwSearchableFail), - tap(() => this.toastr.error('Failure to load Keywords', 'SVOM Json Keywords loaded failed')) - ), { dispatch: false} - ); - - constructor( - private actions$: Actions, - private store: Store<{ }>, - private svomJsonKwService: SvomJsonKwService, - private toastr: ToastrService - ) {} -} diff --git a/client/src/app/instance/store/reducers/svom-json-kw.reducer.spec.ts b/client/src/app/instance/store/reducers/svom-json-kw.reducer.spec.ts deleted file mode 100644 index b5c3ae74..00000000 --- a/client/src/app/instance/store/reducers/svom-json-kw.reducer.spec.ts +++ /dev/null @@ -1,82 +0,0 @@ -import * as fromSvomJsonKw from './svom-json-kw.reducer'; -import * as svomJsonKwActions from '../actions/svom-json-kw.actions'; - -describe('[Instance][Store] Svom Json Kw reducer', () => { - it('unknown action should return the default state', () => { - const { initialState } = fromSvomJsonKw; - const action = { type: 'Unknown' }; - const state = fromSvomJsonKw.svomJsonKwReducer(initialState, action); - - expect(state).toBe(initialState); - }); - - it('resetKw action should return the default state', () => { - const { initialState } = fromSvomJsonKw; - const action = svomJsonKwActions.resetKw(); - const state = fromSvomJsonKw.svomJsonKwReducer(initialState, action); - - expect(state).toEqual(initialState); - }); - - it('selectAcronym action should change the acronymSelected', () => { - const { initialState } = fromSvomJsonKw; - const action = svomJsonKwActions.selectAcronym({ acronymSelected: 'OBLC_ECL' }); - const state = fromSvomJsonKw.svomJsonKwReducer(initialState, action); - - expect(state.acronymSelected).toBe('OBLC_ECL'); - expect(state.svomKeywords).toEqual([]); - expect(state.svomKeywordsIsLoading).toBeFalsy(); - expect(state.svomKeywordsIsLoaded).toBeFalsy(); - expect(state).not.toBe(initialState); - }); - - it('loadKwSearchable action should change the svomKeywordsLoading and svomKeywordsLoaded', () => { - const { initialState } = fromSvomJsonKw; - const action = svomJsonKwActions.loadKwSearchable(); - const state = fromSvomJsonKw.svomJsonKwReducer(initialState, action); - - expect(state.acronymSelected).toBeNull(); - expect(state.svomKeywords).toEqual([]); - expect(state.svomKeywordsIsLoading).toBeTruthy(); - expect(state.svomKeywordsIsLoaded).toBeFalsy(); - expect(state).not.toBe(initialState); - }); - - it('loadKwSearchableSuccess action should change the svomKeywords, svomKeywordsLoading and svomKeywordsLoaded', () => { - const { initialState } = fromSvomJsonKw; - const svomKeywords = [ - { - data_type: 'string', - default: '', - extension: 'PrimaryHDU', - name: 'CARD' - }, - { - data_type: 'string', - default: '', - extension: 'PrimaryHDU', - name: 'TIME' - } - ]; - const action = svomJsonKwActions.loadKwSearchableSuccess({ svomKeywords }); - const state = fromSvomJsonKw.svomJsonKwReducer(initialState, action); - - expect(state.acronymSelected).toBeNull(); - expect(state.svomKeywords).toEqual(svomKeywords); - expect(state.svomKeywordsIsLoading).toBeFalsy(); - expect(state.svomKeywordsIsLoaded).toBeTruthy(); - expect(state).not.toBe(initialState); - }); - - it('loadKwSearchableFail action should change the svomKeywordsLoading and svomKeywordsLoaded', () => { - const { initialState } = fromSvomJsonKw; - const action = svomJsonKwActions.loadKwSearchableFail(); - const state = fromSvomJsonKw.svomJsonKwReducer(initialState, action); - - expect(state.acronymSelected).toBeNull(); - expect(state.svomKeywords).toEqual([]); - expect(state.svomKeywordsIsLoading).toBeFalsy(); - expect(state.svomKeywordsIsLoaded).toBeFalsy(); - expect(state).not.toBe(initialState); - }); -}); diff --git a/client/src/app/instance/store/reducers/svom-json-kw.reducer.ts b/client/src/app/instance/store/reducers/svom-json-kw.reducer.ts deleted file mode 100644 index 37c85260..00000000 --- a/client/src/app/instance/store/reducers/svom-json-kw.reducer.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * This file is part of Anis Client. - * - * @copyright Laboratoire d'Astrophysique de Marseille / CNRS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { createReducer, on } from '@ngrx/store'; - -import { SvomKeyword } from '../models'; -import * as svomJsonKwActions from '../actions/svom-json-kw.actions'; - -/** - * Interface for svom json kw state. - * - * @interface State - */ -export interface State { - acronymSelected: string; - svomKeywords: SvomKeyword[]; - svomKeywordsIsLoading: boolean; - svomKeywordsIsLoaded: boolean; -} - -export const initialState: State = { - acronymSelected: null, - svomKeywords: [], - svomKeywordsIsLoading: false, - svomKeywordsIsLoaded: false -}; - -export const svomJsonKwReducer = createReducer( - initialState, - on(svomJsonKwActions.resetKw, () => ({ - ...initialState - })), - on(svomJsonKwActions.selectAcronym, (state, { acronymSelected }) => ({ - ...state, - acronymSelected - })), - on(svomJsonKwActions.loadKwSearchable, (state) => ({ - ...state, - svomKeywordsIsLoading: true, - svomKeywordsIsLoaded: false - })), - on(svomJsonKwActions.loadKwSearchableSuccess, (state, { svomKeywords }) => ({ - ...state, - svomKeywords, - svomKeywordsIsLoading: false, - svomKeywordsIsLoaded: true - })), - on(svomJsonKwActions.loadKwSearchableFail, (state) => ({ - ...state, - svomKeywordsIsLoading: false, - svomKeywordsIsLoaded: false - })), -); - -export const selectAcronymSelected = (state: State) => state.acronymSelected; -export const selectSvomKeywords = (state: State) => state.svomKeywords; -export const selectSvomKeywordsIsLoading = (state: State) => state.svomKeywordsIsLoading; -export const selectSvomKeywordsIsLoaded = (state: State) => state.svomKeywordsIsLoaded; diff --git a/client/src/app/instance/store/selectors/svom-json-kw.selector.spec.ts b/client/src/app/instance/store/selectors/svom-json-kw.selector.spec.ts deleted file mode 100644 index e3e9604c..00000000 --- a/client/src/app/instance/store/selectors/svom-json-kw.selector.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as svomJsonKwSelector from './svom-json-kw.selector'; -import * as fromSvomJsonKw from '../reducers/svom-json-kw.reducer'; - -describe('[Instance][Store] Svom Json Kw selector', () => { - it('should get selectAcronymSelected', () => { - const state = { instance: { svomJsonKw: { ...fromSvomJsonKw.initialState }}}; - expect(svomJsonKwSelector.selectAcronymSelected(state)).toBeNull(); - }); - - it('should get selectSvomKeywords', () => { - const state = { instance: { svomJsonKw: { ...fromSvomJsonKw.initialState }}}; - expect(svomJsonKwSelector.selectSvomKeywords(state)).toEqual([]); - }); - - it('should get selectSvomKeywordsIsLoading', () => { - const state = { instance: { svomJsonKw: { ...fromSvomJsonKw.initialState }}}; - expect(svomJsonKwSelector.selectSvomKeywordsIsLoading(state)).toBeFalsy(); - }); - - it('should get selectSvomKeywordsIsLoaded', () => { - const state = { instance: { svomJsonKw: { ...fromSvomJsonKw.initialState }}}; - expect(svomJsonKwSelector.selectSvomKeywordsIsLoaded(state)).toBeFalsy(); - }); -}); diff --git a/client/src/app/instance/store/selectors/svom-json-kw.selector.ts b/client/src/app/instance/store/selectors/svom-json-kw.selector.ts deleted file mode 100644 index c178ec62..00000000 --- a/client/src/app/instance/store/selectors/svom-json-kw.selector.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of Anis Client. - * - * @copyright Laboratoire d'Astrophysique de Marseille / CNRS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { createSelector } from '@ngrx/store'; - -import * as reducer from '../../instance.reducer'; -import * as svomJsonKw from '../reducers/svom-json-kw.reducer'; - -export const selectSvomJsonKwState = createSelector( - reducer.getInstanceState, - (state: reducer.State) => state.svomJsonKw -); - -export const selectAcronymSelected = createSelector( - selectSvomJsonKwState, - svomJsonKw.selectAcronymSelected -); - -export const selectSvomKeywords = createSelector( - selectSvomJsonKwState, - svomJsonKw.selectSvomKeywords -); - -export const selectSvomKeywordsIsLoading = createSelector( - selectSvomJsonKwState, - svomJsonKw.selectSvomKeywordsIsLoading -); - -export const selectSvomKeywordsIsLoaded = createSelector( - selectSvomJsonKwState, - svomJsonKw.selectSvomKeywordsIsLoaded -); diff --git a/client/src/app/instance/store/services/index.ts b/client/src/app/instance/store/services/index.ts index 6ea85f7a..612ce58c 100644 --- a/client/src/app/instance/store/services/index.ts +++ b/client/src/app/instance/store/services/index.ts @@ -1,13 +1,11 @@ import { SearchService } from './search.service'; import { ConeSearchService } from './cone-search.service'; import { DetailService } from './detail.service'; -import { SvomJsonKwService } from './svom-json-kw.service'; import { ArchiveService } from './archive.service'; export const instanceServices = [ SearchService, ConeSearchService, DetailService, - SvomJsonKwService, ArchiveService ]; diff --git a/client/src/app/instance/store/services/svom-json-kw.service.spec.ts b/client/src/app/instance/store/services/svom-json-kw.service.spec.ts deleted file mode 100644 index 6a334fd2..00000000 --- a/client/src/app/instance/store/services/svom-json-kw.service.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * This file is part of Anis Client. - * - * @copyright Laboratoire d'Astrophysique de Marseille / CNRS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { TestBed, inject } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; - -import { SvomJsonKwService } from './svom-json-kw.service'; -import { AppConfigService } from 'src/app/app-config.service'; - -describe('[Instance][Store] SvomJsonKwService', () => { - let service: SvomJsonKwService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [ - { provide: AppConfigService, useValue: { apiUrl: 'http://testing.com' } }, - SvomJsonKwService - ] - }); - service = TestBed.inject(SvomJsonKwService); - }); - - it('#retrieveData() should return an Observable<any[]>', - inject([HttpTestingController, SvomJsonKwService],(httpMock: HttpTestingController, svomJsonKwService: SvomJsonKwService) => { - const mockResponse = ['myData']; - - svomJsonKwService.loadKwSearchable('OBLC_ECL').subscribe((event: any[]) => { - expect(event).toEqual(mockResponse); - }); - - const mockRequest = httpMock.expectOne('http://testing.com/search/sp_cards?a=8&c=1::eq::OBLC_ECL'); - - expect(mockRequest.cancelled).toBeFalsy(); - expect(mockRequest.request.responseType).toEqual('json'); - mockRequest.flush(mockResponse); - - httpMock.verify(); - } - ) - ); -}); \ No newline at end of file diff --git a/client/src/app/instance/store/services/svom-json-kw.service.ts b/client/src/app/instance/store/services/svom-json-kw.service.ts deleted file mode 100644 index e86072e9..00000000 --- a/client/src/app/instance/store/services/svom-json-kw.service.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file is part of Anis Client. - * - * @copyright Laboratoire d'Astrophysique de Marseille / CNRS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; - -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; - -import { AppConfigService } from 'src/app/app-config.service'; -import { SvomKeyword } from '../models'; - -/** - * @class - * @classdesc Svom Json Kw service. - */ -@Injectable() -export class SvomJsonKwService { - constructor(private http: HttpClient, private config: AppConfigService) { } - - /** - * Retrieves searchable keywords for the given acronym. - * - * @param {string} acronym - The acronym. - * - * @return Observable<SvomKeyword[]> - */ - loadKwSearchable(acronym: string): Observable<SvomKeyword[]> { - return this.http.get<{search_kw: SvomKeyword[]}[]>(`${this.config.apiUrl}/search/sp_cards?a=8&c=1::eq::${acronym}`).pipe( - map(data => data[0].search_kw) - ); - } -} -- GitLab