Skip to content
Snippets Groups Projects
documentation.component.ts 2.27 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';
    
    
    Tifenn Guillas's avatar
    Tifenn Guillas committed
    import * as attributeActions from 'src/app/metamodel/actions/attribute.actions';
    
    import * as datasetSelector from 'src/app/metamodel/selectors/dataset.selector';
    
    import { AppConfigService } from 'src/app/app-config.service';
    
    Tifenn Guillas's avatar
    Tifenn Guillas committed
    import { Attribute } from 'src/app/metamodel/models';
    import * as instanceSelector from "../../../metamodel/selectors/instance.selector";
    import * as attributeSelector from "../../../metamodel/selectors/attribute.selector";
    
    
    @Component({
        selector: 'app-documentation',
        templateUrl: 'documentation.component.html',
    
    Tifenn Guillas's avatar
    Tifenn Guillas committed
        styleUrls: ['../documentation.component.scss']
    
    })
    /**
     * @class
     * @classdesc Documentation container.
     *
     * @implements OnInit
     */
    export class DocumentationComponent implements OnInit {
    
    Tifenn Guillas's avatar
    Tifenn Guillas committed
        public instanceSelected: Observable<string>;
        public datasetSelected: Observable<string>;
        public attributeListIsLoading: Observable<boolean>;
        public attributeListIsLoaded: Observable<boolean>;
        public attributeList: Observable<Attribute[]>;
    
        constructor(private store: Store<{ }>, private config: AppConfigService) {
    
    Tifenn Guillas's avatar
    Tifenn Guillas committed
            this.instanceSelected = store.select(instanceSelector.selectInstanceNameByRoute);
            this.datasetSelected = store.select(datasetSelector.selectDatasetNameByRoute);
            this.attributeListIsLoading = store.select(attributeSelector.selectAttributeListIsLoading);
            this.attributeListIsLoaded = store.select(attributeSelector.selectAttributeListIsLoaded);
            this.attributeList = store.select(attributeSelector.selectAllAttributes);
    
        }
    
        ngOnInit() {
    
    Tifenn Guillas's avatar
    Tifenn Guillas committed
            this.store.dispatch(attributeActions.loadAttributeList());
    
        }
    
        /**
         * Returns strict url address.
         *
         * @return string
         */
        getUrlServer(): string {
    
            if (!this.config.apiUrl.startsWith('http')) {
    
                const url = window.location;
    
                return url.protocol + '//' + url.host + this.config.apiUrl;
    
            return this.config.apiUrl;