Skip to content
Snippets Groups Projects
documentation.component.ts 1.78 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 * as datasetActions from 'src/app/metamodel/store/actions/dataset.actions';
    import * as datasetSelector from 'src/app/metamodel/store/selectors/dataset.selector';
    import { Dataset } from 'src/app/metamodel/store/models';
    import { environment } from 'src/environments/environment';
    
    @Component({
        selector: 'app-documentation',
        templateUrl: 'documentation.component.html',
        styleUrls: ['documentation.component.scss']
    })
    /**
     * @class
     * @classdesc Documentation container.
     *
     * @implements OnInit
     */
    export class DocumentationComponent implements OnInit {
        public datasetListIsLoading: Observable<boolean>;
        public datasetListIsLoaded: Observable<boolean>;
        public datasetList: Observable<Dataset[]>;
    
        constructor(private store: Store<{ }>) {
            this.datasetListIsLoading = store.select(datasetSelector.selectDatasetListIsLoading);
            this.datasetListIsLoaded = store.select(datasetSelector.selectDatasetListIsLoaded);
            this.datasetList = store.select(datasetSelector.selectAllDatasets);
        }
    
        ngOnInit() {
            this.store.dispatch(datasetActions.loadDatasetList());
        }
    
        /**
         * Returns strict url address.
         *
         * @return string
         */
        getUrlServer(): string {
            if (!environment.apiUrl.startsWith('http')) {
                const url = window.location;
                return url.protocol + '//' + url.host + environment.apiUrl;
            }
            return environment.apiUrl;
        }
    }