fix: improve logviewer behavior when job is loading

This commit is contained in:
Ruben Fiszel
2024-08-13 20:32:46 +02:00
parent b424c61e95
commit 7a68cc76c2
10 changed files with 33 additions and 36 deletions
@@ -378,17 +378,14 @@
/>
{/each}</div
>
{:else}
<div
{:else}<div
class="inline-highlight relative grow {['plain', 'markdown'].includes(resultKind ?? '')
? ''
: 'min-h-[200px]'}"
>
{#if result != undefined && length != undefined && largeObject != undefined}
<div class="flex justify-between items-center w-full">
<div class="text-tertiary text-sm">
{#if !hideAsJson && !['json', 's3object'].includes(resultKind ?? '') && typeof result === 'object'}
<ToggleButtonGroup
>{#if result != undefined && length != undefined && largeObject != undefined}<div
class="flex justify-between items-center w-full"
><div class="text-tertiary text-sm">
{#if !hideAsJson && !['json', 's3object'].includes(resultKind ?? '') && typeof result === 'object'}<ToggleButtonGroup
class="h-6"
selected={forceJson ? 'json' : resultKind?.startsWith('table-') ? 'table' : 'pretty'}
on:selected={(ev) => {
@@ -538,11 +535,13 @@
</div>
{:else if !forceJson && resultKind == 'error' && result?.error}
<div class="flex flex-col items-start">
<span class="text-red-500 font-semibold text-sm whitespace-pre-wrap"
<span class="text-red-500 pt-2 font-semibold !text-xs whitespace-pre-wrap"
>{#if result.error.name || result.error.message}{result.error.name}: {result.error
.message}{:else}{JSON.stringify(result.error, null, 4)}{/if}</span
>
<pre class="text-sm whitespace-pre-wrap text-primary">{result.error.stack ?? ''}</pre>
<pre class="text-xs pt-2 whitespace-pre-wrap text-primary"
>{result.error.stack ?? ''}</pre
>
<slot />
</div>
{:else if !forceJson && resultKind == 'approval'}<div class="flex flex-col gap-3 mt-2 mx-4">
@@ -96,10 +96,6 @@
return content
}
$: if (content != undefined && isLoading) {
isLoading = false
}
$: truncatedContent && scrollToBottom()
$: html = ansi_up.ansi_to_html(
@@ -138,7 +138,7 @@
duration={testJob?.['duration_ms']}
mem={testJob?.['mem_peak']}
content={testJob?.logs}
isLoading={testIsLoading}
isLoading={testIsLoading && testJob?.['running'] == false}
tag={testJob?.tag}
/>
</Pane>
@@ -98,7 +98,7 @@
duration={testJob?.['duration_ms']}
mem={testJob?.['mem_peak']}
content={testJob?.logs}
isLoading={testIsLoading}
isLoading={testIsLoading && testJob?.['running'] == false}
tag={testJob?.tag}
/>
</div>
@@ -979,8 +979,10 @@
You will still need to deploy the app to make visible the latest changes
</Alert>
<a href="https://www.windmill.dev/docs/advanced/external_auth_with_jwt#embed-public-apps-using-your-own-authentification" class="mt-4 text-2xs">Embed this app in your own product to be used by your own users</a>
<a
href="https://www.windmill.dev/docs/advanced/external_auth_with_jwt#embed-public-apps-using-your-own-authentification"
class="mt-4 text-2xs">Embed this app in your own product to be used by your own users</a
>
{/if}
</DrawerContent>
</Drawer>
@@ -1149,14 +1151,14 @@
duration={job?.['duration_ms']}
jobId={job?.id}
content={job?.logs}
isLoading={testIsLoading}
isLoading={testIsLoading && job?.['running'] == false}
tag={job?.tag}
/>
</Pane>
<Pane size={50} minSize={10} class="text-sm text-secondary">
{#if job != undefined && 'result' in job && job.result != undefined}
<div class="relative h-full px-2">
<DisplayResult
{#if job != undefined && 'result' in job && job.result != undefined}<div
class="relative h-full px-2"
><DisplayResult
workspaceId={$workspaceStore}
jobId={selectedJobId}
result={job.result}
@@ -48,7 +48,7 @@
<TestJobLoader bind:this={testJobLoader} bind:isLoading={testIsLoading} bind:job={testJob} />
{#if ($runnableJobEditorPanel.focused && $selectedComponentInEditor) || logDrawerOpen || resultDrawerOpen}
{#if true || ($runnableJobEditorPanel.focused && $selectedComponentInEditor) || logDrawerOpen || resultDrawerOpen}
{@const frontendJob = $runnableJobEditorPanel?.frontendJobs[$selectedComponentInEditor ?? '']}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
@@ -70,27 +70,27 @@
duration={testJob?.['duration_ms']}
mem={testJob?.['mem_peak']}
content={testJob?.logs}
isLoading={testIsLoading}
isLoading={testIsLoading && testJob?.['running'] == false}
tag={testJob?.tag}
/>
{/if}
</Pane>
<Pane size={frontendJob ? 70 : 50} minSize={10} class="text-sm text-tertiary">
{#if frontendJob}
<pre class="overflow-x-auto break-words relative h-full px-2 pt-2"
><DisplayResult bind:drawerOpen={resultDrawerOpen} result={frontendJob} /></pre
>
<div class="break-words relative h-full px-1">
<DisplayResult bind:drawerOpen={resultDrawerOpen} result={frontendJob} />
</div>
{:else if testJob != undefined && 'result' in testJob && testJob.result != undefined}
<pre class="overflow-x-auto break-words relative h-full px-2 pt-2"
><DisplayResult
<div class="break-words relative h-full px-1">
<DisplayResult
bind:drawerOpen={resultDrawerOpen}
workspaceId={testJob?.workspace_id}
jobId={testJob?.id}
result={testJob.result}
/></pre
/></div
>
{:else}
<div class="p-2">
<div class="px-1 pt-1">
{#if testIsLoading}
<Loader2 class="animate-spin" />
{:else}
@@ -144,7 +144,7 @@
duration={job?.['duration_ms']}
mem={job?.['mem_peak']}
content={job?.logs}
isLoading
isLoading={job?.['running'] == false}
tag={job?.tag}
/>
{/if}
@@ -185,7 +185,7 @@
jobId={job.id}
duration={job?.['duration_ms']}
mem={job?.['mem_peak']}
isLoading={!(job && 'logs' in job && job.logs)}
isLoading={job?.['running'] == false}
content={job?.logs}
tag={job?.tag}
/>
@@ -226,7 +226,7 @@
duration={job?.['duration_ms']}
mem={job?.['mem_peak']}
content={job?.logs}
isLoading
isLoading={job?.['running'] == false}
tag={job?.tag}
/>
{/if}
@@ -113,7 +113,7 @@
duration={previewJob?.['duration_ms']}
mem={previewJob?.['mem_peak']}
content={previewJob?.logs}
isLoading={previewIsLoading}
isLoading={previewJob?.['running'] == false && previewIsLoading}
tag={previewJob?.tag}
/>
</Pane>
@@ -751,7 +751,7 @@
jobId={job.id}
duration={job?.['duration_ms']}
mem={job?.['mem_peak']}
isLoading={!(job && 'logs' in job && job.logs)}
isLoading={job?.['running'] == false}
content={job?.logs}
tag={job?.tag}
/>