import { Component , Input } from '@angular/core' ; import { HsAddDataCatalogueService } from '../catalogue.service' ; import { HsAddDataLayerDescriptor } from '../layer-descriptor.model' ; import { HsCatalogueMetadataComponent } from '../catalogue-metadata/catalogue-metadata.component' ; import { HsCatalogueMetadataService } from '../catalogue-metadata/catalogue-metadata.service' ; import { HsCommonEndpointsService } from './../../../../common/endpoints/endpoints.service' ; import { HsConfig } from '../../../../config.service' ; import { HsConfirmDialogComponent } from '../../../../common/confirm/confirm-dialog.component' ; import { HsDialogContainerService } from '../../../layout/dialogs/dialog-container.service' ; import { HsEndpoint } from '../../../../common/endpoints/endpoint.interface' ; import { HsLanguageService } from '../../../language/language.service' ; import { HsLaymanBrowserService } from '../layman/layman.service' ; import { HsLaymanService } from '../../../save-map/layman.service' ; import { HsLogService } from '../../../../common/log/log.service' ; import { HsUtilsService } from '../../../utils/utils.service' ; @ Component ( { selector : 'hs-catalogue-list-item' , templateUrl : 'catalogue-list-item.component.html' , } ) export class HsCatalogueListItemComponent { @ Input ( ) layer ; explanationsVisible : boolean ; metadata ; selected_ds ; selected_layer ; selectedType : string ; selectTypeToAddLayerVisible : boolean ; whatToAddTypes ; loadingInfo = false ; constructor ( public hsConfig , public hsDatasourcesMetadataService , public hsAddDataCatalogueService , public hsDialogContainerService , public hsLaymanBrowserService , public hsLogService , public hsLanguageService , public hsLaymanService , public hsUtilsService , public hsCommonEndpointsService ) { } param endpoint param layer async addLayerToMap ( endpoint , layer ) { this . loadingInfo = true ; const availableTypes = await this . hsAddDataCatalogueService . addLayerToMap ( endpoint , layer , this . selectedType ) ; this . loadingInfo = false ; if ( Array . isArray ( availableTypes ) ) { this . whatToAddTypes = availableTypes ; this . selectTypeToAddLayerVisible = true ; } else { this . selectTypeToAddLayerVisible = false ; this . selectedType = null ; } this . explanationsVisible = false ; } abortAdd ( ) { this . selectTypeToAddLayerVisible = false ; this . explanationsVisible = false ; this . selectedType = null ; } param type param event selectTypeAndAdd ( type , event ) { event . preventDefault ( ) ; this . selectedType = type ; this . addLayerToMap ( this . layer . endpoint , this . layer ) ; } param module param text returns translateString ( module , text ) { return this . hsLanguageService . getTranslationIgnoreNonExisting ( module , text ) ; } toggleExplanations ( ) { this . explanationsVisible = ! this . explanationsVisible ; } param endpoint param layer async showMetadata ( endpoint , layer ) { this . selected_layer = layer ; this . selected_ds = endpoint ; if ( endpoint . type == 'layman' ) { await this . hsLaymanBrowserService . fillLayerMetadata ( endpoint , layer ) ; } this . hsDialogContainerService . create ( HsCatalogueMetadataComponent , { selectedLayer : this . selected_layer , selectedDS : this . selected_ds , } ) ; } param endpoint param layer returns layerRDF ( endpoint , layer ) { return this . hsAddDataCatalogueService . layerRDF ( endpoint , layer ) ; } param layer async removeLayer ( layer ) { if ( ! layer . editable ) { return ; } const dialog = this . hsDialogContainerService . create ( HsConfirmDialogComponent , { message : this . hsLanguageService . getTranslation ( 'DRAW.reallyDeleteThisLayer' ) , note : this . hsLanguageService . getTranslation ( 'DRAW.deleteNote' ) , title : this . hsLanguageService . getTranslation ( 'COMMON.confirmDelete' ) , } ) ; const confirmed = await dialog . waitResult ( ) ; if ( confirmed == 'yes' ) { this . hsLaymanService . removeLayer ( layer . name ) ; this . hsAddDataCatalogueService . catalogEntries = this . hsAddDataCatalogueService . catalogEntries . filter ( ( item ) => { return item . id != layer . id ; } ) ; } } }