Skip to content
Snippets Groups Projects
Commit f9ca4532 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Datasets page components created

parent 94ccaa42
No related branches found
No related tags found
2 merge requests!147Develop,!137Resolve "[Module Multiple] : ajouter le nouveau module"
Showing
with 401 additions and 220 deletions
<!--<div class="row">-->
<!-- <div *ngFor="let category of getCategoryByFamilySortedByDisplay(outputFamily.id)"-->
<!-- class="col-12 col-md-6 my-3 text-center">-->
<!-- <app-output-by-category -->
<!-- [categoryLabel]="category.label" -->
<!-- [attributeList]="getAttributeByCategory(category.id)"-->
<!-- [outputList]="outputList" -->
<!-- [isAllSelected]="getIsAllSelected(category.id)"-->
<!-- [isAllUnselected]="getIsAllUnselected(category.id)" -->
<!-- (change)="emitChange($event)">-->
<!-- </app-output-by-category>-->
<!-- </div>-->
<!--</div>-->
toto
\ No newline at end of file
// import { async, ComponentFixture, TestBed } from '@angular/core/testing';
// import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
//
// import { DatasetListComponent } from './output-by-family.component';
// import { Attribute, Family, Category } from '../../../metamodel/model';
// import { ATTRIBUTE_LIST, OUTPUT_FAMILY, CATEGORY_LIST } from '../../../../settings/test-data';
//
// describe('[Search][Output] Component: OutputByFamilyComponent', () => {
// @Component({
// selector: `app-host`,
// template: `
// <app-output-by-family
// [outputFamily]="outputFamily"
// [datasetAttributeList]="datasetAttributeList"
// [categoryList]="categoryList"
// [outputList]="outputList">
// </app-output-by-family>`
// })
// class TestHostComponent {
// @ViewChild(DatasetListComponent, { static: false })
// public testedComponent: DatasetListComponent;
// public outputFamily: Family = OUTPUT_FAMILY;
// public datasetAttributeList: Attribute[] = ATTRIBUTE_LIST;
// public categoryList: Category[] = CATEGORY_LIST;
// public outputList: number[] = [1];
// }
//
// @Component({ selector: 'app-output-by-category', template: '' })
// class OutputByCategoryStubComponent {
// @Input() categoryLabel: string;
// @Input() attributeList: Attribute[];
// @Input() outputList: number[];
// @Input() isAllSelected: boolean;
// @Input() isAllUnselected: boolean;
// @Output() change: EventEmitter<number[]> = new EventEmitter();
// }
//
// let testHostComponent: TestHostComponent;
// let testHostFixture: ComponentFixture<TestHostComponent>;
// let testedComponent: DatasetListComponent;
//
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// declarations: [
// DatasetListComponent,
// TestHostComponent,
// OutputByCategoryStubComponent
// ]
// });
// testHostFixture = TestBed.createComponent(TestHostComponent);
// testHostComponent = testHostFixture.componentInstance;
// testHostFixture.detectChanges();
// testedComponent = testHostComponent.testedComponent;
// }));
//
// it('should create the component', () => {
// expect(testedComponent).toBeTruthy();
// });
//
// it('#getCategoryByFamilySortedByDisplay(idFamily) should sort by display categories belonging to idFamily', () => {
// const sortedCategoryList: Category[] = testedComponent.getCategoryByFamilySortedByDisplay(1);
// expect(sortedCategoryList.length).toBe(2);
// expect(sortedCategoryList[0].id).toBe(2);
// expect(sortedCategoryList[1].id).toBe(1);
// });
//
// it('#getAttributeByCategory(idCategory) should return attributes belonging to idCategory', () => {
// expect(testedComponent.getAttributeByCategory(1).length).toBe(1);
// expect(testedComponent.getAttributeByCategory(1)[0].id).toBe(1);
// });
//
// it('#getIsAllSelected(idCategory) should return true if all outputs of idCategory are selected', () => {
// expect(testedComponent.getIsAllSelected(1)).toBeTruthy();
// });
//
// it('#getIsAllSelected(idCategory) should return false if not all outputs of idCategory are selected', () => {
// testedComponent.outputList = [];
// expect(testedComponent.getIsAllSelected(1)).toBeFalsy();
// });
//
// it('#getIsAllUnselected(idCategory) should return true if all outputs of idCategory are not selected', () => {
// testedComponent.outputList = [];
// expect(testedComponent.getIsAllUnselected(1)).toBeTruthy();
// });
//
// it('#getIsAllUnselected(idCategory) should return false if not all outputs of idCategory are not selected', () => {
// expect(testedComponent.getIsAllUnselected(1)).toBeFalsy();
// });
//
// it('#emitChange(outputList) should raise change event', () => {
// const expectedOutputList = [1];
// testedComponent.change.subscribe((event: number[]) => expect(event).toEqual(expectedOutputList));
// testedComponent.emitChange([1]);
// });
// });
//
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
// import { Family, Category, Attribute } from '../../../metamodel/model';
// import { sortByDisplay } from '../../../shared/utils';
import { Dataset } from "../../metamodel/model";
@Component({
selector: 'app-dataset-list',
templateUrl: 'dataset-list.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DatasetListComponent {
@Input() datasetList: Dataset[];
@Output() updateDatasetList: EventEmitter<string[]> = new EventEmitter();
// getCategoryByFamilySortedByDisplay(idFamily: number): Category[] {
// return this.categoryList
// .filter(category => category.id_output_family === idFamily)
// .sort(sortByDisplay);
// }
//
// getAttributeByCategory(idCategory: number): Attribute[] {
// return this.datasetAttributeList
// .filter(attribute => attribute.id_output_category === idCategory);
// }
//
// getIsAllSelected(idCategory: number): boolean {
// const attributeListId = this.getAttributeByCategory(idCategory).map(a => a.id);
// const filteredOutputList = this.outputList.filter(id => attributeListId.indexOf(id) > -1);
// return attributeListId.length === filteredOutputList.length;
// }
//
// getIsAllUnselected(idCategory: number): boolean {
// const attributeListId = this.getAttributeByCategory(idCategory).map(a => a.id);
// const filteredOutputList = this.outputList.filter(id => attributeListId.indexOf(id) > -1);
// return filteredOutputList.length === 0;
// }
//
// emitChange(clonedOutputList: number[]): void {
// this.change.emit(
// this.datasetAttributeList
// .filter(a => clonedOutputList.indexOf(a.id) > -1)
// .sort((a, b) => a.output_display - b.output_display)
// .map(a => a.id)
// );
// }
}
<!--<p class="mb-3"><em>{{ categoryLabel }}</em></p>-->
<!--<div class="row mb-1">-->
<!-- <div class="col pr-1">-->
<!-- <button (click)="selectAll()" [disabled]="isAllSelected"-->
<!-- class="btn btn-sm btn-block btn-outline-secondary letter-spacing">-->
<!-- Select All-->
<!-- </button>-->
<!-- </div>-->
<!-- <div class="col pl-1">-->
<!-- <button (click)="unselectAll()" [disabled]="isAllUnselected"-->
<!-- class="btn btn-sm btn-block btn-outline-secondary letter-spacing">-->
<!-- Unselect All-->
<!-- </button>-->
<!-- </div>-->
<!--</div>-->
<!--<div class="selectbox p-0">-->
<!-- <div *ngFor="let attribute of getAttributeListSortedByDisplay()">-->
<!-- <div *ngIf="isSelected(attribute.id)">-->
<!-- <button class="btn btn-block text-left py-1 m-0 rounded-0" (click)="toggleSelection(attribute.id)">-->
<!-- <span class="fas fa-fw fa-check-square theme-color"></span> {{ attribute.form_label }}-->
<!-- </button>-->
<!-- </div>-->
<!-- <div *ngIf="!isSelected(attribute.id)">-->
<!-- <button class="btn btn-block text-left py-1 m-0 rounded-0" (click)="toggleSelection(attribute.id)">-->
<!-- <span class="far fa-fw fa-square text-secondary"></span> {{ attribute.form_label }}-->
<!-- </button>-->
<!-- </div>-->
<!-- </div>-->
<!--</div>-->
datasets by project
\ No newline at end of file
// import { async, ComponentFixture, TestBed } from '@angular/core/testing';
// import { Component, ViewChild } from '@angular/core';
//
// import { DatasetsByProjetComponent } from './output-by-category.component';
// import { Attribute } from '../../../metamodel/model';
// import { ATTRIBUTE_LIST } from '../../../../settings/test-data';
//
// describe('[Search][Output] Component: OutputByCategoryComponent', () => {
// @Component({
// selector: `app-host`,
// template: `
// <app-output-by-category
// [categoryLabel]="categoryLabel"
// [attributeList]="attributeList"
// [outputList]="outputList"
// [isAllSelected]="isAllSelected"
// [isAllUnselected]="isAllUnselected">
// </app-output-by-category>`
// })
// class TestHostComponent {
// @ViewChild(DatasetsByProjetComponent, { static: false })
// public testedComponent: DatasetsByProjetComponent;
// public categoryLabel = 'Default output category';
// public attributeList: Attribute[] = ATTRIBUTE_LIST;
// public outputList: number[] = [1];
// public isAllSelected = true;
// public isAllUnselected: false;
// }
//
// let testHostComponent: TestHostComponent;
// let testHostFixture: ComponentFixture<TestHostComponent>;
// let testedComponent: DatasetsByProjetComponent;
//
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// declarations: [
// DatasetsByProjetComponent,
// TestHostComponent
// ]
// });
// testHostFixture = TestBed.createComponent(TestHostComponent);
// testHostComponent = testHostFixture.componentInstance;
// testHostFixture.detectChanges();
// testedComponent = testHostComponent.testedComponent;
// }));
//
// it('should create the component', () => {
// expect(testedComponent).toBeTruthy();
// });
//
// it('#getAttributeListSortedByDisplay() should sort attributeList by output_display', () => {
// const sortedAttributeList: Attribute[] = testedComponent.getAttributeListSortedByDisplay();
// expect(sortedAttributeList[0].id).toBe(2);
// expect(sortedAttributeList[1].id).toBe(1);
// });
//
// it('#isSelected(idOutput) should return true if output is selected', () => {
// expect(testedComponent.isSelected(1)).toBeTruthy();
// });
//
// it('#isSelected(idOutput) should return false if output is not selected', () => {
// expect(testedComponent.isSelected(2)).toBeFalsy();
// });
//
// it('#toggleSelection(idOutput) should remove idOutput from outputList and raise change event', () => {
// const idOutput = 1;
// const expectedOutputList = [];
// testedComponent.change.subscribe((event: number[]) => expect(event).toEqual(expectedOutputList));
// testedComponent.toggleSelection(idOutput);
// });
//
// it('#toggleSelection(idOutput) should add idOutput to outputList and raise change event', () => {
// const idOutput = 2;
// const expectedOutputList = [1, 2];
// testedComponent.change.subscribe((event: number[]) => expect(event).toEqual(expectedOutputList));
// testedComponent.toggleSelection(idOutput);
// });
//
// it('#selectAll() should add all outputs to outputList and raise change event', () => {
// const expectedOutputList = [1, 2];
// testedComponent.change.subscribe((event: number[]) => expect(event).toEqual(expectedOutputList));
// testedComponent.selectAll();
// });
//
// it('#unselectAll() should remove all outputs to outputList and raise change event', () => {
// const expectedOutputList = [];
// testedComponent.change.subscribe((event: number[]) => expect(event).toEqual(expectedOutputList));
// testedComponent.unselectAll();
// });
// });
//
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import { Dataset } from "../../metamodel/model";
@Component({
selector: 'app-datasets-by-project',
templateUrl: 'datasets-by-projet.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DatasetsByProjetComponent {
@Input() projectLabel: string;
@Input() datasetList: Dataset[];
@Input() isAllSelected: boolean;
@Input() isAllUnselected: boolean;
@Output() change: EventEmitter<number[]> = new EventEmitter();
// getAttributeListSortedByDisplay() {
// return this.attributeList
// .sort((a, b) => a.output_display - b.output_display);
// }
//
// isSelected(id: number) {
// return this.outputList.filter(i => i === id).length > 0;
// }
//
// toggleSelection(attributeId: number): void {
// const clonedOutputList = [...this.outputList];
// const index = clonedOutputList.indexOf(attributeId);
// if (index > -1) {
// clonedOutputList.splice(index, 1);
// } else {
// clonedOutputList.push(attributeId);
// }
// this.change.emit(clonedOutputList);
// }
//
// selectAll(): void {
// const clonedOutputList = [...this.outputList];
// const attributeListId = this.attributeList.map(a => a.id);
// attributeListId.filter(id => clonedOutputList.indexOf(id) === -1).forEach(id => {
// clonedOutputList.push(id);
// });
// this.change.emit(clonedOutputList);
// }
//
// unselectAll(): void {
// const clonedOutputList = [...this.outputList];
// const attributeListId = this.attributeList.map(a => a.id);
// attributeListId.filter(id => clonedOutputList.indexOf(id) > -1).forEach(id => {
// const index = clonedOutputList.indexOf(id);
// clonedOutputList.splice(index, 1);
// });
// this.change.emit(clonedOutputList);
// }
}
import { ProgressBarMultipleComponent } from "./progress-bar-multiple.component";
import { SummaryMultipleComponent } from "./summary-multiple.component";
import { DatasetListComponent } from "./dataset-list.component";
import { DatasetsByProjetComponent } from "./datasets-by-projet.component";
export const dummiesComponents = [
ProgressBarMultipleComponent,
SummaryMultipleComponent
SummaryMultipleComponent,
DatasetListComponent,
DatasetsByProjetComponent
];
\ No newline at end of file
<div *ngIf="datasetSearchMetaIsLoading | async"
class="row justify-content-center mt-5">
<span class="fas fa-circle-notch fa-spin fa-3x"></span>
<span class="sr-only">Loading...</span>
</div>
<div *ngIf="datasetSearchMetaIsLoaded | async" class="row mt-4">
<!-- <div class="col-12">-->
<!-- <app-result-download-->
<!-- [datasetName]="datasetName | async"-->
<!-- [datasetList]="datasetList | async"-->
<!-- [dataLength]="dataLength | async"-->
<!-- [isConeSearchAdded]="isConeSearchAdded | async"-->
<!-- [coneSearch]="coneSearch | async"-->
<!-- [criteriaList]="criteriaList | async"-->
<!-- [outputList]="outputList | async">-->
<!-- </app-result-download>-->
<!-- <app-reminder-->
<!-- [datasetAttributeList]="datasetAttributeList | async"-->
<!-- [isConeSearchAdded]="isConeSearchAdded | async"-->
<!-- [coneSearch]="coneSearch | async"-->
<!-- [criteriaFamilyList]="criteriaFamilyList | async"-->
<!-- [criteriaList]="criteriaList | async"-->
<!-- [outputFamilyList]="outputFamilyList | async"-->
<!-- [categoryList]="categoryList | async"-->
<!-- [outputList]="outputList | async">-->
<!-- </app-reminder>-->
<!-- <app-result-url-display-->
<!-- [datasetList]="datasetList | async"-->
<!-- [datasetName]="datasetName | async"-->
<!-- [isConeSearchAdded]="isConeSearchAdded | async"-->
<!-- [coneSearch]="coneSearch | async"-->
<!-- [criteriaList]="criteriaList | async"-->
<!-- [outputList]="outputList | async">-->
<!-- </app-result-url-display>-->
<!-- <app-result-datatable-->
<!-- [datasetName]="datasetName | async"-->
<!-- [datasetList]="datasetList | async"-->
<!-- [queryParams]="queryParams | async"-->
<!-- [datasetAttributeList]="datasetAttributeList | async"-->
<!-- [outputList]="outputList | async"-->
<!-- [searchData]="searchData | async"-->
<!-- [dataLength]="dataLength | async"-->
<!-- [selectedData]="selectedData | async"-->
<!-- (getSearchData)="getSearchData($event)"-->
<!-- (addSelectedData)="addSearchData($event)"-->
<!-- (deleteSelectedData)="deleteSearchData($event)"-->
<!-- [processWip]="processWip | async"-->
<!-- [processDone]="processDone | async"-->
<!-- [processId]="processId | async"-->
<!-- (executeProcess)="executeProcess($event)">-->
<!-- </app-result-datatable>-->
<!-- </div>-->
<div class="row mt-4">
<div *ngIf="datasetSearchMetaIsLoading | async" class="col-12 col-md-8 col-lg-9 text-center mt-5">
<span class="fas fa-circle-notch fa-spin fa-3x"></span>
<span class="sr-only">Loading...</span>
</div>
<div *ngIf="datasetSearchMetaIsLoaded | async" class="col-12 col-md-8 col-lg-9">
<app-dataset-list [datasetList]="datasetList | async" (updateDatasetList)="updateDatasetList($event)">
</app-dataset-list>
</div>
<div class="col-12 col-md-4 col-lg-3 pt-2">
<app-summary-multiple
[currentStep]="currentStep | async"
[isValidConeSearch]="isValidConeSearch | async"
[coneSearch]="coneSearch | async"
[datasetSearchMetaIsLoading]="datasetSearchMetaIsLoading | async"
[datasetSearchMetaIsLoaded]="datasetSearchMetaIsLoaded | async"
[datasetList]="datasetList | async"
[queryParams]="queryParams | async">
</app-summary-multiple>
</div>
</div>
<div class="row mt-5 justify-content-between">
<div class="col">
......
......@@ -56,4 +56,8 @@ export class DatasetsComponent implements OnInit {
checkStep(): void {
this.store.dispatch(new searchMultipleActions.DatasetsCheckedAction());
}
updateDatasetList(datasetList: string[]) {
console.log(datasetList);
}
}
......@@ -47,7 +47,7 @@ export class PositionComponent implements OnInit {
ngOnInit() {
// 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(new searchActions.InitSearchByUrl()));
Promise.resolve(null).then(() => this.store.dispatch(new searchMultipleActions.InitSearchByUrlAction()));
Promise.resolve(null).then(() => this.store.dispatch(new searchMultipleActions.ChangeStepAction('position')));
this.store.dispatch(new datasetActions.LoadDatasetSearchMetaAction());
this.scrollTopService.setScrollTop();
......
......@@ -7,9 +7,6 @@ import { Store, Action } from '@ngrx/store';
import { of } from 'rxjs';
import { map, tap, switchMap, withLatestFrom, catchError, delay } from 'rxjs/operators';
import * as attributeActions from '../../metamodel/action/attribute.action';
import * as criteriaActions from '../../metamodel/action/criteria.action';
import * as outputActions from '../../metamodel/action/output.action';
import * as searchMultipleActions from './search-multiple.action';
import * as coneSearchActions from '../../shared/cone-search/store/cone-search.action';
import * as fromMetamodel from '../../metamodel/reducers';
......@@ -18,7 +15,6 @@ import * as fromSearchMultiple from './search-multiple.reducer';
import * as fromConeSearch from '../../shared/cone-search/store/cone-search.reducer';
import * as utils from '../../shared/utils';
import { SearchMultipleService } from './search-multiple.service';
import { getCriterionStr } from '../../shared/utils';
import { ConeSearch } from "../../shared/cone-search/store/model";
@Injectable()
......@@ -49,11 +45,11 @@ export class SearchMultipleEffects {
dec: parseFloat(params[1]),
radius: parseInt(params[2], 10)
};
actions.push(new coneSearchActions.AddConeSearchAction(coneSearch));
actions.push(new coneSearchActions.AddConeSearchFromUrlAction(coneSearch));
actions.push(new searchMultipleActions.PositionCheckedAction());
}
if (state.router.state.queryParams.d) {
// actions.push(new searchActions.OutputChecked());
// actions.push(new searchMultipleActions.DatasetsCheckedAction());
}
return actions;
} else {
......@@ -63,120 +59,6 @@ export class SearchMultipleEffects {
);
//
// @Effect()
// newSearchAction$ = this.actions$.pipe(
// ofType(searchActions.NEW_SEARCH),
// map((action: searchActions.NewSearchAction) => new searchActions.SelectDatasetAction(action.payload))
// );
//
// @Effect()
// loadDatasetAttributeListSuccessAction$ = this.actions$.pipe(
// ofType(attributeActions.LOAD_ATTRIBUTE_SEARCH_META_SUCCESS),
// withLatestFrom(this.store$),
// switchMap(([action, state]) => {
// const loadAttributeSearchMetaSuccessAction = action as attributeActions.LoadAttributeSearchMetaSuccessAction;
//
// const actions: Action[] = [];
//
// let defaultOutputList = loadAttributeSearchMetaSuccessAction.payload
// .filter(attribute => attribute.selected && attribute.id_output_category)
// .sort((a, b) => a.output_display - b.output_display)
// .map(attribute => attribute.id);
//
// if (state.router.state.queryParams.a) {
// defaultOutputList = state.router.state.queryParams.a.split(';').map((o: string) => parseInt(o, 10));
// }
//
// actions.push(new searchActions.UpdateOutputListAction(defaultOutputList));
//
// let defaultCriteriaList = loadAttributeSearchMetaSuccessAction.payload
// .filter(attribute => attribute.id_criteria_family && attribute.search_type && attribute.min)
// .map(attribute => {
// switch (attribute.search_type) {
// case 'field':
// case 'select':
// case 'datalist':
// case 'radio':
// case 'date':
// case 'date-time':
// case 'time':
// return { id: attribute.id, type: 'field', value: attribute.min.toString(), operator: attribute.operator };
// case 'list':
// return { id: attribute.id, type: 'list', values: attribute.min.toString().split('|') };
// case 'between':
// case 'between-date':
// return { id: attribute.id, type: 'between', min: attribute.min.toString(), max: attribute.max.toString() };
// case 'select-multiple':
// case 'checkbox':
// const msValues = attribute.min.toString().split('|');
// const options = attribute.options.filter(option => msValues.includes(option.value));
// return { id: attribute.id, type: 'multiple', options };
// case 'json':
// const [path, operator, value] = attribute.min.toString().split('|');
// return { id: attribute.id, type: 'json', path, operator, value };
//
// default:
// return null;
// }
// });
//
// if (state.router.state.queryParams.c) {
// defaultCriteriaList = state.router.state.queryParams.c.split(';').map((c: string) => {
// const params = c.split('::');
// const attribute = loadAttributeSearchMetaSuccessAction.payload.find(a => a.id === parseInt(params[0], 10));
// switch (attribute.search_type) {
// case 'field':
// case 'select':
// case 'datalist':
// case 'radio':
// case 'date':
// case 'date-time':
// case 'time':
// return { id: parseInt(params[0], 10), type: 'field', operator: params[1], value: params[2] };
// case 'list':
// return { id: parseInt(params[0], 10), type: 'list', values: params[2].split('|') };
// case 'between':
// case 'between-date':
// if (params[1] === 'bw') {
// const bwValues = params[2].split('|');
// return { id: parseInt(params[0], 10), type: 'between', min: bwValues[0], max: bwValues[1] };
// } else if (params[1] === 'gte') {
// return { id: parseInt(params[0], 10), type: 'between', min: params[2], max: null };
// } else {
// return { id: parseInt(params[0], 10), type: 'between', min: null, max: params[2] };
// }
// case 'select-multiple':
// case 'checkbox':
// const msValues = params[2].split('|');
// const options = attribute.options.filter(option => msValues.includes(option.value));
// return { id: parseInt(params[0], 10), type: 'multiple', options };
// case 'json':
// const [path, operator, value] = params[2].split('|');
// return { id: parseInt(params[0], 10), type: 'json', path, operator, value };
//
// default:
// return null;
// }
// });
// }
//
// actions.push(new searchActions.UpdateCriteriaListAction(defaultCriteriaList));
//
// if (state.router.state.queryParams.cs) {
// const params = state.router.state.queryParams.cs.split(':');
// const coneSearch: ConeSearch = {
// ra: parseFloat(params[0]),
// dec: parseFloat(params[1]),
// radius: parseInt(params[2], 10)
// };
// actions.push(new searchActions.IsConeSearchAddedAction(true));
// actions.push(new coneSearchActions.AddConeSearchAction(coneSearch));
// }
//
// return actions;
// })
// );
//
// @Effect()
// retrieveDataAction$ = this.actions$.pipe(
// ofType(searchActions.RETRIEVE_DATA),
// withLatestFrom(this.store$),
......@@ -228,49 +110,4 @@ export class SearchMultipleEffects {
// ofType(searchActions.GET_DATA_LENGTH_FAIL),
// tap(_ => this.toastr.error('Loading Failed!', 'The data length loading failed'))
// );
//
// @Effect()
// executeProcessAction$ = this.actions$.pipe(
// ofType(searchActions.EXECUTE_PROCESS),
// withLatestFrom(this.store$),
// switchMap(([action, state]) => {
// const executeProcessAction = action as searchActions.ExecuteProcessAction;
// const dname = state.search.datasetName;
// let query = '?a=' + state.search.outputList.join(';');
// query += '&c=';
// query += state.metamodel.attribute.datasetAttributeList.find(a => a.search_flag === 'ID').id;
// query += '::in::';
// query += state.search.selectedData.join('|');
// return this.searchService.executeProcess(executeProcessAction.payload, dname, query).pipe(
// map((res: any) => new searchActions.ExecuteProcessWipAction(res.message)),
// catchError(() => of(new searchActions.ExecuteProcessFailAction()))
// );
// })
// );
//
// @Effect()
// executeProcessWipAction$ = this.actions$.pipe(
// ofType(searchActions.EXECUTE_PROCESS_WIP),
// withLatestFrom(this.store$),
// switchMap(([action, state]) => {
// const executeProcessWipAction = action as searchActions.ExecuteProcessWipAction;
// const idProcess: string = executeProcessWipAction.payload;
// return this.searchService.checkProcess(idProcess).pipe(
// map(_ => {
// return new searchActions.ExecuteProcessSuccessAction(idProcess);
// }),
// catchError((err: HttpErrorResponse) => {
// if (err.status === 404) {
// return of(new searchActions.ExecuteProcessWipAction(idProcess)).pipe(delay(5000));
// }
// return of(new searchActions.ExecuteProcessFailAction());
// }));
// })
// );
//
// @Effect({ dispatch: false })
// executeProcessFailAction$ = this.actions$.pipe(
// ofType(searchActions.EXECUTE_PROCESS_FAIL),
// tap(_ => this.toastr.error('Action Failed!', 'The process failed'))
// );
}
......@@ -52,6 +52,7 @@ export class ConeSearchComponent {
}
isValid(): void {
console.log(this.ra, this.dec, this.radius);
if (this.ra && this.dec && this.radius) {
const cs = { ra: this.ra, dec: this.dec, radius: this.radius} as ConeSearch;
this.store.dispatch(new coneSearchActions.AddConeSearchAction(cs));
......
......@@ -8,6 +8,7 @@ export const RETRIEVE_COORDINATES_FAIL = '[ConeSearch] Retrieve Coordinates Fail
export const DELETE_RESOLVER = '[ConeSearch] Delete Resolver';
export const IS_VALID_CONE_SEARCH = '[ConeSearch] Is Valid Cone Search';
export const ADD_CONE_SEARCH = '[ConeSearch] Add Cone Search';
export const ADD_CONE_SEARCH_FROM_URL = '[ConeSearch] Add Cone Search From Url';
export const DELETE_CONE_SEARCH = '[ConeSearch] Delete Cone Search';
......@@ -47,6 +48,12 @@ export class AddConeSearchAction implements Action {
constructor(public payload: ConeSearch) { }
}
export class AddConeSearchFromUrlAction implements Action {
readonly type = ADD_CONE_SEARCH_FROM_URL;
constructor(public payload: ConeSearch) { }
}
export class DeleteConeSearchAction implements Action {
readonly type = DELETE_CONE_SEARCH;
......@@ -60,4 +67,5 @@ export type Actions
| DeleteResolverAction
| IsValidConeSearchAction
| AddConeSearchAction
| AddConeSearchFromUrlAction
| DeleteConeSearchAction;
......@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import {Action, Store} from '@ngrx/store';
import { of } from 'rxjs';
import { map, tap, switchMap, withLatestFrom, catchError } from 'rxjs/operators';
......@@ -11,6 +11,8 @@ import * as fromRouter from '@ngrx/router-store';
import * as fromConeSearch from './cone-search.reducer';
import * as utils from '../../utils';
import { ConeSearchService } from './cone-search.service';
import {FormControl, Validators} from "@angular/forms";
import {nanValidator, rangeValidator} from "../../validator";
@Injectable()
......@@ -61,4 +63,27 @@ export class ConeSearchEffects {
}
})
);
@Effect()
addConeSearchFromUrlAction$ = this.actions$.pipe(
ofType(coneSearchActions.ADD_CONE_SEARCH_FROM_URL),
switchMap(action => {
const addConeSearchFromUrlAction = action as coneSearchActions.AddConeSearchFromUrlAction;
let raForm = new FormControl('', [Validators.required, nanValidator, rangeValidator(0, 360)]);
raForm.setValue(addConeSearchFromUrlAction.payload.ra);
let decForm = new FormControl('', [Validators.required, nanValidator, rangeValidator(-90, 90)]);
decForm.setValue(addConeSearchFromUrlAction.payload.dec);
let radiusForm = new FormControl('', [Validators.required, nanValidator, rangeValidator(0, 150)]);
radiusForm.setValue(addConeSearchFromUrlAction.payload.dec);
if (!raForm.errors && !decForm.errors && !radiusForm.errors) {
const actions: Action[] = [];
actions.push(new coneSearchActions.AddConeSearchAction(addConeSearchFromUrlAction.payload));
actions.push(new coneSearchActions.IsValidConeSearchAction(true));
return actions;
} else {
this.toastr.error('Cone search from URL is not valid', 'Not valid position!');
return of();
}
})
);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment