Files
windmill/frontend/src/lib/components/DisplayResultControlBar.svelte
T
GuilhemandClaude Opus 5.5 d1abc75fa6 feat: load a large result on request, ten render_all elements at a time (#12664)
* feat: show a large result as one placeholder that loads it on request

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep other json trees as on main, explain results drawn as json, and drop render_all cards in narrow panes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: draw loaded images over 5 MB, load a non-list render_all whole, restart Load after reselecting a run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say a large render_all lists up to 100 elements

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 21:58:55 +01:00

97 lines
2.6 KiB
Svelte

<script lang="ts">
import { twMerge } from 'tailwind-merge'
import { Download, InfoIcon, ClipboardCopy, Expand } from 'lucide-svelte'
import Popover from './Popover.svelte'
import { copyToClipboard } from '$lib/utils'
import { downloadViaClient, shouldDownloadViaClient } from '$lib/utils/downloadFile'
import { appendViewToken } from '$lib/viewToken'
import type { DisplayResultUi } from './custom_ui'
import { createEventDispatcher } from 'svelte'
interface Props {
customUi?: DisplayResultUi | undefined
filename?: string | undefined
workspaceId?: string | undefined
jobId?: string | undefined
nodeId?: string | undefined
result: any
disableTooltips?: boolean
disableExpand?: boolean
}
let {
customUi = undefined,
filename = undefined,
workspaceId = undefined,
jobId = undefined,
nodeId = undefined,
result,
disableTooltips = false,
disableExpand = false
}: Props = $props()
const dispatch = createEventDispatcher()
function toJsonStr(result: any) {
try {
return JSON.stringify(result ?? null, null, 4) ?? 'null'
} catch (e) {
return 'error stringifying object: ' + e.toString()
}
}
let resultApiPath = $derived(
workspaceId && jobId
? appendViewToken(
nodeId
? `/w/${workspaceId}/jobs/result_by_id/${jobId}/${nodeId}`
: `/w/${workspaceId}/jobs_u/completed/get_result/${jobId}`
)
: undefined
)
let downloadName = $derived(`${filename ?? 'result'}.json`)
</script>
<div class={twMerge('flex flex-row gap-2.5 z-10 text-primary -mt-1 items-center')}>
{#if customUi?.disableDownload !== true}
{#if resultApiPath && shouldDownloadViaClient()}
<button
class="text-current"
onclick={() => downloadViaClient(resultApiPath!, downloadName)}
aria-label="Download result"
>
<Download size={14} />
</button>
{:else}
<a
download={downloadName}
class="text-current"
href={resultApiPath
? `/api${resultApiPath}`
: `data:text/json;charset=utf-8,${encodeURIComponent(toJsonStr(result))}`}
>
<Download size={14} />
</a>
{/if}
{/if}
{#if disableTooltips !== true}
<Popover documentationLink="https://www.windmill.dev/docs/core_concepts/rich_display_rendering">
{#snippet text()}
The result renderer in Windmill supports rich display rendering, allowing you to customize
the display format of your results.
{/snippet}
<div>
<InfoIcon size={14} />
</div>
</Popover>
{/if}
<button onclick={() => copyToClipboard(toJsonStr(result))}>
<ClipboardCopy size={14} />
</button>
{#if !disableExpand}
<button onclick={() => dispatch('open-drawer')}>
<Expand size={14} />
</button>
{/if}
</div>