fix search outputs in apps with null object

This commit is contained in:
Ruben Fiszel
2023-04-05 18:52:41 +02:00
parent 8c72722710
commit 95ed99a1d2
3 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
http://localhost {
bind {$ADDRESS}
reverse_proxy /api/* https://app.windmill.dev {
reverse_proxy /api/* https://teracapital.windmill.dev {
header_up Host {http.reverse_proxy.upstream.hostport}
header_down Set-Cookie windmill.dev localhost
}
@@ -10,7 +10,7 @@ http://localhost {
https://localhost {
bind {$ADDRESS}
reverse_proxy /ws/* https://app.windmill.dev {
reverse_proxy /ws/* https://teracapital.windmill.dev {
header_up Host {http.reverse_proxy.upstream.hostport}
}
}
@@ -99,9 +99,9 @@
<div class="mb-2 text-gray-500 text-sm bg-gray-50/20">
as JSON&nbsp;<input class="windmillapp" type="checkbox" bind:checked={forceJson} /></div
>{/if}{#if typeof result == 'object' && Object.keys(result).length > 0}<div
class="mb-2 min-w-[300px] text-sm text-gray-700 relative"
class="mb-2 w-full text-sm text-gray-700 relative"
>The result keys are: <b>{truncate(Object.keys(result).join(', '), 50)}</b>
<div class="text-gray-500 text-sm absolute top-0 right-2">
<div class="text-gray-500 text-sm absolute top-6 right-0">
<button on:click={jsonViewer.openDrawer}>Expand JSON</button>
</div></div
>{/if}{#if !forceJson && resultKind == 'table-col'}<div
@@ -600,6 +600,9 @@ export function recursivelyFilterKeyInJSON(
search: string,
extraSearch?: string | undefined
): object {
if (json === null || json === undefined) {
return json
}
if (!search || search == '') {
return json
}
@@ -616,7 +619,7 @@ export function recursivelyFilterKeyInJSON(
} else if (typeof json[key] === 'object') {
const res = recursivelyFilterKeyInJSON(json[key], search, extraSearch)
if (Object.keys(res).length !== 0) {
if (Object.keys(res ?? {}).length !== 0) {
filteredJSON[key] = res
}
}