Skip to content
Snippets Groups Projects
edit-instance.component.ts 1.41 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * This file is part of Anis Client.
     *
     * @copyright Laboratoire d'Astrophysique de Marseille / CNRS
     *
     * For the full copyright and license information, please view the LICENSE
     * file that was distributed with this source code.
     */
    
    
    import { Component, OnInit } from '@angular/core';
    
    import { Store } from '@ngrx/store';
    import { Observable } from 'rxjs';
    
    import { Instance } from 'src/app/metamodel/store/models';
    import * as instanceActions from 'src/app/metamodel/store/actions/instance.actions';
    import * as instanceSelector from 'src/app/metamodel/store/selectors/instance.selector';
    
    @Component({
        selector: 'app-edit-instance',
        templateUrl: 'edit-instance.component.html'
    })
    export class EditInstanceComponent implements OnInit {
        public instanceListIsLoading: Observable<boolean>;
        public instanceListIsLoaded: Observable<boolean>;
        public instance: Observable<Instance>;
    
        constructor(private store: Store<{ }>) {
            this.instanceListIsLoading = store.select(instanceSelector.selectInstanceListIsLoading);
            this.instanceListIsLoaded = store.select(instanceSelector.selectInstanceListIsLoaded);
            this.instance = store.select(instanceSelector.selectInstanceByRouteName);
        }
    
        ngOnInit() {
            this.store.dispatch(instanceActions.loadInstanceList());
        }
    
        editInstance(instance: Instance) {
            this.store.dispatch(instanceActions.editInstance({ instance }));
        }
    }