Newer
Older
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { DatasetCount, SearchMultipleQueryParams } from '../store/model';
import { Attribute, Dataset, Project } from '../../metamodel/model';
import { ConeSearch } from "../../shared/cone-search/store/model";
import * as searchMultipleActions from '../store/search-multiple.action';
import * as datasetActions from '../../metamodel/action/dataset.action';
import * as attributeActions from '../../metamodel/action/attribute.action';
import * as fromSearchMultiple from '../store/search-multiple.reducer';
import * as fromMetamodel from '../../metamodel/reducers';
import * as searchMultipleSelector from '../store/search-multiple.selector';
import * as metamodelSelector from '../../metamodel/selectors';
import * as coneSearchSelector from '../../shared/cone-search/store/cone-search.selector';
import { ScrollTopService } from '../../shared/service/sroll-top.service';
interface StoreState {
searchMultiple: fromSearchMultiple.State;
metamodel: fromMetamodel.State;
}
@Component({
selector: 'app-result-multiple',
templateUrl: 'result-multiple.component.html'
})
export class ResultMultipleComponent implements OnInit, OnDestroy {
public datasetSearchMetaIsLoading: Observable<boolean>;
public datasetSearchMetaIsLoaded: Observable<boolean>;
public projectList: Observable<Project[]>;
public datasetList: Observable<Dataset[]>;
// public attributeListIsLoading: Observable<boolean>;
// public attributeListIsLoaded: Observable<boolean>;
// public attributeList: Observable<Attribute[]>;
public currentStep: Observable<string>;
public coneSearch: Observable<ConeSearch>;
public selectedDatasets: Observable<string[]>;
// public searchData: Observable<any[]>;
// public dataLength: Observable<number>;
// public selectedData: Observable<number[] | string[]>;
public queryParams: Observable<SearchMultipleQueryParams>;
public datasetsCountIsLoading: Observable<boolean>;
public datasetsCountIsLoaded: Observable<boolean>;
public datasetsCount: Observable<DatasetCount[]>;
constructor(private store: Store<StoreState>, private scrollTopService: ScrollTopService) {
this.datasetSearchMetaIsLoading = store.select(metamodelSelector.getDatasetSearchMetaIsLoading);
this.datasetSearchMetaIsLoaded = store.select(metamodelSelector.getDatasetSearchMetaIsLoaded);
this.currentStep = store.select(searchMultipleSelector.getCurrentStep);
this.projectList = store.select(metamodelSelector.getProjectList);
this.datasetList = store.select(metamodelSelector.getDatasetList);
// this.attributeListIsLoading = store.select(searchMultipleSelector.getAttributeListIsLoading);
// this.attributeListIsLoaded = store.select(searchMultipleSelector.getAttributeListIsLoaded);
// this.attributeList = store.select(searchMultipleSelector.getAttributeList);
this.coneSearch = this.store.select(coneSearchSelector.getConeSearch);
this.selectedDatasets = this.store.select(searchMultipleSelector.getSelectedDatasets);
// this.searchData = this.store.select(searchSelector.getSearchData);
// this.dataLength = this.store.select(searchSelector.getDataLength);
// this.selectedData = this.store.select(searchSelector.getSelectedData);
this.queryParams = this.store.select(searchMultipleSelector.getQueryParams);
this.datasetsCountIsLoading = this.store.select(searchMultipleSelector.getDatasetsCountIsLoading);
this.datasetsCountIsLoaded = this.store.select(searchMultipleSelector.getDatasetsCountIsLoaded);
this.datasetsCount = this.store.select(searchMultipleSelector.getDatasetsCount);
}
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.ResultChecked()));
Promise.resolve(null).then(() => this.store.dispatch(new searchMultipleActions.ChangeStepAction('result')));
Promise.resolve(null).then(() => this.store.dispatch(new searchMultipleActions.InitSearchByUrlAction()));
this.store.dispatch(new datasetActions.LoadDatasetSearchMetaAction());
this.scrollTopService.setScrollTop();
}
getDatasetsCount(): void {
this.store.dispatch(new searchMultipleActions.RetrieveDatasetsCountAction());
}
retrieveMeta(dname: string): void {
this.store.dispatch(new attributeActions.LoadAttributeSearchMetaAction(dname));
// getSearchData(pagination: [number, number, number, string]): void {
// this.store.dispatch(new searchActions.RetrieveDataAction(pagination));
// this.store.dispatch(new searchActions.GetDataLengthAction());
// }
//
// addSearchData(data: number | string): void {
// this.store.dispatch(new searchActions.AddSelectedDataAction(data));
// }
//
// deleteSearchData(data: number | string): void {
// this.store.dispatch(new searchActions.DeleteSelectedDataAction(data));
// }
//
// executeProcess(typeProcess: string): void {
// this.store.dispatch(new searchActions.ExecuteProcessAction(typeProcess));
// }
ngOnDestroy() {
this.store.dispatch(new searchMultipleActions.DestroyResultsAction());