diff --git a/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.html b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.html index ca1a671ed43e3e3b7f1edbcc97fa36d7db6cc377..f75a949f8a9bcb0e0e5f06cff9ffde57c56d8b33 100644 --- a/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.html +++ b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.html @@ -23,6 +23,34 @@ </div> </div> </div> + <div class="custom-control custom-switch"> + <input class="custom-control-input" type="checkbox" id="resolver_enabled" name="resolver_enabled" formControlName="resolver_enabled"> + <label class="custom-control-label" for="resolver_enabled">Resolver enabled</label> + </div> + <div class="form-group"> + <div class="form-row"> + <div class="col-md-6"> + <label for="default_ra">Default RA</label> + <input type="number" class="form-control" id="default_ra" name="default_ra" formControlName="default_ra"> + </div> + <div class="col-md-6"> + <label for="default_dec">Default DEC</label> + <input type="number" class="form-control" id="default_dec" name="default_dec" formControlName="default_dec"> + </div> + </div> + </div> + <div class="form-group"> + <label for="default_radius">Default radius</label> + <input type="number" class="form-control" id="default_radius" name="default_radius" formControlName="default_radius"> + </div> + <div class="form-group"> + <label for="default_ra_dec_unit">Default Ra & Dec unit</label> + <select class="form-control" id="default_ra_dec_unit" name="default_ra_dec_unit" formControlName="default_ra_dec_unit"> + <option></option> + <option value="degree">Degree</option> + <option value="hms">HMS</option> + </select> + </div> <div class="custom-control custom-switch"> <input class="custom-control-input" type="checkbox" id="plot_enabled" name="plot_enabled" formControlName="plot_enabled"> <label class="custom-control-label" for="plot_enabled">Plot enabled</label> diff --git a/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.ts b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.ts index 3a2ff5a3059c44ff9ae31390001d6a86a7176233..d42ca6195606536b3eab8629c1809ce4b612a08a 100644 --- a/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.ts +++ b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.ts @@ -27,7 +27,12 @@ export class ConeSearchConfigFormComponent implements OnInit { opened: new UntypedFormControl({value: false, disabled: true}), column_ra: new UntypedFormControl({value: false, disabled: true}), column_dec: new UntypedFormControl({value: false, disabled: true}), - plot_enabled: new UntypedFormControl(false), + resolver_enabled: new UntypedFormControl({value: false, disabled: true}), + default_ra: new UntypedFormControl({value: null, disabled: true}), + default_dec: new UntypedFormControl({value: null, disabled: true}), + default_radius: new UntypedFormControl({value: 2.0, disabled: true}), + default_ra_dec_unit: new UntypedFormControl({value: 'degree', disabled: true}), + plot_enabled: new UntypedFormControl({value: false, disabled: true}) }); ngOnInit() { @@ -40,12 +45,22 @@ export class ConeSearchConfigFormComponent implements OnInit { this.form.controls.opened.enable(); this.form.controls.column_ra.enable(); this.form.controls.column_dec.enable(); + this.form.controls.resolver_enabled.enable(); + this.form.controls.default_ra.enable(); + this.form.controls.default_dec.enable(); + this.form.controls.default_radius.enable(); + this.form.controls.default_ra_dec_unit.enable(); this.form.controls.plot_enabled.enable(); } else { this.form.controls.opened.setValue(false); this.form.controls.opened.disable(); this.form.controls.column_ra.disable(); this.form.controls.column_dec.disable(); + this.form.controls.resolver_enabled.disable(); + this.form.controls.default_ra.disable(); + this.form.controls.default_dec.disable(); + this.form.controls.default_radius.disable(); + this.form.controls.default_ra_dec_unit.disable(); this.form.controls.plot_enabled.disable(); } } diff --git a/client/src/app/instance/cone-search/components/cone-search.component.html b/client/src/app/instance/cone-search/components/cone-search.component.html index 0d5da742daf22ff65c6820ed518922f0bb93613b..c2e0feb841ffc6b4c17bbb2ad65917466cf1c185 100644 --- a/client/src/app/instance/cone-search/components/cone-search.component.html +++ b/client/src/app/instance/cone-search/components/cone-search.component.html @@ -1,4 +1,4 @@ -<div class="row pb-4"> +<div class="row pb-4" *ngIf="resolverEnabled"> <div class="col"> <app-resolver [coneSearch]="coneSearch" diff --git a/client/src/app/instance/cone-search/components/cone-search.component.spec.ts b/client/src/app/instance/cone-search/components/cone-search.component.spec.ts index 2b23602aea2aac00b3d22f404ae28ad57b74b667..5a83f53ed02ea8277eac2497186c0fbe8e8e483d 100644 --- a/client/src/app/instance/cone-search/components/cone-search.component.spec.ts +++ b/client/src/app/instance/cone-search/components/cone-search.component.spec.ts @@ -12,24 +12,22 @@ import { Component, Input, ViewChild } from '@angular/core'; import { FormGroup, ReactiveFormsModule } from '@angular/forms'; import { ConeSearchComponent } from './cone-search.component'; -import { ConeSearch, Resolver } from 'src/app/instance/store/models'; +import { ConeSearch } from 'src/app/instance/store/models'; describe('[Instance][ConeSearch][Components] ConeSearchComponent', () => { @Component({ selector: `app-host`, template: ` <app-cone-search - [coneSearch]="coneSearch" - [resolver]="resolver" - [resolverIsLoading]="resolverIsLoading" - [resolverIsLoaded]="resolverIsLoaded"> + [coneSearch]="coneSearch" + [resolverIsLoading]="resolverIsLoading" + [resolverIsLoaded]="resolverIsLoaded"> </app-cone-search>` }) class TestHostComponent { @ViewChild(ConeSearchComponent, { static: false }) public testedComponent: ConeSearchComponent; public coneSearch: ConeSearch = undefined; - public resolver: Resolver = undefined; public resolverIsLoading: boolean = false; public resolverIsLoaded: boolean = false; } @@ -37,7 +35,6 @@ describe('[Instance][ConeSearch][Components] ConeSearchComponent', () => { @Component({ selector: 'app-resolver', template: '' }) class ResolverStubComponent { @Input() coneSearch: ConeSearch; - @Input() resolver: Resolver; @Input() resolverIsLoading: boolean; @Input() resolverIsLoaded: boolean; } @@ -46,14 +43,12 @@ describe('[Instance][ConeSearch][Components] ConeSearchComponent', () => { class RaStubComponent { @Input() form: FormGroup; @Input() unit: string; - @Input() resolver: Resolver; } @Component({ selector: 'app-dec', template: '' }) class DecStubComponent { @Input() form: FormGroup; @Input() unit: string; - @Input() resolver: Resolver; } @Component({ selector: 'app-radius', template: '' }) @@ -89,7 +84,6 @@ describe('[Instance][ConeSearch][Components] ConeSearchComponent', () => { it('should call ngOnChanges and apply changes', () => { const spy = jest.spyOn(testedComponent, 'ngOnChanges'); - testHostComponent.resolver = { name: 'myObject', ra: 1, dec: 2 }; testHostFixture.detectChanges(); expect(spy).toHaveBeenCalledTimes(0); expect(testedComponent.unit).toEqual('degree'); diff --git a/client/src/app/instance/cone-search/components/cone-search.component.ts b/client/src/app/instance/cone-search/components/cone-search.component.ts index 5ded610d50c5036e93c5f87b835e1861ae9bcf7f..4c5783e0608b7c1fd193c8f543af1856be0e400c 100644 --- a/client/src/app/instance/cone-search/components/cone-search.component.ts +++ b/client/src/app/instance/cone-search/components/cone-search.component.ts @@ -27,6 +27,9 @@ import { nanValidator, rangeValidator } from '../validators'; }) export class ConeSearchComponent implements OnChanges, OnInit, OnDestroy { @Input() coneSearch: ConeSearch; + @Input() defaultRadius: number; + @Input() defaultRaDecUnit: string; + @Input() resolverEnabled: boolean; @Input() resolverIsLoading: boolean; @Input() resolverIsLoaded: boolean; @Output() retrieveCoordinates: EventEmitter<string> = new EventEmitter(); @@ -61,6 +64,14 @@ export class ConeSearchComponent implements OnChanges, OnInit, OnDestroy { this.emitAdd.emit(); } }); + + if (!this.coneSearch && this.defaultRadius) { + this.form.controls.radius.setValue(this.defaultRadius); + } + + if (this.defaultRaDecUnit) { + this.unit = this.defaultRaDecUnit; + } } ngOnChanges(changes: SimpleChanges): void { diff --git a/client/src/app/instance/cone-search/components/dec.component.spec.ts b/client/src/app/instance/cone-search/components/dec.component.spec.ts index 407b3b1405dab94c7c06f97782b090120e5a6dbd..895af94e9ca8a2e32352412a57e2b38660819ded 100644 --- a/client/src/app/instance/cone-search/components/dec.component.spec.ts +++ b/client/src/app/instance/cone-search/components/dec.component.spec.ts @@ -14,7 +14,6 @@ import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angula import { of } from 'rxjs'; import { DecComponent } from './dec.component'; -import { Resolver } from 'src/app/instance/store/models'; import { nanValidator, rangeValidator } from '../validators'; describe('[Instance][ConeSearch][Components] DecComponent', () => { @@ -41,7 +40,6 @@ describe('[Instance][ConeSearch][Components] DecComponent', () => { public testedComponent: DecComponent; public form: FormGroup = form; public unit: string = 'degree'; - public resolver: Resolver = undefined; } let testHostComponent: TestHostComponent; @@ -92,7 +90,6 @@ describe('[Instance][ConeSearch][Components] DecComponent', () => { expect(spy).toHaveBeenCalledTimes(2); expect(testedComponent.form.controls.dec_dms.disabled).toBeTruthy(); expect(testedComponent.form.controls.dec.enabled).toBeTruthy(); - testHostComponent.resolver = { ra: 1, dec: 2, name: 'myObject' }; testHostFixture.detectChanges(); expect(spy).toHaveBeenCalledTimes(2); expect(testedComponent.form.controls.dec.value).toEqual(32.87); diff --git a/client/src/app/instance/cone-search/components/dec.component.ts b/client/src/app/instance/cone-search/components/dec.component.ts index 7d8c3180b6f8aaf71c651477ecf8d7dc9735956f..c6f3a72aab7a69a9aa9f01f5cffd7b9be48cfea0 100644 --- a/client/src/app/instance/cone-search/components/dec.component.ts +++ b/client/src/app/instance/cone-search/components/dec.component.ts @@ -38,7 +38,12 @@ export class DecComponent implements OnInit, OnDestroy, OnChanges { public decDmsSubscription: Subscription; ngOnInit(): void { - this.form.controls.dec_dms.disable(); + if (this.unit === 'degree') { + this.form.controls.dec_dms.disable(); + } else { + this.form.controls.dec.disable(); + } + this.decControlSubscription = this.form.controls.dec.valueChanges.pipe(debounceTime(250)) .subscribe(deg => this.deg2DMS(deg)); } diff --git a/client/src/app/instance/cone-search/components/ra.component.spec.ts b/client/src/app/instance/cone-search/components/ra.component.spec.ts index 7a05acd69eb0bf28238d71b2c2d5d0189fc383ba..044647cd2b86f501bc40b4714ec772913bda79ee 100644 --- a/client/src/app/instance/cone-search/components/ra.component.spec.ts +++ b/client/src/app/instance/cone-search/components/ra.component.spec.ts @@ -14,7 +14,6 @@ import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angula import { of } from 'rxjs'; import { RaComponent } from './ra.component'; -import { Resolver } from 'src/app/instance/store/models'; import { nanValidator, rangeValidator } from '../validators'; describe('[Instance][ConeSearch][Components] RaComponent', () => { @@ -41,7 +40,6 @@ describe('[Instance][ConeSearch][Components] RaComponent', () => { public testedComponent: RaComponent; public form: FormGroup = form; public unit: string = 'degree'; - public resolver: Resolver = undefined; } let testHostComponent: TestHostComponent; @@ -92,7 +90,6 @@ describe('[Instance][ConeSearch][Components] RaComponent', () => { expect(spy).toHaveBeenCalledTimes(2); expect(testedComponent.form.controls.ra_hms.disabled).toBeTruthy(); expect(testedComponent.form.controls.ra.enabled).toBeTruthy(); - testHostComponent.resolver = { ra: 1, dec: 2, name: 'myObject' }; testHostFixture.detectChanges(); expect(spy).toHaveBeenCalledTimes(2); expect(testedComponent.form.controls.ra.value).toEqual(78.2); diff --git a/client/src/app/instance/cone-search/components/ra.component.ts b/client/src/app/instance/cone-search/components/ra.component.ts index a177faac1169541cd5b3b5dcfd50924b977af26b..3dec1ea4b7081eaedba34f6fff5e96214f2a0c45 100644 --- a/client/src/app/instance/cone-search/components/ra.component.ts +++ b/client/src/app/instance/cone-search/components/ra.component.ts @@ -38,7 +38,12 @@ export class RaComponent implements OnInit, OnDestroy, OnChanges { public raHmsFormSubscription: Subscription; ngOnInit(): void { - this.form.controls.ra_hms.disable(); + if (this.unit === 'degree') { + this.form.controls.ra_hms.disable(); + } else { + this.form.controls.ra.disable(); + } + this.raControlSubscription = this.form.controls.ra.valueChanges.pipe(debounceTime(250)) .subscribe(deg => this.deg2HMS(deg)); } diff --git a/client/src/app/instance/cone-search/components/resolver.component.spec.ts b/client/src/app/instance/cone-search/components/resolver.component.spec.ts index 58c2b4b3f58889ffc486e060838949037c3aa6d1..d8d2ae6f5b46608d742d9bfae11733ab0fbe377d 100644 --- a/client/src/app/instance/cone-search/components/resolver.component.spec.ts +++ b/client/src/app/instance/cone-search/components/resolver.component.spec.ts @@ -12,7 +12,7 @@ import { Component, ViewChild } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; import { ResolverComponent } from './resolver.component'; -import { ConeSearch, Resolver } from 'src/app/instance/store/models'; +import { ConeSearch } from 'src/app/instance/store/models'; describe('[Instance][ConeSearch][Components] ResolverComponent', () => { @Component({ @@ -20,7 +20,6 @@ describe('[Instance][ConeSearch][Components] ResolverComponent', () => { template: ` <app-resolver [coneSearch]="coneSearch" - [resolver]="resolver" [resolverIsLoading]="resolverIsLoading" [resolverIsLoaded]="resolverIsLoaded"> </app-resolver>` @@ -29,7 +28,6 @@ describe('[Instance][ConeSearch][Components] ResolverComponent', () => { @ViewChild(ResolverComponent, { static: false }) public testedComponent: ResolverComponent; public coneSearch: ConeSearch = undefined; - public resolver: Resolver = undefined; public resolverIsLoading: boolean = false; public resolverIsLoaded: boolean = false; } diff --git a/client/src/app/instance/cone-search/components/resolver.component.ts b/client/src/app/instance/cone-search/components/resolver.component.ts index fab848211df15a8a6b5daeaec8e8ae86c0fc170f..77dc17c294f0e5e81aafd34b6fc16d731f71e7ca 100644 --- a/client/src/app/instance/cone-search/components/resolver.component.ts +++ b/client/src/app/instance/cone-search/components/resolver.component.ts @@ -10,7 +10,7 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { UntypedFormGroup, UntypedFormControl, Validators } from '@angular/forms'; -import { ConeSearch, Resolver } from 'src/app/instance/store/models'; +import { ConeSearch } from 'src/app/instance/store/models'; /** * @class diff --git a/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.html b/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.html index 52e4398fbf5142c3e90a7728c9d5712546b304ab..e13cbbdb79b63da29b8db72b00ee60a978becbbf 100644 --- a/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.html +++ b/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.html @@ -6,6 +6,7 @@ <div class="col"> <app-cone-search [coneSearch]="coneSearch" + [resolverEnabled]="true" [resolverIsLoading]="resolverIsLoading" [resolverIsLoaded]="resolverIsLoaded" (retrieveCoordinates)="retrieveCoordinates.emit($event)" diff --git a/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.ts b/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.ts index f2096f2602a4645d1c575ccdee31b8334642d633..cb656bea3c4cc3f2f6be0b9b6f4da37eb940ccca 100644 --- a/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.ts +++ b/client/src/app/instance/search-multiple/components/position/cone-search-panel.component.ts @@ -9,7 +9,7 @@ import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core'; -import { ConeSearch, Resolver, coneSearchToString } from 'src/app/instance/store/models'; +import { ConeSearch, coneSearchToString } from 'src/app/instance/store/models'; @Component({ selector: 'app-cone-search-panel', diff --git a/client/src/app/instance/search-multiple/components/progress-bar-multiple.component.ts b/client/src/app/instance/search-multiple/components/progress-bar-multiple.component.ts index 9a09a721236ea1f314b9958270f1b9b9690b77e7..2e2d391c1ec8a680654c4261cba4ed7c7d7ecace 100644 --- a/client/src/app/instance/search-multiple/components/progress-bar-multiple.component.ts +++ b/client/src/app/instance/search-multiple/components/progress-bar-multiple.component.ts @@ -25,7 +25,6 @@ import { ConeSearch, SearchMultipleQueryParams } from 'src/app/instance/store/mo export class ProgressBarMultipleComponent { @Input() instance: Instance; @Input() currentStep: string; - @Input() positionStepChecked: boolean; @Input() datasetsStepChecked: boolean; @Input() resultStepChecked: boolean; @Input() coneSearch: ConeSearch; diff --git a/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.spec.ts b/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.spec.ts index 69b64e6f6f803b12951d53d835f5593d15e3ea8f..5bece9d1f56e186d2ed2ca53dd3d679d34f3eda1 100644 --- a/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.spec.ts +++ b/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.spec.ts @@ -5,7 +5,6 @@ import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { of } from 'rxjs'; import { AbstractSearchMultipleComponent } from './abstract-search-multiple.component'; -import * as searchActions from '../../store/actions/search.actions'; import * as searchMultipleActions from '../../store/actions/search-multiple.actions'; describe('[Instance][SearchMultiple][Container] AbstractSearchComponent', () => { @@ -17,10 +16,6 @@ describe('[Instance][SearchMultiple][Container] AbstractSearchComponent', () => ngOnInit() { super.ngOnInit(); } - - ngOnDestroy() { - super.ngOnDestroy(); - } } let component: MyFakeComponent; @@ -51,11 +46,4 @@ describe('[Instance][SearchMultiple][Container] AbstractSearchComponent', () => done(); }); }); - - it('#ngOnDestroy() should unsubscribe from datasetListSubscription', () => { - component.datasetListSubscription = of().subscribe(); - const spy = jest.spyOn(component.datasetListSubscription, 'unsubscribe'); - component.ngOnDestroy(); - expect(spy).toHaveBeenCalledTimes(1); - }); }); diff --git a/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.ts b/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.ts index d3c5f13c5497d0a043b856f8713a8b7af86f09f2..9a8557be38130f6803bc390f4c4c35a4c9042fbe 100644 --- a/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.ts +++ b/client/src/app/instance/search-multiple/containers/abstract-search-multiple.component.ts @@ -21,7 +21,7 @@ import * as coneSearchSelector from 'src/app/instance/store/selectors/cone-searc * @implements OnDestroy */ @Directive() -export abstract class AbstractSearchMultipleComponent implements OnInit, OnDestroy { +export abstract class AbstractSearchMultipleComponent implements OnInit { public pristine: Observable<boolean>; public instance: Observable<Instance>; public datasetFamilyListIsLoading: Observable<boolean>; @@ -34,7 +34,6 @@ export abstract class AbstractSearchMultipleComponent implements OnInit, OnDestr public selectedDatasets: Observable<string[]>; public coneSearch: Observable<ConeSearch>; public queryParams: Observable<SearchMultipleQueryParams>; - public datasetListSubscription: Subscription; constructor(protected store: Store<{ }>) { this.pristine = this.store.select(searchMultipleSelector.selectPristine); @@ -52,16 +51,8 @@ export abstract class AbstractSearchMultipleComponent implements OnInit, OnDestr } ngOnInit(): void { - this.datasetListSubscription = this.datasetListIsLoaded.subscribe(datasetListIsLoaded => { - if (datasetListIsLoaded) { - // Create a micro task that is processed after the current synchronous code - // This micro task prevent the expression has changed after view init error - Promise.resolve(null).then(() => this.store.dispatch(searchMultipleActions.initSearch())); - } - }) - } - - ngOnDestroy(): void { - if (this.datasetListSubscription) this.datasetListSubscription.unsubscribe(); + // Create a micro task that is processed after the current synchronous code + // This micro task prevent the expression has changed after view init error + Promise.resolve(null).then(() => this.store.dispatch(searchMultipleActions.initSearch())); } } diff --git a/client/src/app/instance/search-multiple/containers/position.component.spec.ts b/client/src/app/instance/search-multiple/containers/position.component.spec.ts index 84a0914057bb7b80650f61a4919096a35bd27f54..9af01525b8f6fab8be2b817458304864bba5ad2d 100644 --- a/client/src/app/instance/search-multiple/containers/position.component.spec.ts +++ b/client/src/app/instance/search-multiple/containers/position.component.spec.ts @@ -6,7 +6,7 @@ import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { PositionComponent } from './position.component'; import { Dataset, DatasetFamily } from '../../../metamodel/models'; -import { ConeSearch, Resolver, SearchMultipleQueryParams } from '../../store/models'; +import { ConeSearch, SearchMultipleQueryParams } from '../../store/models'; import { AbstractSearchMultipleComponent } from './abstract-search-multiple.component'; import * as searchMultipleActions from '../../store/actions/search-multiple.actions'; import * as coneSearchActions from '../../store/actions/cone-search.actions'; @@ -18,7 +18,6 @@ describe('[Instance][SearchMultiple][Container] PositionComponent', () => { @Component({ selector: 'app-cone-search', template: '' }) class ConeSearchStubComponent { @Input() coneSearch: ConeSearch; - @Input() resolver: Resolver; @Input() resolverIsLoading: boolean; @Input() resolverIsLoaded: boolean; } diff --git a/client/src/app/instance/search-multiple/containers/position.component.ts b/client/src/app/instance/search-multiple/containers/position.component.ts index 7d883f8c9e61906d45c4e40cd29cb08f04c6f0f6..2cbbe5a268d663b6c2f76f78e565dc617ccc9a3d 100644 --- a/client/src/app/instance/search-multiple/containers/position.component.ts +++ b/client/src/app/instance/search-multiple/containers/position.component.ts @@ -13,7 +13,7 @@ import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { AbstractSearchMultipleComponent } from './abstract-search-multiple.component'; -import { Resolver, ConeSearch } from '../../store/models'; +import { ConeSearch } from '../../store/models'; import * as searchMultipleActions from '../../store/actions/search-multiple.actions'; import * as coneSearchActions from '../../store/actions/cone-search.actions'; import * as coneSearchSelector from '../../store/selectors/cone-search.selector'; diff --git a/client/src/app/instance/search-multiple/containers/result-multiple.component.spec.ts b/client/src/app/instance/search-multiple/containers/result-multiple.component.spec.ts index 4cb2ae0c0191b4ceedd1debde6e128842952c307..52f62c4b5dfad2934c0546b01f77a10e5d8ae5c7 100644 --- a/client/src/app/instance/search-multiple/containers/result-multiple.component.spec.ts +++ b/client/src/app/instance/search-multiple/containers/result-multiple.component.spec.ts @@ -63,12 +63,4 @@ describe('[Instance][SearchMultiple][Container] ResultMultipleComponent', () => done(); }); }); - - it('#ngOnDestroy() should unsubscribe from pristineSubscription', () => { - component.pristineSubscription = of().subscribe(); - const spy = jest.spyOn(component.pristineSubscription, 'unsubscribe'); - jest.spyOn(AbstractSearchMultipleComponent.prototype, 'ngOnDestroy').mockReturnThis(); - component.ngOnDestroy(); - expect(spy).toHaveBeenCalledTimes(1); - }); }); diff --git a/client/src/app/instance/search-multiple/containers/result-multiple.component.ts b/client/src/app/instance/search-multiple/containers/result-multiple.component.ts index cd50bfbc06ae6f0320273184cca8b1cb0fb4a733..fc86939f46efff2c48ff42a30bdaf40699e3d9b2 100644 --- a/client/src/app/instance/search-multiple/containers/result-multiple.component.ts +++ b/client/src/app/instance/search-multiple/containers/result-multiple.component.ts @@ -12,7 +12,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { Observable, Subscription } from 'rxjs'; import { Store } from '@ngrx/store'; -import { SearchMultipleDatasetLength, SearchMultipleDatasetData } from '../../store/models'; +import { SearchMultipleDatasetLength } from '../../store/models'; import { AbstractSearchMultipleComponent } from './abstract-search-multiple.component'; import * as searchMultipleActions from '../../store/actions/search-multiple.actions'; import * as searchMultipleSelector from 'src/app/instance/store/selectors/search-multiple.selector'; @@ -33,9 +33,6 @@ export class ResultMultipleComponent extends AbstractSearchMultipleComponent imp public dataLength: Observable<SearchMultipleDatasetLength[]>; public dataLengthIsLoading: Observable<boolean>; public dataLengthIsLoaded: Observable<boolean>; - public data: Observable<SearchMultipleDatasetData[]>; - public dataIsLoading: Observable<boolean>; - public dataIsLoaded: Observable<boolean>; public pristineSubscription: Subscription; constructor(protected store: Store<{ }>) { @@ -43,9 +40,6 @@ export class ResultMultipleComponent extends AbstractSearchMultipleComponent imp this.dataLength = this.store.select(searchMultipleSelector.selectDataLength); this.dataLengthIsLoading = this.store.select(searchMultipleSelector.selectDataLengthIsLoading); this.dataLengthIsLoaded = this.store.select(searchMultipleSelector.selectDataLengthIsLoaded); - this.data = this.store.select(searchMultipleSelector.selectData); - this.dataIsLoading = this.store.select(searchMultipleSelector.selectDataIsLoading); - this.dataIsLoaded = this.store.select(searchMultipleSelector.selectDataIsLoaded); } ngOnInit(): void { @@ -64,6 +58,5 @@ export class ResultMultipleComponent extends AbstractSearchMultipleComponent imp ngOnDestroy(): void { if (this.pristineSubscription) this.pristineSubscription.unsubscribe(); - super.ngOnDestroy(); } } diff --git a/client/src/app/instance/search-multiple/search-multiple.component.html b/client/src/app/instance/search-multiple/search-multiple.component.html index 7f7342be55b65395e810bc751799628776dea30e..e9095b8dd47323444d19c078257ff44789e239bf 100644 --- a/client/src/app/instance/search-multiple/search-multiple.component.html +++ b/client/src/app/instance/search-multiple/search-multiple.component.html @@ -2,7 +2,6 @@ <app-progress-bar-multiple [instance]="instance | async" [currentStep]="currentStep | async" - [positionStepChecked]="positionStepChecked | async" [datasetsStepChecked]="datasetsStepChecked | async" [resultStepChecked]="resultStepChecked | async" [coneSearch]="coneSearch | async" diff --git a/client/src/app/instance/search-multiple/search-multiple.component.ts b/client/src/app/instance/search-multiple/search-multiple.component.ts index b0d2b7b88a44d5099b04b2455761c63191ecc8da..0f5eb576f31cc41d668545086f1cae60b50f5b63 100644 --- a/client/src/app/instance/search-multiple/search-multiple.component.ts +++ b/client/src/app/instance/search-multiple/search-multiple.component.ts @@ -29,7 +29,6 @@ import * as coneSearchSelector from '../store/selectors/cone-search.selector'; export class SearchMultipleComponent { public instance: Observable<Instance>; public currentStep: Observable<string>; - public positionStepChecked: Observable<boolean>; public datasetsStepChecked: Observable<boolean>; public resultStepChecked: Observable<boolean>; public coneSearch: Observable<ConeSearch>; @@ -39,7 +38,6 @@ export class SearchMultipleComponent { constructor(private store: Store<{ }>) { this.instance = this.store.select(instanceSelector.selectInstanceByRouteName); this.currentStep = this.store.select(searchMultipleSelector.selectCurrentStep); - this.positionStepChecked = this.store.select(searchMultipleSelector.selectPositionStepChecked); this.datasetsStepChecked = this.store.select(searchMultipleSelector.selectDatasetsStepChecked); this.resultStepChecked = this.store.select(searchMultipleSelector.selectResultStepChecked); this.coneSearch = this.store.select(coneSearchSelector.selectConeSearch); diff --git a/client/src/app/instance/search/components/criteria/cone-search-tab.component.html b/client/src/app/instance/search/components/criteria/cone-search-tab.component.html index d0991f524b2f24c484a80b02db047d9481fd32cd..ce576d7087fe87bff2e67680c93e8c2f1b49fb85 100644 --- a/client/src/app/instance/search/components/criteria/cone-search-tab.component.html +++ b/client/src/app/instance/search/components/criteria/cone-search-tab.component.html @@ -16,6 +16,9 @@ <div class="col"> <app-cone-search [coneSearch]="coneSearch" + [defaultRadius]="coneSearchConfig.default_radius" + [defaultRaDecUnit]="coneSearchConfig.default_ra_dec_unit" + [resolverEnabled]="coneSearchConfig.resolver_enabled" [resolverIsLoading]="resolverIsLoading" [resolverIsLoaded]="resolverIsLoaded" (retrieveCoordinates)="retrieveCoordinates.emit($event)" diff --git a/client/src/app/instance/search/components/criteria/cone-search-tab.component.spec.ts b/client/src/app/instance/search/components/criteria/cone-search-tab.component.spec.ts index f268da6353db89672ea076ecf666d81806a1067b..7299cc4bff92495fb4402b28f0653b0d62433632 100644 --- a/client/src/app/instance/search/components/criteria/cone-search-tab.component.spec.ts +++ b/client/src/app/instance/search/components/criteria/cone-search-tab.component.spec.ts @@ -14,14 +14,13 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AccordionModule } from 'ngx-bootstrap/accordion'; import { ConeSearchTabComponent } from './cone-search-tab.component'; -import { ConeSearch, Resolver } from '../../../store/models'; +import { ConeSearch } from '../../../store/models'; import { DatasetByNamePipe } from '../../../../shared/pipes/dataset-by-name.pipe'; describe('[Instance][Search][Component][Criteria] ConeSearchTabComponent', () => { @Component({ selector: 'app-cone-search', template: '' }) class ConeSearchStubComponent { @Input() coneSearch: ConeSearch; - @Input() resolver: Resolver; @Input() resolverIsLoading: boolean; @Input() resolverIsLoaded: boolean; } diff --git a/client/src/app/instance/search/components/criteria/cone-search-tab.component.ts b/client/src/app/instance/search/components/criteria/cone-search-tab.component.ts index 3df09dbacb60c300269a9f3bb840c87b3231e829..4d24cc79446c5ec4580ff3a313881d8d96a9a2f1 100644 --- a/client/src/app/instance/search/components/criteria/cone-search-tab.component.ts +++ b/client/src/app/instance/search/components/criteria/cone-search-tab.component.ts @@ -10,7 +10,7 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { ConeSearchConfig, Dataset } from 'src/app/metamodel/models'; -import { ConeSearch, Resolver, coneSearchToString } from 'src/app/instance/store/models'; +import { ConeSearch, coneSearchToString } from 'src/app/instance/store/models'; /** * @class diff --git a/client/src/app/instance/search/containers/abstract-search.component.spec.ts b/client/src/app/instance/search/containers/abstract-search.component.spec.ts index b304927b12119b87fa5d65eb8c08358f25c105aa..4e3998c24dc72fbeae81b0cbfa79e3fc78849618 100644 --- a/client/src/app/instance/search/containers/abstract-search.component.spec.ts +++ b/client/src/app/instance/search/containers/abstract-search.component.spec.ts @@ -25,10 +25,6 @@ describe('[Instance][Search][Container] AbstractSearchComponent', () => { ngOnInit() { super.ngOnInit(); } - - ngOnDestroy() { - super.ngOnDestroy(); - } } let component: MyFakeComponent; @@ -54,17 +50,9 @@ describe('[Instance][Search][Container] AbstractSearchComponent', () => { const spy = jest.spyOn(store, 'dispatch'); component.ngOnInit(); Promise.resolve(null).then(function() { - expect(spy).toHaveBeenCalledTimes(2); + expect(spy).toHaveBeenCalledTimes(1); expect(spy).toHaveBeenCalledWith(searchActions.initSearch()); - expect(spy).toHaveBeenCalledWith(searchActions.loadDefaultFormParameters()); done(); }); }); - - it('#ngOnDestroy() should unsubscribe from attributeListIsLoadedSubscription', () => { - component.attributeListIsLoadedSubscription = of().subscribe(); - const spy = jest.spyOn(component.attributeListIsLoadedSubscription, 'unsubscribe'); - component.ngOnDestroy(); - expect(spy).toHaveBeenCalledTimes(1); - }); }); diff --git a/client/src/app/instance/search/containers/abstract-search.component.ts b/client/src/app/instance/search/containers/abstract-search.component.ts index 265889220b952045aec693857c240e266365a9cb..21a02c66138481a4f3460e3ae19407ddce2a6d40 100644 --- a/client/src/app/instance/search/containers/abstract-search.component.ts +++ b/client/src/app/instance/search/containers/abstract-search.component.ts @@ -7,10 +7,10 @@ * file that was distributed with this source code. */ -import { Directive, OnInit, OnDestroy } from '@angular/core'; +import { Directive, OnInit } from '@angular/core'; import { Store } from '@ngrx/store'; -import { Observable, Subscription } from 'rxjs'; +import { Observable } from 'rxjs'; import { ConeSearch, Criterion, SearchQueryParams } from '../../store/models'; import { Dataset, Attribute, CriteriaFamily, OutputFamily, OutputCategory } from 'src/app/metamodel/models'; @@ -34,7 +34,7 @@ import * as coneSearchSelector from '../../store/selectors/cone-search.selector' * @implements OnDestroy */ @Directive() -export abstract class AbstractSearchComponent implements OnInit, OnDestroy { +export abstract class AbstractSearchComponent implements OnInit { public datasetSelected: Observable<string>; public instanceSelected: Observable<string>; public datasetListIsLoading: Observable<boolean>; @@ -58,7 +58,6 @@ export abstract class AbstractSearchComponent implements OnInit, OnDestroy { public outputList: Observable<number[]>; public queryParams: Observable<SearchQueryParams>; public coneSearch: Observable<ConeSearch>; - public attributeListIsLoadedSubscription: Subscription; constructor(protected store: Store<{ }>) { this.datasetSelected = store.select(datasetSelector.selectDatasetNameByRoute); @@ -90,14 +89,5 @@ export abstract class AbstractSearchComponent implements OnInit, OnDestroy { // Create a micro task that is processed after the current synchronous code // This micro task prevent the expression has changed after view init error Promise.resolve(null).then(() => this.store.dispatch(searchActions.initSearch())); - this.attributeListIsLoadedSubscription = this.attributeListIsLoaded.subscribe(attributeListIsLoaded => { - if (attributeListIsLoaded) { - Promise.resolve(null).then(() => this.store.dispatch(searchActions.loadDefaultFormParameters())); - } - }); - } - - ngOnDestroy(): void { - if (this.attributeListIsLoadedSubscription) this.attributeListIsLoadedSubscription.unsubscribe(); } } diff --git a/client/src/app/instance/search/containers/criteria.component.spec.ts b/client/src/app/instance/search/containers/criteria.component.spec.ts index 350bcf906f561c51984411f8af0753e83ef76d14..cbc3aeaed785b3a3259ac8ae33307453a4e3995c 100644 --- a/client/src/app/instance/search/containers/criteria.component.spec.ts +++ b/client/src/app/instance/search/containers/criteria.component.spec.ts @@ -15,7 +15,7 @@ import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { CriteriaComponent } from './criteria.component'; import { Attribute, CriteriaFamily, Dataset, OutputCategory, OutputFamily } from '../../../metamodel/models'; -import { ConeSearch, Criterion, Resolver, SearchQueryParams, SvomKeyword } from '../../store/models'; +import { ConeSearch, Criterion, SearchQueryParams, SvomKeyword } from '../../store/models'; import { SortByCriteriaDisplayPipe } from '../pipes/sort-by-criteria-display.pipe'; import * as searchActions from '../../store/actions/search.actions'; import { AbstractSearchComponent } from './abstract-search.component'; @@ -31,7 +31,6 @@ describe('[Instance][Search][Container] CriteriaComponent', () => { @Input() datasetSelected: string; @Input() datasetList: Dataset[]; @Input() coneSearch: ConeSearch; - @Input() resolver: Resolver; @Input() resolverIsLoading: boolean; @Input() resolverIsLoaded: boolean; } @@ -90,10 +89,9 @@ describe('[Instance][Search][Container] CriteriaComponent', () => { jest.spyOn(AbstractSearchComponent.prototype, 'ngOnInit').mockReturnThis(); component.ngOnInit(); Promise.resolve(null).then(function() { - expect(spy).toHaveBeenCalledTimes(3); + expect(spy).toHaveBeenCalledTimes(2); expect(spy).toHaveBeenCalledWith(searchActions.changeStep({ step: 'criteria' })); expect(spy).toHaveBeenCalledWith(searchActions.checkCriteria()); - expect(spy).toHaveBeenCalledWith(coneSearchConfigActions.loadConeSearchConfig()); done(); }); }); diff --git a/client/src/app/instance/search/containers/criteria.component.ts b/client/src/app/instance/search/containers/criteria.component.ts index cb0d816c590dccac354da5e5d02fd9b09d9f6a2c..83117cf8d64f64d586c8da1e5986054a510f90fd 100644 --- a/client/src/app/instance/search/containers/criteria.component.ts +++ b/client/src/app/instance/search/containers/criteria.component.ts @@ -14,14 +14,13 @@ import { Observable } from 'rxjs'; import { AbstractSearchComponent } from './abstract-search.component'; import { ConeSearchConfig, Dataset, Instance } from 'src/app/metamodel/models'; -import { ConeSearch, Criterion, Resolver } from '../../store/models'; +import { ConeSearch, Criterion } from '../../store/models'; import * as instanceSelector from 'src/app/metamodel/selectors/instance.selector'; import * as datasetSelector from 'src/app/metamodel/selectors/dataset.selector'; +import * as coneSearchConfigSelector from 'src/app/metamodel/selectors/cone-search-config.selector'; 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 coneSearchConfigActions from 'src/app/metamodel/actions/cone-search-config.actions'; -import * as coneSearchConfigSelector from 'src/app/metamodel/selectors/cone-search-config.selector'; /** * @class @@ -56,7 +55,6 @@ export class CriteriaComponent extends AbstractSearchComponent { // This micro task prevent the expression has changed after view init error Promise.resolve(null).then(() => this.store.dispatch(searchActions.changeStep({ step: 'criteria' }))); Promise.resolve(null).then(() => this.store.dispatch(searchActions.checkCriteria())); - Promise.resolve(null).then(() => this.store.dispatch(coneSearchConfigActions.loadConeSearchConfig())); super.ngOnInit(); } diff --git a/client/src/app/instance/search/containers/dataset.component.spec.ts b/client/src/app/instance/search/containers/dataset.component.spec.ts index c52aefb6c988c2423f331b2c93435be8fc139c72..68c0e8df07802abdff23d21a0a84535ff8b98c27 100644 --- a/client/src/app/instance/search/containers/dataset.component.spec.ts +++ b/client/src/app/instance/search/containers/dataset.component.spec.ts @@ -91,17 +91,9 @@ describe('[Instance][Search][Container] DatasetComponent', () => { jest.spyOn(AbstractSearchComponent.prototype, 'ngOnInit').mockReturnThis(); component.ngOnInit(); Promise.resolve(null).then(function() { - expect(spy).toHaveBeenCalledTimes(2); + expect(spy).toHaveBeenCalledTimes(1); expect(spy).toHaveBeenCalledWith(searchActions.changeStep({ step: 'dataset' })); - expect(spy).toHaveBeenCalledWith(searchActions.initSearch()); done(); }); }); - - it('#ngOnDestroy() should unsubscribe from datasetSelectedSubscription', () => { - component.datasetSelectedSubscription = of().subscribe(); - const spy = jest.spyOn(component.datasetSelectedSubscription, 'unsubscribe'); - component.ngOnDestroy(); - expect(spy).toHaveBeenCalledTimes(1); - }); }); diff --git a/client/src/app/instance/search/containers/dataset.component.ts b/client/src/app/instance/search/containers/dataset.component.ts index 7f24ff31fb884edf0baca82f354dcb01064422aa..25f1c2b55e185a6fba2c53cdc1b1122a0d2dc7a4 100644 --- a/client/src/app/instance/search/containers/dataset.component.ts +++ b/client/src/app/instance/search/containers/dataset.component.ts @@ -10,7 +10,7 @@ import { Component} from '@angular/core'; import { Store } from '@ngrx/store'; -import { Observable, Subscription } from 'rxjs'; +import { Observable } from 'rxjs'; import { AbstractSearchComponent } from './abstract-search.component'; import { DatasetFamily, DatasetGroup } from 'src/app/metamodel/models'; @@ -37,7 +37,6 @@ export class DatasetComponent extends AbstractSearchComponent { public datasetGroupList: Observable<DatasetGroup[]>; public datasetGroupListIsLoading: Observable<boolean>; public datasetGroupListIsLoaded: Observable<boolean>; - public datasetSelectedSubscription: Subscription; constructor(protected store: Store<{ }>, private config: AppConfigService) { super(store); @@ -55,11 +54,6 @@ export class DatasetComponent extends AbstractSearchComponent { // Create a micro task that is processed after the current synchronous code // This micro task prevent the expression has changed after view init error Promise.resolve(null).then(() => this.store.dispatch(searchActions.changeStep({ step: 'dataset' }))); - this.datasetSelectedSubscription = this.datasetSelected.subscribe(datasetSelected => { - if (datasetSelected) { - Promise.resolve(null).then(() => this.store.dispatch(searchActions.initSearch())); - } - }) super.ngOnInit(); } @@ -80,9 +74,4 @@ export class DatasetComponent extends AbstractSearchComponent { getAdminRoles(): string[] { return this.config.adminRoles; } - - ngOnDestroy(): void { - if (this.datasetSelectedSubscription) this.datasetSelectedSubscription.unsubscribe(); - super.ngOnDestroy(); - } } diff --git a/client/src/app/instance/search/containers/result.component.spec.ts b/client/src/app/instance/search/containers/result.component.spec.ts index d84173c57aaee2907a6edf03bbae93409c914f8a..d89e8504922d10017a6534f256a22cc645be610f 100644 --- a/client/src/app/instance/search/containers/result.component.spec.ts +++ b/client/src/app/instance/search/containers/result.component.spec.ts @@ -124,12 +124,11 @@ describe('[Instance][Search][Container] ResultComponent', () => { jest.spyOn(AbstractSearchComponent.prototype, 'ngOnInit').mockReturnThis(); component.ngOnInit(); Promise.resolve(null).then(function() { - expect(spy).toHaveBeenCalledTimes(5); + expect(spy).toHaveBeenCalledTimes(4); expect(spy).toHaveBeenCalledWith(searchActions.changeStep({ step: 'result' })); expect(spy).toHaveBeenCalledWith(searchActions.checkResult()); - expect(spy).toHaveBeenCalledWith(searchActions.retrieveDataLength()); expect(spy).toHaveBeenCalledWith(imageActions.loadImageList()); - expect(spy).toHaveBeenCalledWith(coneSearchConfigActions.loadConeSearchConfig()); + expect(spy).toHaveBeenCalledWith(searchActions.retrieveDataLength()); done(); }); }); diff --git a/client/src/app/instance/search/containers/result.component.ts b/client/src/app/instance/search/containers/result.component.ts index a24e7e583414bbdd0e7334cf726511b6e589ae2b..cf364dc07b37984d26db74a8c6c9cb5f378709ae 100644 --- a/client/src/app/instance/search/containers/result.component.ts +++ b/client/src/app/instance/search/containers/result.component.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import { Component } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable, Subscription } from 'rxjs'; @@ -25,7 +25,6 @@ import * as archiveSelector from '../../store/selectors/archive.selector'; import * as imageActions from 'src/app/metamodel/actions/image.actions'; import * as imageSelector from 'src/app/metamodel/selectors/image.selector'; import * as datasetSelector from 'src/app/metamodel/selectors/dataset.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'; /** @@ -39,7 +38,7 @@ import * as coneSearchConfigSelector from 'src/app/metamodel/selectors/cone-sear selector: 'app-result', templateUrl: 'result.component.html' }) -export class ResultComponent extends AbstractSearchComponent { +export class ResultComponent extends AbstractSearchComponent implements OnInit, OnDestroy { public instance: Observable<Instance>; public dataset: Observable<Dataset>; public dataLength: Observable<number>; @@ -89,14 +88,13 @@ export class ResultComponent extends AbstractSearchComponent { // This micro task prevent the expression has changed after view init error Promise.resolve(null).then(() => this.store.dispatch(searchActions.changeStep({ step: 'result' }))); Promise.resolve(null).then(() => this.store.dispatch(searchActions.checkResult())); - super.ngOnInit(); + Promise.resolve(null).then(() => this.store.dispatch(imageActions.loadImageList())); this.pristineSubscription = this.pristine.subscribe(pristine => { if (!pristine) { Promise.resolve(null).then(() => this.store.dispatch(searchActions.retrieveDataLength())); } }); - Promise.resolve(null).then(() => this.store.dispatch(imageActions.loadImageList())); - Promise.resolve(null).then(() => this.store.dispatch(coneSearchConfigActions.loadConeSearchConfig())); + super.ngOnInit(); } /** @@ -170,15 +168,6 @@ export class ResultComponent extends AbstractSearchComponent { this.store.dispatch(searchActions.updateOutputList({ outputList })); } - /** - * Dispatches action to destroy search results. - */ - ngOnDestroy(): void { - this.store.dispatch(searchActions.destroyResults()); - this.store.dispatch(archiveActions.resetArchive()); - if (this.pristineSubscription) this.pristineSubscription.unsubscribe(); - super.ngOnDestroy(); - } /** * update image plot background href value * @@ -206,4 +195,13 @@ export class ResultComponent extends AbstractSearchComponent { updateSelectId(id: any) { this.selectId = id; } + + /** + * Dispatches action to destroy search results. + */ + ngOnDestroy(): void { + this.store.dispatch(searchActions.destroyResults()); + this.store.dispatch(archiveActions.resetArchive()); + if (this.pristineSubscription) this.pristineSubscription.unsubscribe(); + } } diff --git a/client/src/app/instance/store/actions/search-multiple.actions.ts b/client/src/app/instance/store/actions/search-multiple.actions.ts index 87d20074517eeb51f87b1895a8c81f6d9a5161a8..1dd207977345616e4968533dea9865507fa3df9d 100644 --- a/client/src/app/instance/store/actions/search-multiple.actions.ts +++ b/client/src/app/instance/store/actions/search-multiple.actions.ts @@ -9,7 +9,7 @@ import { createAction, props } from '@ngrx/store'; -import { SearchMultipleDatasetLength, SearchMultipleDatasetData } from '../models'; +import { SearchMultipleDatasetLength } from '../models'; export const initSearch = createAction('[Search Multiple] Init Search'); export const restartSearch = createAction('[Search Multiple] Restart Search'); @@ -21,6 +21,3 @@ export const updateSelectedDatasets = createAction('[Search Multiple] Update Sel export const retrieveDataLength = createAction('[Search Multiple] Retrieve Data Length'); export const retrieveDataLengthSuccess = createAction('[Search Multiple] Retrieve Data Length Success', props<{ dataLength: SearchMultipleDatasetLength[] }>()); export const retrieveDataLengthFail = createAction('[Search Multiple] Retrieve Data Length Fail'); -export const retrieveData = createAction('[Search Multiple] Retrieve Data'); -export const retrieveDataSuccess = createAction('[Search Multiple] Retrieve Data Success', props<{ data: SearchMultipleDatasetData[] }>()); -export const retrieveDataFail = createAction('[Search Multiple] Retrieve Data Fail'); diff --git a/client/src/app/instance/store/actions/search.actions.ts b/client/src/app/instance/store/actions/search.actions.ts index 51cd7a0384f7dbb2dc7b64cccc145bad8865bb8d..613a5f50f7d9031ba5c7f4fc9ebd22320a3802cc 100644 --- a/client/src/app/instance/store/actions/search.actions.ts +++ b/client/src/app/instance/store/actions/search.actions.ts @@ -15,6 +15,7 @@ export const initSearch = createAction('[Search] Init Search'); export const restartSearch = createAction('[Search] Restart Search'); export const resetSearch = createAction('[Search] Reset Search'); export const destroyResults = createAction('[Search] Destroy Results'); +export const tryLoadDefaultFormParameters = createAction('[Search] Try Load Default Form Parameters'); export const loadDefaultFormParameters = createAction('[Search] Load Default Form Parameters'); export const markAsDirty = createAction('[Search] Mark As Dirty'); export const changeCurrentDataset = createAction('[Search] Change Current Dataset', props<{ currentDataset: string }>()); diff --git a/client/src/app/instance/store/effects/search-multiple.effects.ts b/client/src/app/instance/store/effects/search-multiple.effects.ts index b2eb411a1f5bfa6472e2559b515b36d22c25ee73..66a0a4e9ab8442147c909e8d957d3acd57f88079 100644 --- a/client/src/app/instance/store/effects/search-multiple.effects.ts +++ b/client/src/app/instance/store/effects/search-multiple.effects.ts @@ -26,7 +26,6 @@ import * as coneSearchSelector from '../selectors/cone-search.selector'; @Injectable() export class SearchMultipleEffects { - /** * Calls actions to initialize search multiple. */ diff --git a/client/src/app/instance/store/effects/search.effects.spec.ts b/client/src/app/instance/store/effects/search.effects.spec.ts index 436528864caa23d27230d2df7402fa349e3e2bbf..30c9f4fa09b82642a6437a42977b441e0ec25be1 100644 --- a/client/src/app/instance/store/effects/search.effects.spec.ts +++ b/client/src/app/instance/store/effects/search.effects.spec.ts @@ -21,6 +21,8 @@ import * as outputCategoryActions from '../../../metamodel/actions/output-catego import * as attributeSelector from '../../../metamodel/selectors/attribute.selector'; import * as coneSearchSelector from '../selectors/cone-search.selector'; import * as coneSearchActions from '../actions/cone-search.actions'; +import * as coneSearchConfigSelector from 'src/app/metamodel/selectors/cone-search-config.selector'; +import * as coneSearchConfigActions from 'src/app/metamodel/actions/cone-search-config.actions'; import { Criterion, PaginationOrder } from '../models'; describe('[Instance][Store] SearchEffects', () => { @@ -43,6 +45,7 @@ describe('[Instance][Store] SearchEffects', () => { let mockConeSearchSelectorSelectConeSearch; let mockSearchSelectorSelectOutputListByRoute; let mockSearchSelectorSelectOutputList; + let mocksSearchSelectorSelectConeSearchConfig; beforeEach(() => { TestBed.configureTestingModule({ @@ -96,6 +99,9 @@ describe('[Instance][Store] SearchEffects', () => { mockSearchSelectorSelectOutputList = store.overrideSelector( searchSelector.selectOutputList,[] ); + mocksSearchSelectorSelectConeSearchConfig = store.overrideSelector( + coneSearchConfigSelector.selectConeSearchConfig,null + ); }); it('should be created', () => { @@ -133,12 +139,14 @@ describe('[Instance][Store] SearchEffects', () => { const action = searchActions.initSearch(); actions = hot('-a', { a: action }); - const expected = cold('-(bcdef)', { + const expected = cold('-(bcdefgh)', { b: searchActions.changeCurrentDataset({ currentDataset: 'myDatasetName' }), c: attributeActions.loadAttributeList(), d: criteriaFamilyActions.loadCriteriaFamilyList(), e: outputFamilyActions.loadOutputFamilyList(), - f: outputCategoryActions.loadOutputCategoryList() + f: outputCategoryActions.loadOutputCategoryList(), + g: coneSearchConfigActions.loadConeSearchConfig(), + h: searchActions.tryLoadDefaultFormParameters() }); expect(effects.initSearch$).toBeObservable(expected); @@ -160,15 +168,17 @@ describe('[Instance][Store] SearchEffects', () => { const action = searchActions.initSearch(); actions = hot('-a', { a: action }); - const expected = cold('-(bcdefghi)', { + const expected = cold('-(bcdefghijk)', { b: searchActions.changeCurrentDataset({ currentDataset: 'myDatasetName' }), c: attributeActions.loadAttributeList(), d: criteriaFamilyActions.loadCriteriaFamilyList(), e: outputFamilyActions.loadOutputFamilyList(), f: outputCategoryActions.loadOutputCategoryList(), - g: searchActions.checkCriteria(), - h: searchActions.checkOutput(), - i: searchActions.checkResult() + g: coneSearchConfigActions.loadConeSearchConfig(), + h: searchActions.tryLoadDefaultFormParameters(), + i: searchActions.checkCriteria(), + j: searchActions.checkOutput(), + k: searchActions.checkResult() }); expect(effects.initSearch$).toBeObservable(expected); @@ -209,10 +219,13 @@ describe('[Instance][Store] SearchEffects', () => { describe('restartSearch$ effect', () => { it('should dispatch the initSearch action', () => { const action = searchActions.restartSearch(); - const outcome = searchActions.initSearch(); actions = hot('-a', { a: action }); - const expected = cold('-b', { b: outcome }); + const expected = cold('-(bcd)', { + b: attributeActions.resetAttributeList(), + c: coneSearchConfigActions.resetConeSearchConfig(), + d: searchActions.initSearch() + }); expect(effects.restartSearch$).toBeObservable(expected); }); @@ -452,7 +465,7 @@ describe('[Instance][Store] SearchEffects', () => { searchSelector.selectCriteriaListByRoute, '1::eq::un;2::eq::deux' ); mockSearchSelectorSelectOutputListByRoute = store.overrideSelector( - searchSelector.selectOutputListByRoute, null + searchSelector.selectOutputListByRoute, '1;2;3' ); const action = searchActions.loadDefaultFormParameters(); @@ -463,7 +476,7 @@ describe('[Instance][Store] SearchEffects', () => { {'id':2,'type':'field','operator':'eq','value':'deux'} ]; const defaultConeSearch = null; - const defaultOutputList = []; + const defaultOutputList = [1, 2, 3]; const expected = cold('-(bcde)', { b: searchActions.updateCriteriaList({ criteriaList: criteriaList }), c: coneSearchActions.addConeSearch({ coneSearch: defaultConeSearch }), diff --git a/client/src/app/instance/store/effects/search.effects.ts b/client/src/app/instance/store/effects/search.effects.ts index 3f05797b8970f44fa4e96dec68ce9174dcd322ba..d0424b705ed918cde67f3d42d45a31d2a0410987 100644 --- a/client/src/app/instance/store/effects/search.effects.ts +++ b/client/src/app/instance/store/effects/search.effects.ts @@ -10,9 +10,9 @@ import { Injectable } from '@angular/core'; import { Actions, createEffect, ofType, concatLatestFrom } from '@ngrx/effects'; -import { Store, Action } from '@ngrx/store'; -import { of } from 'rxjs'; -import { map, tap, mergeMap, catchError } from 'rxjs/operators'; +import { Store, Action, select } from '@ngrx/store'; +import { of, combineLatest } from 'rxjs'; +import { map, switchMap, tap, mergeMap, catchError, skipWhile } from 'rxjs/operators'; import { ToastrService } from 'ngx-toastr'; import { KeycloakService } from 'keycloak-angular'; import FileSaver from 'file-saver'; @@ -29,6 +29,8 @@ import * as datasetSelector from 'src/app/metamodel/selectors/dataset.selector'; import * as searchSelector from '../selectors/search.selector'; import * as coneSearchActions from '../actions/cone-search.actions'; import * as coneSearchSelector from '../selectors/cone-search.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'; import * as authSelector from 'src/app/auth/auth.selector'; /** @@ -37,7 +39,6 @@ import * as authSelector from 'src/app/auth/auth.selector'; */ @Injectable() export class SearchEffects { - /** * Calls actions to initialize search. */ @@ -63,7 +64,9 @@ export class SearchEffects { attributeActions.loadAttributeList(), criteriaFamilyActions.loadCriteriaFamilyList(), outputFamilyActions.loadOutputFamilyList(), - outputCategoryActions.loadOutputCategoryList() + outputCategoryActions.loadOutputCategoryList(), + coneSearchConfigActions.loadConeSearchConfig(), + searchActions.tryLoadDefaultFormParameters() ]; if (steps) { if(steps[0] === '1') { @@ -96,7 +99,24 @@ export class SearchEffects { restartSearch$ = createEffect((): any => this.actions$.pipe( ofType(searchActions.restartSearch), - map(() => searchActions.initSearch()) + mergeMap(() => [ + attributeActions.resetAttributeList(), + coneSearchConfigActions.resetConeSearchConfig(), + searchActions.initSearch() + ]) + ) + ); + + tryLoadDefaultFormParameters$ = createEffect((): any => + this.actions$.pipe( + ofType(searchActions.tryLoadDefaultFormParameters), + switchMap(() => combineLatest([ + this.store.pipe(select(attributeSelector.selectAttributeListIsLoaded)), + this.store.pipe(select(coneSearchConfigSelector.selectConeSearchConfigIsLoaded)), + ]).pipe( + skipWhile(([attributeListIsLoaded, coneSearchConfigIsLoaded]) => !attributeListIsLoaded || !coneSearchConfigIsLoaded), + map(() => searchActions.loadDefaultFormParameters()) + )) ) ); @@ -110,11 +130,12 @@ export class SearchEffects { this.store.select(searchSelector.selectPristine), this.store.select(searchSelector.selectCurrentDataset), this.store.select(attributeSelector.selectAllAttributes), + this.store.select(coneSearchConfigSelector.selectConeSearchConfig), this.store.select(searchSelector.selectCriteriaListByRoute), this.store.select(coneSearchSelector.selectConeSearchByRoute), this.store.select(searchSelector.selectOutputListByRoute) ]), - mergeMap(([, pristine, currentDataset, attributeList, criteriaList, coneSearch, outputList]) => { + mergeMap(([, pristine, currentDataset, attributeList, coneSearchConfig, criteriaList, coneSearch, outputList]) => { // Default form parameters already loaded or no dataset selected if (!pristine || !currentDataset) { return of({ type: '[No Action] Load Default Form Parameters' }); @@ -129,16 +150,12 @@ export class SearchEffects { const attribute = attributeList.find(a => a.id === parseInt(params[0], 10)); return stringToCriterion(attribute, params); }); - } else { - // Build default criteria list with the attribute list metamodel configuration - defaultCriteriaList = attributeList - .filter(attribute => attribute.id_criteria_family && attribute.search_type && attribute.min) - .map(attribute => stringToCriterion(attribute)); } // Update cone search let defaultConeSearch: ConeSearch = null; if (coneSearch) { + // Build cone-search with the URL query parameters (cs) defaultConeSearch = stringToConeSearch(coneSearch); } @@ -147,8 +164,27 @@ export class SearchEffects { if (outputList) { // Build output list with the URL query parameters (a) defaultOutputList = outputList.split(';').map((o: string) => parseInt(o, 10)); - } else { - // Build default output list with the attribute list metamodel configuration + } + + // If the user has moved from step 1 to 2 + // outputList is empty and ANIS cand build + // 1. default criteria list with the attribute list metamodel configuration + // 2. default output list with the attribute list metamodel configuration + if (!outputList) { + defaultCriteriaList = attributeList + .filter(attribute => attribute.id_criteria_family && attribute.search_type && (attribute.min || attribute.max)) + .map(attribute => stringToCriterion(attribute)); + + if (coneSearchConfig + && coneSearchConfig.default_ra !== null + && coneSearchConfig.default_dec !== null + && coneSearchConfig.default_radius !== null + ) { + defaultConeSearch = stringToConeSearch( + `${coneSearchConfig.default_ra}:${coneSearchConfig.default_dec}:${coneSearchConfig.default_radius}` + ); + } + defaultOutputList = attributeList .filter(attribute => attribute.selected && attribute.id_output_category) .sort((a, b) => a.output_display - b.output_display) diff --git a/client/src/app/instance/store/models/criterion.model.ts b/client/src/app/instance/store/models/criterion.model.ts index 3abcabaf8d12c3619f2259b63d65b700ddd687f1..b9193009bcb3aba5be84ca830ce089efa8df09bd 100644 --- a/client/src/app/instance/store/models/criterion.model.ts +++ b/client/src/app/instance/store/models/criterion.model.ts @@ -127,7 +127,10 @@ export const stringToCriterion = (attribute: Attribute, params: string[] = null) return { id: attribute.id, type: 'between', min: null, max: params[2] } as BetweenCriterion; } } else { - return { id: attribute.id, type: 'between', min: attribute.min.toString(), max: attribute.max.toString() } as BetweenCriterion; + const min = (attribute.min) ? attribute.min.toString() : null; + const max = (attribute.max) ? attribute.max.toString() : null; + console.log(max); + return { id: attribute.id, type: 'between', min, max } as BetweenCriterion; } case 'select-multiple': case 'checkbox': diff --git a/client/src/app/instance/store/models/index.ts b/client/src/app/instance/store/models/index.ts index 67be1059cf6ae8f9f0530f91f275da1cf1252ae6..17085214a99584c8d9e67374d9562f57df670955 100644 --- a/client/src/app/instance/store/models/index.ts +++ b/client/src/app/instance/store/models/index.ts @@ -6,5 +6,4 @@ export * from './pagination.model'; export * from './cone-search.model'; export * from './resolver.model'; export * from './search-multiple-dataset-length'; -export * from './search-multiple-dataset-data'; export * from './svom-keyword.model'; diff --git a/client/src/app/instance/store/models/search-multiple-dataset-data.ts b/client/src/app/instance/store/models/search-multiple-dataset-data.ts deleted file mode 100644 index 0f3d0d86928cb33b5ca735f14aea4fc281b1d4da..0000000000000000000000000000000000000000 --- a/client/src/app/instance/store/models/search-multiple-dataset-data.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. - */ - -/** - * Interface for search multiple data. - * - * @interface SearchMultipleDatasetData - */ -export interface SearchMultipleDatasetData { - datasetName: string; - data: any[]; -} diff --git a/client/src/app/instance/store/reducers/cone-search.reducer.spec.ts b/client/src/app/instance/store/reducers/cone-search.reducer.spec.ts index dabdd0737fb478657d4b7f8f52904d7f39b22e41..ba89431b0742ce45a42ac9cd39f307c195742eb3 100644 --- a/client/src/app/instance/store/reducers/cone-search.reducer.spec.ts +++ b/client/src/app/instance/store/reducers/cone-search.reducer.spec.ts @@ -20,7 +20,6 @@ describe('[Instance][Store] ConeSearch reducer', () => { const state = fromConeSearch.coneSearchReducer(initialState, action); expect(state.coneSearch).toEqual(coneSearch); - expect(state.resolver).toBeNull(); expect(state.resolverIsLoading).toBeFalsy(); expect(state.resolverIsLoaded).toBeFalsy(); expect(state).not.toBe(initialState); @@ -35,7 +34,6 @@ describe('[Instance][Store] ConeSearch reducer', () => { const state = fromConeSearch.coneSearchReducer(initialState, action); expect(state.coneSearch).toBeNull(); - expect(state.resolver).toBeNull(); expect(state.resolverIsLoading).toBeFalsy(); expect(state.resolverIsLoaded).toBeFalsy(); expect(state).not.toBe(initialState); @@ -47,7 +45,6 @@ describe('[Instance][Store] ConeSearch reducer', () => { const state = fromConeSearch.coneSearchReducer(initialState, action); expect(state.coneSearch).toBeNull(); - expect(state.resolver).toBeNull(); expect(state.resolverIsLoading).toBeTruthy(); expect(state.resolverIsLoaded).toBeFalsy(); expect(state).not.toBe(initialState); @@ -74,7 +71,6 @@ describe('[Instance][Store] ConeSearch reducer', () => { const state = fromConeSearch.coneSearchReducer(initialState, action); expect(state.coneSearch).toBeNull(); - expect(state.resolver).toBeNull(); expect(state.resolverIsLoading).toBeFalsy(); expect(state.resolverIsLoaded).toBeFalsy(); expect(state).not.toBe(initialState); @@ -87,13 +83,6 @@ describe('[Instance][Store] ConeSearch reducer', () => { expect(fromConeSearch.selectConeSearch(state)).toBeNull(); }); - it('should get resolver', () => { - const action = {} as Action; - const state = fromConeSearch.coneSearchReducer(undefined, action); - - expect(fromConeSearch.selectResolver(state)).toBeNull(); - }); - it('should get resolverIsLoading', () => { const action = {} as Action; const state = fromConeSearch.coneSearchReducer(undefined, action); diff --git a/client/src/app/instance/store/reducers/cone-search.reducer.ts b/client/src/app/instance/store/reducers/cone-search.reducer.ts index c76d862030ccf3a74ac8c853a4846688c3b992f0..558e1a27d9a24f63163c5a3ed8cc9591300e1e63 100644 --- a/client/src/app/instance/store/reducers/cone-search.reducer.ts +++ b/client/src/app/instance/store/reducers/cone-search.reducer.ts @@ -10,7 +10,7 @@ import { createReducer, on } from '@ngrx/store'; import * as coneSearchActions from '../actions/cone-search.actions'; -import { ConeSearch, Resolver } from '../models'; +import { ConeSearch } from '../models'; /** * Interface for cone search state. @@ -19,14 +19,12 @@ import { ConeSearch, Resolver } from '../models'; */ export interface State { coneSearch: ConeSearch; - resolver: Resolver; resolverIsLoading: boolean; resolverIsLoaded: boolean; } export const initialState: State = { coneSearch: null, - resolver: null, resolverIsLoading: false, resolverIsLoaded: false } @@ -61,6 +59,5 @@ export const coneSearchReducer = createReducer( ); export const selectConeSearch = (state: State) => state.coneSearch; -export const selectResolver = (state: State) => state.resolver; export const selectResolverIsLoading = (state: State) => state.resolverIsLoading; export const selectResolverIsLoaded = (state: State) => state.resolverIsLoaded; diff --git a/client/src/app/instance/store/reducers/search-multiple.reducer.spec.ts b/client/src/app/instance/store/reducers/search-multiple.reducer.spec.ts index e270b579ada00ea021adfe65537f7d1d48650022..100956512dce5d1972799579f6f6f50fe5a74914 100644 --- a/client/src/app/instance/store/reducers/search-multiple.reducer.spec.ts +++ b/client/src/app/instance/store/reducers/search-multiple.reducer.spec.ts @@ -2,7 +2,7 @@ import { Action } from '@ngrx/store'; import * as fromSearchMultiple from './search-multiple.reducer'; import * as searchMultipleActions from '../actions/search-multiple.actions'; -import { SearchMultipleDatasetData, SearchMultipleDatasetLength } from '../models'; +import { SearchMultipleDatasetLength } from '../models'; describe('[Instance][Store] SearchMultiple reducer', () => { it('unknown action should return the default state', () => { @@ -20,16 +20,12 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toEqual('position'); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(0); expect(state.dataLengthIsLoading).toBeFalsy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -40,16 +36,12 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toEqual('myStep'); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(0); expect(state.dataLengthIsLoading).toBeFalsy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -60,16 +52,12 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeFalsy(); expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(0); expect(state.dataLengthIsLoading).toBeFalsy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -80,16 +68,12 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeTruthy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(0); expect(state.dataLengthIsLoading).toBeFalsy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -100,16 +84,12 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeTruthy(); expect(state.selectedDatasets.length).toEqual(0); expect(state.dataLengthIsLoading).toBeFalsy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -121,7 +101,6 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(1); @@ -129,9 +108,6 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.dataLengthIsLoading).toBeFalsy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -145,16 +121,12 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(0); expect(state.dataLengthIsLoading).toBeTruthy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -169,7 +141,6 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(0); @@ -177,9 +148,6 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.dataLengthIsLoaded).toBeTruthy(); expect(state.dataLength.length).toEqual(1); expect(state.dataLength).toEqual(dataLength); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -193,87 +161,12 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); expect(state.datasetsStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.selectedDatasets.length).toEqual(0); expect(state.dataLengthIsLoading).toBeFalsy(); expect(state.dataLengthIsLoaded).toBeFalsy(); expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); - expect(state).not.toBe(initialState); - }); - - it('retrieveData action should set dataIsLoading to true and dataIsLoaded to false', () => { - const initialState = { - ...fromSearchMultiple.initialState, - dataIsLoaded: true - }; - const action = searchMultipleActions.retrieveData(); - const state = fromSearchMultiple.searchMultipleReducer(initialState, action); - - expect(state.pristine).toBeTruthy(); - expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); - expect(state.datasetsStepChecked).toBeFalsy(); - expect(state.resultStepChecked).toBeFalsy(); - expect(state.selectedDatasets.length).toEqual(0); - expect(state.dataLengthIsLoading).toBeFalsy(); - expect(state.dataLengthIsLoaded).toBeFalsy(); - expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeTruthy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); - expect(state).not.toBe(initialState); - }); - - it('retrieveDataSuccess action should set data, set dataIsLoading to false and dataIsLoaded to true', () => { - const initialState = { - ...fromSearchMultiple.initialState, - dataIsLoading: true - }; - const data: SearchMultipleDatasetData[] = [{ datasetName: 'myDataset', data: ['myData'] }]; - const action = searchMultipleActions.retrieveDataSuccess({ data }); - const state = fromSearchMultiple.searchMultipleReducer(initialState, action); - - expect(state.pristine).toBeTruthy(); - expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); - expect(state.datasetsStepChecked).toBeFalsy(); - expect(state.resultStepChecked).toBeFalsy(); - expect(state.selectedDatasets.length).toEqual(0); - expect(state.dataLengthIsLoading).toBeFalsy(); - expect(state.dataLengthIsLoaded).toBeFalsy(); - expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeTruthy(); - expect(state.data.length).toEqual(1); - expect(state.data).toEqual(data); - expect(state).not.toBe(initialState); - }); - - it('retrieveDataFail action should set dataIsLoading to false', () => { - const initialState = { - ...fromSearchMultiple.initialState, - dataIsLoading: true - }; - const action = searchMultipleActions.retrieveDataFail(); - const state = fromSearchMultiple.searchMultipleReducer(initialState, action); - - expect(state.pristine).toBeTruthy(); - expect(state.currentStep).toBeNull(); - expect(state.positionStepChecked).toBeFalsy(); - expect(state.datasetsStepChecked).toBeFalsy(); - expect(state.resultStepChecked).toBeFalsy(); - expect(state.selectedDatasets.length).toEqual(0); - expect(state.dataLengthIsLoading).toBeFalsy(); - expect(state.dataLengthIsLoaded).toBeFalsy(); - expect(state.dataLength.length).toEqual(0); - expect(state.dataIsLoading).toBeFalsy(); - expect(state.dataIsLoaded).toBeFalsy(); - expect(state.data.length).toEqual(0); expect(state).not.toBe(initialState); }); @@ -291,13 +184,6 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(fromSearchMultiple.selectCurrentStep(state)).toBeNull(); }); - it('should get positionStepChecked', () => { - const action = {} as Action; - const state = fromSearchMultiple.searchMultipleReducer(undefined, action); - - expect(fromSearchMultiple.selectPositionStepChecked(state)).toBeFalsy(); - }); - it('should get datasetsStepChecked', () => { const action = {} as Action; const state = fromSearchMultiple.searchMultipleReducer(undefined, action); @@ -339,25 +225,4 @@ describe('[Instance][Store] SearchMultiple reducer', () => { expect(fromSearchMultiple.selectDataLength(state).length).toEqual(0); }); - - it('should get dataIsLoading', () => { - const action = {} as Action; - const state = fromSearchMultiple.searchMultipleReducer(undefined, action); - - expect(fromSearchMultiple.selectDataIsLoading(state)).toBeFalsy(); - }); - - it('should get dataIsLoaded', () => { - const action = {} as Action; - const state = fromSearchMultiple.searchMultipleReducer(undefined, action); - - expect(fromSearchMultiple.selectDataIsLoaded(state)).toBeFalsy(); - }); - - it('should get data', () => { - const action = {} as Action; - const state = fromSearchMultiple.searchMultipleReducer(undefined, action); - - expect(fromSearchMultiple.selectData(state).length).toEqual(0); - }); }); diff --git a/client/src/app/instance/store/reducers/search-multiple.reducer.ts b/client/src/app/instance/store/reducers/search-multiple.reducer.ts index d5cf3af087b2055e2b0caa99b846102e2c363ba2..1d6c8dfa17dec55d1bb1686654ba8739dccdf600 100644 --- a/client/src/app/instance/store/reducers/search-multiple.reducer.ts +++ b/client/src/app/instance/store/reducers/search-multiple.reducer.ts @@ -9,7 +9,7 @@ import { createReducer, on } from '@ngrx/store'; -import { SearchMultipleDatasetLength, SearchMultipleDatasetData } from '../models'; +import { SearchMultipleDatasetLength } from '../models'; import * as searchMultipleActions from '../actions/search-multiple.actions'; /** @@ -20,32 +20,23 @@ import * as searchMultipleActions from '../actions/search-multiple.actions'; export interface State { pristine: boolean; currentStep: string; - // TODO: remove unused positionStepChecked variable - positionStepChecked: boolean; datasetsStepChecked: boolean; resultStepChecked: boolean; selectedDatasets: string[]; dataLengthIsLoading: boolean; dataLengthIsLoaded: boolean; dataLength: SearchMultipleDatasetLength[]; - dataIsLoading: boolean; - dataIsLoaded: boolean; - data: SearchMultipleDatasetData[]; } export const initialState: State = { pristine: true, currentStep: null, - positionStepChecked: false, datasetsStepChecked: false, resultStepChecked: false, selectedDatasets: [], dataLengthIsLoading: false, dataLengthIsLoaded: false, - dataLength: [], - dataIsLoading: false, - dataIsLoaded: false, - data: [] + dataLength: [] }; export const searchMultipleReducer = createReducer( @@ -88,33 +79,14 @@ export const searchMultipleReducer = createReducer( on(searchMultipleActions.retrieveDataLengthFail, state => ({ ...state, dataLengthIsLoading: false - })), - on(searchMultipleActions.retrieveData, state => ({ - ...state, - dataIsLoading: true, - dataIsLoaded: false - })), - on(searchMultipleActions.retrieveDataSuccess, (state, { data }) => ({ - ...state, - data, - dataIsLoading: false, - dataIsLoaded: true - })), - on(searchMultipleActions.retrieveDataFail, state => ({ - ...state, - dataIsLoading: false })) ); export const selectPristine = (state: State) => state.pristine; export const selectCurrentStep = (state: State) => state.currentStep; -export const selectPositionStepChecked = (state: State) => state.positionStepChecked; export const selectDatasetsStepChecked = (state: State) => state.datasetsStepChecked; export const selectResultStepChecked = (state: State) => state.resultStepChecked; export const selectSelectedDatasets = (state: State) => state.selectedDatasets; export const selectDataLengthIsLoading = (state: State) => state.dataLengthIsLoading; export const selectDataLengthIsLoaded = (state: State) => state.dataLengthIsLoaded; export const selectDataLength = (state: State) => state.dataLength; -export const selectDataIsLoading = (state: State) => state.dataIsLoading; -export const selectDataIsLoaded = (state: State) => state.dataIsLoaded; -export const selectData = (state: State) => state.data; diff --git a/client/src/app/instance/store/reducers/search.reducer.spec.ts b/client/src/app/instance/store/reducers/search.reducer.spec.ts index b89b21eecb2c35cb02498049230a399e401c01bb..b39b17eccec5f9f89d9759432d038512af1d6c9b 100644 --- a/client/src/app/instance/store/reducers/search.reducer.spec.ts +++ b/client/src/app/instance/store/reducers/search.reducer.spec.ts @@ -20,8 +20,8 @@ describe('[Instance][Store] Search reducer', () => { expect(state.pristine).toBeTruthy(); expect(state.currentDataset).toBeNull(); - expect(state.currentStep).toBe('dataset'); - expect(state.criteriaStepChecked).toBeFalsy(); + expect(state.currentStep).toBe('criteria'); + expect(state.criteriaStepChecked).toBeTruthy(); expect(state.outputStepChecked).toBeFalsy(); expect(state.resultStepChecked).toBeFalsy(); expect(state.coneSearchAdded).toBeFalsy(); diff --git a/client/src/app/instance/store/reducers/search.reducer.ts b/client/src/app/instance/store/reducers/search.reducer.ts index acceaacc730dd72a1724f8c698d6c21969c167ea..e00a8b3b0c4a9cb2f27bd72fac886af543ad109a 100644 --- a/client/src/app/instance/store/reducers/search.reducer.ts +++ b/client/src/app/instance/store/reducers/search.reducer.ts @@ -59,7 +59,8 @@ export const searchReducer = createReducer( initialState, on(searchActions.restartSearch, () => ({ ...initialState, - currentStep: 'dataset' + currentStep: 'criteria', + criteriaStepChecked: true })), on(searchActions.changeStep, (state, { step }) => ({ ...state, diff --git a/client/src/app/instance/store/selectors/cone-search.selector.spec.ts b/client/src/app/instance/store/selectors/cone-search.selector.spec.ts index 81414c207e6609015ab05152f7dbf1a64be488a5..6ea6f013ac2b287433063f40a485deb2d0c0e39c 100644 --- a/client/src/app/instance/store/selectors/cone-search.selector.spec.ts +++ b/client/src/app/instance/store/selectors/cone-search.selector.spec.ts @@ -7,11 +7,6 @@ describe('[Instance][Store] Cone search selector', () => { expect(coneSearchSelector.selectConeSearch(state)).toBeNull(); }); - it('should get resolver', () => { - const state = { instance: { coneSearch: { ...fromConeSearch.initialState }}}; - expect(coneSearchSelector.selectResolver(state)).toBeNull(); - }); - it('should get resolverIsLoading', () => { const state = { instance: { coneSearch: { ...fromConeSearch.initialState }}}; expect(coneSearchSelector.selectResolverIsLoading(state)).toBeFalsy(); diff --git a/client/src/app/instance/store/selectors/cone-search.selector.ts b/client/src/app/instance/store/selectors/cone-search.selector.ts index 695bba185eacc01db90b4dfface55f691ee3d3c7..88da0162faca7fa25ab80f8a34152c0633301cfb 100644 --- a/client/src/app/instance/store/selectors/cone-search.selector.ts +++ b/client/src/app/instance/store/selectors/cone-search.selector.ts @@ -22,11 +22,6 @@ export const selectConeSearch = createSelector( fromConeSearch.selectConeSearch ); -export const selectResolver = createSelector( - selectConeSearchState, - fromConeSearch.selectResolver -); - export const selectResolverIsLoading = createSelector( selectConeSearchState, fromConeSearch.selectResolverIsLoading diff --git a/client/src/app/instance/store/selectors/search-multiple.selector.spec.ts b/client/src/app/instance/store/selectors/search-multiple.selector.spec.ts index 8c39e57671523b10719ad24cd6a38688c038f27c..4a9d88b4e94c260ceb4a5cb5c1c27ab070570d32 100644 --- a/client/src/app/instance/store/selectors/search-multiple.selector.spec.ts +++ b/client/src/app/instance/store/selectors/search-multiple.selector.spec.ts @@ -14,11 +14,6 @@ describe('[Instance][Store] Search multiple selector', () => { expect(searchMultipleSelector.selectCurrentStep(state)).toBeNull(); }); - it('should get positionStepChecked', () => { - const state = { instance: { searchMultiple: { ...fromSearchMultiple.initialState }}}; - expect(searchMultipleSelector.selectPositionStepChecked(state)).toBeFalsy(); - }); - it('should get datasetsStepChecked', () => { const state = { instance: { searchMultiple: { ...fromSearchMultiple.initialState }}}; expect(searchMultipleSelector.selectDatasetsStepChecked(state)).toBeFalsy(); @@ -49,21 +44,6 @@ describe('[Instance][Store] Search multiple selector', () => { expect(searchMultipleSelector.selectDataLength(state).length).toEqual(0); }); - it('should get dataIsLoading', () => { - const state = { instance: { searchMultiple: { ...fromSearchMultiple.initialState }}}; - expect(searchMultipleSelector.selectDataIsLoading(state)).toBeFalsy(); - }); - - it('should get dataIsLoaded', () => { - const state = { instance: { searchMultiple: { ...fromSearchMultiple.initialState }}}; - expect(searchMultipleSelector.selectDataIsLoaded(state)).toBeFalsy(); - }); - - it('should get data', () => { - const state = { instance: { searchMultiple: { ...fromSearchMultiple.initialState }}}; - expect(searchMultipleSelector.selectData(state).length).toEqual(0); - }); - it('should get queryParams', () => { const state = { instance: { diff --git a/client/src/app/instance/store/selectors/search-multiple.selector.ts b/client/src/app/instance/store/selectors/search-multiple.selector.ts index f5055252ac1ed66365347b032d52e43bc1ca99d7..1175f6316d238ed0a969a76a88de3f7d75edd5e9 100644 --- a/client/src/app/instance/store/selectors/search-multiple.selector.ts +++ b/client/src/app/instance/store/selectors/search-multiple.selector.ts @@ -29,11 +29,6 @@ export const selectCurrentStep = createSelector( fromSearchMultiple.selectCurrentStep ); -export const selectPositionStepChecked = createSelector( - selectSearchMultipleState, - fromSearchMultiple.selectPositionStepChecked -); - export const selectDatasetsStepChecked = createSelector( selectSearchMultipleState, fromSearchMultiple.selectDatasetsStepChecked @@ -64,21 +59,6 @@ export const selectDataLength = createSelector( fromSearchMultiple.selectDataLength ); -export const selectDataIsLoading = createSelector( - selectSearchMultipleState, - fromSearchMultiple.selectDataIsLoading -); - -export const selectDataIsLoaded = createSelector( - selectSearchMultipleState, - fromSearchMultiple.selectDataIsLoaded -); - -export const selectData = createSelector( - selectSearchMultipleState, - fromSearchMultiple.selectData -); - export const selectQueryParams = createSelector( coneSearchSelector.selectConeSearch, selectSelectedDatasets, diff --git a/client/src/app/metamodel/actions/attribute.actions.ts b/client/src/app/metamodel/actions/attribute.actions.ts index 4bd5d6401e8c0218f9f3e5a5fefe9bee4d048189..63c9f6f8d3f2fa5677cc39ab678759dd83cdd1fe 100644 --- a/client/src/app/metamodel/actions/attribute.actions.ts +++ b/client/src/app/metamodel/actions/attribute.actions.ts @@ -11,6 +11,7 @@ import { createAction, props } from '@ngrx/store'; import { Attribute } from '../models'; +export const resetAttributeList = createAction('[Metamodel] Reset Attribute List'); export const loadAttributeList = createAction('[Metamodel] Load Attribute List'); export const loadAttributeListSuccess = createAction('[Metamodel] Load Attribute List Success', props<{ attributes: Attribute[] }>()); export const loadAttributeListFail = createAction('[Metamodel] Load Attribute List Fail'); diff --git a/client/src/app/metamodel/actions/cone-search-config.actions.ts b/client/src/app/metamodel/actions/cone-search-config.actions.ts index e9346bb57052fcfd95422f00f35073addd19450d..7ca1e7d963b5f6f738a6ccd69a5fa9ace58d53dd 100644 --- a/client/src/app/metamodel/actions/cone-search-config.actions.ts +++ b/client/src/app/metamodel/actions/cone-search-config.actions.ts @@ -11,6 +11,7 @@ import { createAction, props } from '@ngrx/store'; import { ConeSearchConfig } from '../models'; +export const resetConeSearchConfig = createAction('[Metamodel] Reset Cone Search Config'); export const loadConeSearchConfig = createAction('[Metamodel] Load Cone Search Config'); export const loadConeSearchConfigSuccess = createAction('[Metamodel] Load Cone Search Config Success', props<{ coneSearchConfig: ConeSearchConfig }>()); export const loadConeSearchConfigFail = createAction('[Metamodel] Load Cone Search Config Fail'); diff --git a/client/src/app/metamodel/models/cone-search-config.model.ts b/client/src/app/metamodel/models/cone-search-config.model.ts index b067ff0d41911a9158e27cf8387b37ddf2c02dac..85228e87e9dabb4fb8304b680e32caa9086ed11f 100644 --- a/client/src/app/metamodel/models/cone-search-config.model.ts +++ b/client/src/app/metamodel/models/cone-search-config.model.ts @@ -18,5 +18,10 @@ export interface ConeSearchConfig { opened: boolean; column_ra: number; column_dec: number; + resolver_enabled: boolean; + default_ra: number; + default_dec: number; + default_radius: number; + default_ra_dec_unit: string; plot_enabled: boolean; } diff --git a/client/src/app/metamodel/reducers/attribute.reducer.ts b/client/src/app/metamodel/reducers/attribute.reducer.ts index 3def9fef90535dcb6dcf5875d2b84dd7dbe78ebc..a50f4bd65e25253252332713e59be56fb5568bba 100644 --- a/client/src/app/metamodel/reducers/attribute.reducer.ts +++ b/client/src/app/metamodel/reducers/attribute.reducer.ts @@ -32,6 +32,11 @@ export const initialState: State = adapter.getInitialState({ export const attributeReducer = createReducer( initialState, + on(attributeActions.resetAttributeList, () => { + return { + ...initialState + } + }), on(attributeActions.loadAttributeList, (state) => { return { ...state, diff --git a/client/src/app/metamodel/reducers/cone-search-config.reducer.ts b/client/src/app/metamodel/reducers/cone-search-config.reducer.ts index b2aa464a313e29e61879fde21d8776b7ae0b60a8..5caea58a28b95e08867d6a0be736aa609b5d85c8 100644 --- a/client/src/app/metamodel/reducers/cone-search-config.reducer.ts +++ b/client/src/app/metamodel/reducers/cone-search-config.reducer.ts @@ -31,6 +31,11 @@ export const initialState: State = { export const coneSearchConfigReducer = createReducer( initialState, + on(coneSearchActions.resetConeSearchConfig, () => { + return { + ...initialState + } + }), on(coneSearchActions.loadConeSearchConfig, (state) => { return { ...state, diff --git a/conf-dev/create-db.sh b/conf-dev/create-db.sh index 5375f265fba8f6083b3c1271ec6a9a1ca3e9ee1f..d2bc1ce19ec154f1a38463dc76a1bbd7847dc23c 100644 --- a/conf-dev/create-db.sh +++ b/conf-dev/create-db.sh @@ -96,7 +96,7 @@ curl -d '{"id":6,"name":"zflag","label":"zflag","form_label":"zflag","descriptio curl -d '{"id":7,"name":"sel_mag","label":"sel_mag","form_label":"sel_mag","description":null,"primary_key":false,"output_display":70,"criteria_display":70,"search_type":"between","type":"decimal","operator":null,"dynamic_operator":true,"min":null,"max":null,"placeholder_min":null,"placeholder_max":null,"renderer":null,"renderer_config":null,"detail_display":70,"selected":true,"order_by":true,"archive":false,"detail":false,"options":null,"vo_utype":null,"vo_ucd":null,"vo_unit":null,"vo_description":null,"vo_datatype":null,"vo_size":null,"id_criteria_family":4,"id_output_category":5,"id_detail_output_category":null}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vvds_f02_udeep/attribute # Add vvds_f02_udeep cone search -curl -d '{"enabled":true,"opened":false,"column_ra":3,"column_dec":4,"plot_enabled":true}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vvds_f02_udeep/cone-search-config +curl -d '{"enabled":true,"opened":false,"column_ra":3,"column_dec":4,"resolver_enabled":true,"default_ra":null,"default_dec":null,"default_radius":2.0,"default_ra_dec_unit":"degree","plot_enabled":true}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vvds_f02_udeep/cone-search-config # Add vvds_f02_udeep image curl -d '{"label":"Mag i","file_path":"/IMAGES/CFHTLS_D-85_i_022559-042940_T0007_MEDIAN.fits","file_size":1498320000,"ra_min":35.994643451078,"ra_max":36.99765934121,"dec_min":-3.9943006310031,"dec_max":-4.9941936740893,"stretch":"linear","pmin":0.2,"pmax":99}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vvds_f02_udeep/image diff --git a/server/doctrine-proxy/__CG__AppEntityConeSearchConfig.php b/server/doctrine-proxy/__CG__AppEntityConeSearchConfig.php index 42b64ffdbbd31efbafd96e552dc2cae97e7ad7aa..ddb98c40f3fbbe5c9766ed6fb22b52f66d0a498c 100644 --- a/server/doctrine-proxy/__CG__AppEntityConeSearchConfig.php +++ b/server/doctrine-proxy/__CG__AppEntityConeSearchConfig.php @@ -67,10 +67,10 @@ class ConeSearchConfig extends \App\Entity\ConeSearchConfig implements \Doctrine public function __sleep() { if ($this->__isInitialized__) { - return ['__isInitialized__', 'id', 'enabled', 'opened', 'columnRa', 'columnDec', 'plotEnabled']; + return ['__isInitialized__', 'id', 'enabled', 'opened', 'columnRa', 'columnDec', 'resolverEnabled', 'defaultRa', 'defaultDec', 'defaultRadius', 'defaultRaDecUnit', 'plotEnabled']; } - return ['__isInitialized__', 'id', 'enabled', 'opened', 'columnRa', 'columnDec', 'plotEnabled']; + return ['__isInitialized__', 'id', 'enabled', 'opened', 'columnRa', 'columnDec', 'resolverEnabled', 'defaultRa', 'defaultDec', 'defaultRadius', 'defaultRaDecUnit', 'plotEnabled']; } /** @@ -280,6 +280,116 @@ class ConeSearchConfig extends \App\Entity\ConeSearchConfig implements \Doctrine return parent::setColumnDec($columnDec); } + /** + * {@inheritDoc} + */ + public function getResolverEnabled() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getResolverEnabled', []); + + return parent::getResolverEnabled(); + } + + /** + * {@inheritDoc} + */ + public function setResolverEnabled($resolverEnabled) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setResolverEnabled', [$resolverEnabled]); + + return parent::setResolverEnabled($resolverEnabled); + } + + /** + * {@inheritDoc} + */ + public function getDefaultRa() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDefaultRa', []); + + return parent::getDefaultRa(); + } + + /** + * {@inheritDoc} + */ + public function setDefaultRa($defaultRa) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDefaultRa', [$defaultRa]); + + return parent::setDefaultRa($defaultRa); + } + + /** + * {@inheritDoc} + */ + public function getDefaultDec() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDefaultDec', []); + + return parent::getDefaultDec(); + } + + /** + * {@inheritDoc} + */ + public function setDefaultDec($defaultDec) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDefaultDec', [$defaultDec]); + + return parent::setDefaultDec($defaultDec); + } + + /** + * {@inheritDoc} + */ + public function getDefaultRadius() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDefaultRadius', []); + + return parent::getDefaultRadius(); + } + + /** + * {@inheritDoc} + */ + public function setDefaultRadius($defaultRadius) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDefaultRadius', [$defaultRadius]); + + return parent::setDefaultRadius($defaultRadius); + } + + /** + * {@inheritDoc} + */ + public function getDefaultRaDecUnit() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDefaultRaDecUnit', []); + + return parent::getDefaultRaDecUnit(); + } + + /** + * {@inheritDoc} + */ + public function setDefaultRaDecUnit($defaultRaDecUnit) + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDefaultRaDecUnit', [$defaultRaDecUnit]); + + return parent::setDefaultRaDecUnit($defaultRaDecUnit); + } + /** * {@inheritDoc} */ diff --git a/server/src/Action/ConeSearchConfigAction.php b/server/src/Action/ConeSearchConfigAction.php index 8d2be835b9111cf14dce36c513c6ab3832d920e8..a6ab51eacc374e49ae00447ada44cff3704ac3f2 100644 --- a/server/src/Action/ConeSearchConfigAction.php +++ b/server/src/Action/ConeSearchConfigAction.php @@ -108,6 +108,11 @@ final class ConeSearchConfigAction extends AbstractAction 'opened', 'column_ra', 'column_dec', + 'resolver_enabled', + 'default_ra', + 'default_dec', + 'default_radius', + 'default_ra_dec_unit', 'plot_enabled' ); @@ -135,6 +140,11 @@ final class ConeSearchConfigAction extends AbstractAction $coneSearchConfig->setOpened($parsedBody['opened']); $coneSearchConfig->setColumnRa($parsedBody['column_ra']); $coneSearchConfig->setColumnDec($parsedBody['column_dec']); + $coneSearchConfig->setResolverEnabled($parsedBody['resolver_enabled']); + $coneSearchConfig->setDefaultRa($parsedBody['default_ra']); + $coneSearchConfig->setDefaultDec($parsedBody['default_dec']); + $coneSearchConfig->setDefaultRadius($parsedBody['default_radius']); + $coneSearchConfig->setDefaultRaDecUnit($parsedBody['default_ra_dec_unit']); $coneSearchConfig->setPlotEnabled($parsedBody['plot_enabled']); $dataset->setConeSearchConfig($coneSearchConfig); @@ -157,6 +167,11 @@ final class ConeSearchConfigAction extends AbstractAction $coneSearchConfig->setOpened($parsedBody['opened']); $coneSearchConfig->setColumnRa($parsedBody['column_ra']); $coneSearchConfig->setColumnDec($parsedBody['column_dec']); + $coneSearchConfig->setResolverEnabled($parsedBody['resolver_enabled']); + $coneSearchConfig->setDefaultRa($parsedBody['default_ra']); + $coneSearchConfig->setDefaultDec($parsedBody['default_dec']); + $coneSearchConfig->setDefaultRadius($parsedBody['default_radius']); + $coneSearchConfig->setDefaultRaDecUnit($parsedBody['default_ra_dec_unit']); $coneSearchConfig->setPlotEnabled($parsedBody['plot_enabled']); $this->em->flush(); } diff --git a/server/src/Entity/ConeSearchConfig.php b/server/src/Entity/ConeSearchConfig.php index 5d63582526a9eb85dc4ae9de723eaeb61dbe7345..9ec28c9fd6e357278983990a73dfe1245490186c 100644 --- a/server/src/Entity/ConeSearchConfig.php +++ b/server/src/Entity/ConeSearchConfig.php @@ -58,6 +58,41 @@ class ConeSearchConfig implements \JsonSerializable */ protected $columnDec; + /** + * @var bool + * + * @Column(type="boolean", name="resolver_enabled", nullable=false, options={"default" : true}) + */ + protected $resolverEnabled; + + /** + * @var float + * + * @Column(type="float", name="default_ra", nullable=true) + */ + protected $defaultRa; + + /** + * @var float + * + * @Column(type="float", name="default_dec", nullable=true) + */ + protected $defaultDec; + + /** + * @var float + * + * @Column(type="float", name="default_radius", nullable=false, options={"default" : "2.0"})) + */ + protected $defaultRadius; + + /** + * @var string + * + * @Column(type="string", name="default_ra_dec_unit", nullable=false, options={"default" : "degree"})) + */ + protected $defaultRaDecUnit; + /** * @var bool * @@ -110,6 +145,56 @@ class ConeSearchConfig implements \JsonSerializable $this->columnDec = $columnDec; } + public function getResolverEnabled() + { + return $this->resolverEnabled; + } + + public function setResolverEnabled($resolverEnabled) + { + $this->resolverEnabled = $resolverEnabled; + } + + public function getDefaultRa() + { + return $this->defaultRa; + } + + public function setDefaultRa($defaultRa) + { + $this->defaultRa = $defaultRa; + } + + public function getDefaultDec() + { + return $this->defaultDec; + } + + public function setDefaultDec($defaultDec) + { + $this->defaultDec = $defaultDec; + } + + public function getDefaultRadius() + { + return $this->defaultRadius; + } + + public function setDefaultRadius($defaultRadius) + { + $this->defaultRadius = $defaultRadius; + } + + public function getDefaultRaDecUnit() + { + return $this->defaultRaDecUnit; + } + + public function setDefaultRaDecUnit($defaultRaDecUnit) + { + $this->defaultRaDecUnit = $defaultRaDecUnit; + } + public function getPlotEnabled() { return $this->plotEnabled; @@ -128,7 +213,12 @@ class ConeSearchConfig implements \JsonSerializable 'opened' => $this->getOpened(), 'column_ra' => $this->getColumnRa(), 'column_dec' => $this->getColumnDec(), - 'plot_enabled' => $this->getPlotEnabled(), + 'resolver_enabled' => $this->getResolverEnabled(), + 'default_ra' => $this->getDefaultRa(), + 'default_dec' => $this->getDefaultDec(), + 'default_radius' => $this->getDefaultRadius(), + 'default_ra_dec_unit' => $this->getDefaultRaDecUnit(), + 'plot_enabled' => $this->getPlotEnabled() ]; } }