Skip to content
Snippets Groups Projects
edit-database.component.ts 1.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { Component, OnInit} from '@angular/core';
    import { Observable } from 'rxjs';
    import { Store } from '@ngrx/store';
    
    import { Database } from 'src/app/metamodel/store/models';
    import * as databaseActions from 'src/app/metamodel/store/actions/database.actions';
    import * as databaseSelector from 'src/app/metamodel/store/selectors/database.selector';
    
    @Component({
        selector: 'app-edit-database',
        templateUrl: 'edit-database.component.html'
    })
    export class EditDatabaseComponent implements OnInit {
        public databaseListIsLoading: Observable<boolean>;
        public databaseListIsLoaded: Observable<boolean>;
        public database: Observable<Database>;
    
        constructor(private store: Store<{ }>) {
            this.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading);
            this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded);
            this.database = store.select(databaseSelector.selectDatabaseByRouteId);
        }
    
        ngOnInit() {
            this.store.dispatch(databaseActions.loadDatabaseList());
        }
    
        editDatabase(database: Database) {
            this.store.dispatch(databaseActions.editDatabase({ database }));
        }
    }