import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, ParamMap } from '@angular/router'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; import { environment } from '../../../environments/environment'; import { Criterion, SearchMeta } from '../store/model'; import { Dataset, Family, Category, Attribute } from '../../metamodel/model'; import * as searchActions from '../store/search.action'; import * as datasetActions from '../../metamodel/action/dataset.action'; import * as criteriaActions from '../../metamodel/action/criteria.action'; import * as outputActions from '../../metamodel/action/output.action'; import * as fromSearch from '../store/search.reducer'; import * as fromMetamodel from '../../metamodel/reducers'; import * as searchSelector from '../store/search.selector'; import * as metamodelSelector from '../../metamodel/selectors'; interface StoreState { search: fromSearch.State; metamodel: fromMetamodel.State; } @Component({ selector: 'app-detail', templateUrl: 'detail.component.html', styleUrls: [ 'detail.component.css' ] }) export class DetailComponent implements OnInit { // public apiPath: string = environment.apiUrl + '/search'; // public datasetName: Observable<String>; // public currentStep: Observable<string>; // public datasetList: Observable<Dataset[]>; // public datasetAttributeList: Observable<Attribute[]>; // public outputFamilyList: Observable<Family[]>; // public categoryList: Observable<Category[]>; // public criteriaList: Observable<Criterion[]>; // public outputList: Observable<number[]>; // public searchMeta: Observable<SearchMeta>; // public searchData: Observable<any[]>; constructor(private route: ActivatedRoute, private store: Store<StoreState>) { // this.datasetName = store.select(searchSelector.getDatasetName); // this.currentStep = store.select(searchSelector.getCurrentStep); // this.datasetList = store.select(metamodelSelector.getDatasetList); // this.datasetAttributeList = this.store.select(metamodelSelector.getDatasetAttributeList); // this.outputFamilyList = this.store.select(metamodelSelector.getOutputFamilyList); // this.categoryList = this.store.select(metamodelSelector.getCategoryList); // this.criteriaList = this.store.select(searchSelector.getCriteriaList); // this.outputList = this.store.select(searchSelector.getOutputList); // this.searchMeta = this.store.select(searchSelector.getSearchMeta); // this.searchData = this.store.select(searchSelector.getSearchData); } 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.ChangeStepAction('result'))); // Promise.resolve(null).then(() => this.store.dispatch(new searchActions.ResultChecked())); // this.route.paramMap.subscribe((params: ParamMap) => { // const datasetName = params.get('dname'); // Promise.resolve(null).then(() => this.store.dispatch(new searchActions.SelectDatasetAction(datasetName))); // this.store.dispatch(new criteriaActions.LoadDatasetAttributeListAction(datasetName)); // }); // this.store.dispatch(new datasetActions.LoadDatasetSearchMetaAction()); // this.store.dispatch(new outputActions.LoadOutputFamilyListAction()); // this.store.dispatch(new outputActions.LoadCategoryListAction()); } // getSearchMeta(): void { // this.store.dispatch(new searchActions.RetrieveMetaAction()); // } // getSearchData(page: number): void { // this.store.dispatch(new searchActions.RetrieveDataAction(page)); // } }