import { Component } from '@angular/core' ; import { AddDataUrlType , servicesSupportedByUrl } from './types/url.type' ; import { AddDataUrlValues } from './add-data-url-values' ; import { HsAddDataCommonService } from '../common/common.service' ; import { HsAddDataOwsService } from './add-data-ows.service' ; import { HsAddDataUrlService } from './add-data-url.service' ; import { HsConfig } from '../../../config.service' ; import { HsLanguageService } from '../../language/language.service' ; import { HsLayoutService } from '../../layout/layout.service' ; import { HsShareUrlService } from '../../permalink/share-url.service' ; @ Component ( { selector : 'hs-add-data-url' , templateUrl : './add-data-url.component.html' , } ) export class HsAddDataUrlComponent { types : { id : AddDataUrlType ; text : string ; } [ ] ; constructor ( public hsConfig , public hsLanguageService , public hsShareUrlService , public hsLayoutService , public hsAddDataCommonService , public hsAddDataOwsService , public hsAddDataUrlService ) { if ( Array . isArray ( this . hsConfig . connectTypes ) ) { this . types = this . hsConfig . connectTypes . filter ( ( type ) => servicesSupportedByUrl . includes ( type ) ) . map ( ( type ) => AddDataUrlValues . find ( ( v ) => v . id == type ) ) ; } else { this . types = AddDataUrlValues ; } if ( this . hsAddDataUrlService . typeSelected ) { this . connectServiceFromUrlParam ( this . hsAddDataUrlService . typeSelected ) ; } } selectType ( type ) { this . hsAddDataUrlService . typeSelected = type ; } connectServiceFromUrlParam ( type ) { if ( ! this . hsAddDataUrlService . connectFromParams ) { return ; } const layers = this . hsShareUrlService . getParamValue ( `hs-${ type }-layers` ) ; const url = this . hsShareUrlService . getParamValue ( `hs-${ type }-to-connect` ) ; if ( layers ) { for ( const layer of layers . split ( ';' ) ) { this . hsAddDataOwsService . connectToOWS ( { type , uri : url , layer , style : undefined , } ) ; } } else { this . hsAddDataOwsService . connectToOWS ( { type , uri : url } ) ; } this . hsAddDataUrlService . connectFromParams = false ; } }