Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { Criterion } from '../store/model';
import { Project, DatasetFamily, Dataset, Attribute } from '../../metamodel/model';
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 searchActions from '../store/search.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-dataset',
templateUrl: 'dataset.component.html',
styleUrls: [ 'dataset.component.css' ]
})
export class DatasetComponent implements OnInit {
public projectList: Observable<Project[]>;
public datasetList: Observable<Dataset[]>;
public datasetFamilyList: Observable<DatasetFamily[]>;
public datasetAttributeList: Observable<Attribute[]>;
public currentStep: Observable<string>;
public datasetName: Observable<String>;
public criteriaList: Observable<Criterion[]>;
public outputList: Observable<number[]>;
constructor(private store: Store<StoreState>) {
this.projectList = store.select(metamodelSelector.getProjectList);
this.datasetList = store.select(metamodelSelector.getDatasetList);
this.datasetFamilyList = store.select(metamodelSelector.getDatasetFamilyList);
this.datasetAttributeList = store.select(metamodelSelector.getDatasetAttributeList);
this.currentStep = store.select(searchSelector.getCurrentStep);
this.datasetName = store.select(searchSelector.getDatasetName);
this.criteriaList = this.store.select(searchSelector.getCriteriaList);
this.outputList = this.store.select(searchSelector.getOutputList);
}
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('dataset')));
this.store.dispatch(new datasetActions.LoadProjectListAction());
this.store.dispatch(new datasetActions.LoadDatasetListAction());
this.store.dispatch(new datasetActions.LoadDatasetFamilyListAction());
}
selectDataset(datasetName: string): void {
this.store.dispatch(new searchActions.SelectDatasetAction(datasetName));
this.store.dispatch(new criteriaActions.LoadDatasetAttributeListAction(datasetName));
// this.store.dispatch(new outputActions.LoadDatasetOutputFamilyAction(datasetName));
}
}