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
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { Database, Survey } from 'src/app/metamodel/store/models';
import * as databaseActions from 'src/app/metamodel/store/actions/database.actions';
import * as surveyActions from 'src/app/metamodel/store/actions/survey.actions';
import * as databaseSelector from 'src/app/metamodel/store/selectors/database.selector';
import * as surveySelector from 'src/app/metamodel/store/selectors/survey.selector';
@Component({
selector: 'app-database-list',
templateUrl: 'database-list.component.html'
})
export class DatabaseListComponent implements OnInit {
public databaseListIsLoading: Observable<boolean>;
public databaseListIsLoaded: Observable<boolean>;
public databaseList: Observable<Database[]>;
public surveyListIsLoading: Observable<boolean>;
public surveyListIsLoaded: Observable<boolean>;
public surveyList: Observable<Survey[]>;
constructor(private store: Store<{ }>) {
this.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading);
this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded);
this.databaseList = store.select(databaseSelector.selectAllDatabases);
this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading);
this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded);
this.surveyList = store.select(surveySelector.selectAllSurveys);
}
ngOnInit() {
this.store.dispatch(databaseActions.loadDatabaseList());
this.store.dispatch(surveyActions.loadSurveyList());
}
deleteDatabase(database: Database) {
this.store.dispatch(databaseActions.deleteDatabase({ database }));