More tweaks to the linked data loader

This commit is contained in:
Pieter Vander Vennet 2024-06-19 03:22:57 +02:00
parent 684932aebd
commit 734be4a702
5 changed files with 76 additions and 55 deletions

View file

@ -66,24 +66,22 @@
</script>
<div>
<div class:interactive={!readonly} class="flex w-full justify-between py-1 px-2">
<div class="flex flex-col">
<div>
{#if renderingExternal}
<TagRenderingAnswer
tags={new UIEventSource(mockPropertiesExternal)}
selectedElement={feature}
config={renderingExternal}
{layer}
{state}
/>
{:else}
<div class="flex items-center gap-x-1">
<b>{key}</b>
{externalProperties[key]}
</div>
{/if}
</div>
<div class:interactive={!readonly} class="flex flex-col items-end py-1 px-2">
<div class="flex flex-col w-full">
{#if renderingExternal}
<TagRenderingAnswer
tags={new UIEventSource(mockPropertiesExternal)}
selectedElement={feature}
config={renderingExternal}
{layer}
{state}
/>
{:else}
<div class="flex items-center gap-x-1">
<b>{key}</b>
{externalProperties[key]}
</div>
{/if}
{#if !readonly && ($isTesting || $isDebug || $showTags === "yes" || $showTags === "always" || $showTags === "full")}
<div class="subtle text-sm">
@ -103,7 +101,7 @@
{#if !readonly}
{#if currentStep === "init"}
<button
class="small"
class="w-fit"
on:click={() => apply(key)}
on:mouseover={() => (onOverwrite = true)}
on:focus={() => (onOverwrite = true)}

View file

@ -1833,8 +1833,15 @@ export default class SpecialVisualizations {
})()
)
}
return Stores.FromPromiseWithErr(
LinkedDataLoader.fetchJsonLd(url, { country }, useProxy)
return Stores.FromPromiseWithErr((async () => {
try {
return await LinkedDataLoader.fetchJsonLd(url, { country }, useProxy ? "proxy" : "fetch-lod")
} catch (e) {
console.log("Could not get with proxy/download LOD, attempting to download directly. Error for ",url,"is",e)
return await LinkedDataLoader.fetchJsonLd(url, { country }, "fetch-raw")
}
})()
)
})
@ -1850,7 +1857,8 @@ export default class SpecialVisualizations {
layer,
externalData,
sourceUrl,
readonly
readonly,
collapsed: isClosed
}),
undefined,
url.map((url) => !!url)