From ccd75cf2223cdf903e685b96027539458baffd14 Mon Sep 17 00:00:00 2001 From: Christoph Giesche Date: Fri, 26 Jan 2024 15:14:00 +0100 Subject: [PATCH] Add debugging logs in ServiceCallConfiguration.vue The commit adds a series of console log statements throughout the ServiceCallConfiguration.vue file to help debug issues relating to domain entities. --- src/components/ServiceCallConfiguration.vue | 27 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/components/ServiceCallConfiguration.vue b/src/components/ServiceCallConfiguration.vue index 9200910..3d6d361 100644 --- a/src/components/ServiceCallConfiguration.vue +++ b/src/components/ServiceCallConfiguration.vue @@ -74,7 +74,7 @@ {{ item.name }} {{ item.info.description }} @@ -152,18 +152,35 @@ const domainServices = computed(() => { }) const domainEntities = computed(() => { + console.log("[DEBUG] List of domainEntities has been requested.") if (!props.availableServices || !props.availableEntities || !props.modelValue || !props.modelValue.serviceId) { + console.log(`Available services: ${JSON.stringify(props.availableServices)}`) + console.log(`Available entities: ${JSON.stringify(props.availableEntities)}`) + console.log(`Model: ${JSON.stringify(props.modelValue)}`) + console.log("[DEBUG] No entities available because preconditions are not met:") return []; } + console.log("[DEBUG] Filtering available entities") let selectedService = props.availableServices.filter(service => service.serviceId === props.modelValue.serviceId)[0] + console.log(`[DEBUG] Selected service ${JSON.stringify(selectedService)}`) + if (selectedService && selectedService.target && Array.isArray(selectedService.target.entity)) { + console.log("[DEBUG] Finding service target domains") let targetDomains = selectedService.target.entity.filter(entity => entity.domain).flatMap(entity => entity.domain); + console.log(`[DEBUG] Service target domains: ${JSON.stringify(targetDomains)}`) if (targetDomains.length > 0) { - return props.availableEntities.filter(entity => targetDomains.includes(entity.domain)).sort(titleSort); + console.log(`[DEBUG] Finding matching entities for service domain(s).`) + let availableEntities = props.availableEntities.filter(entity => targetDomains.includes(entity.domain)).sort(titleSort); + console.log(`[DEBUG] Returning ${availableEntities.length} matching entities for service domain(s).`) + return availableEntities; } else { + console.log(`[DEBUG] Returning ALL (${props.availableEntities.length}) available entities.`) return props.availableEntities.filter(entity => entity).sort(titleSort); } } + + console.log("[DEBUG] Selected service does not support target. So, no entities available :(") + return []; }) @@ -173,7 +190,11 @@ const serviceDataInvalidFeedback = computed(() => { return ""; } try { - const renderedServiceData = nunjucks.renderString(serviceDataString, {ticks: 5, rotationPercent: 100, rotationAbsolute: 100}); + const renderedServiceData = nunjucks.renderString(serviceDataString, { + ticks: 5, + rotationPercent: 100, + rotationAbsolute: 100 + }); const json = JSON.parse(renderedServiceData); return (typeof json === "object") ? "" : "Service data must be an JSON object."