Skip to content

Commit

Permalink
Merge pull request #41 from unity-sds/log_autoscroll
Browse files Browse the repository at this point in the history
Autoscrolls logs in UI
  • Loading branch information
jdrodjpl authored Nov 7, 2024
2 parents 232ffdd + 2158e9b commit 8ed6681
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/components/ApplicationPanelItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@
}
dispatch('refreshApplicationList');
}
let logsDiv: HTMLElement;
function scrollLogsToBottom() {
if (logsDiv) {
logsDiv.scrollIntoView({ behavior: 'smooth', block: 'end' });
}
}
$: if (logs) {
setTimeout(scrollLogsToBottom, 0);
}
</script>

<div class="lg:w-1/3 md:w-1/2 mb-4" style="flex: 0 0 auto">
Expand Down Expand Up @@ -239,7 +250,7 @@
</h2>

{#if logs}
<pre>
<pre bind:this={logsDiv}>
{logs}
</pre>
{/if}
Expand Down
15 changes: 14 additions & 1 deletion src/routes/install/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@
let showLogs = false;
let logs: string;
let logsDiv: HTMLElement;
function scrollLogsToBottom() {
if (logsDiv) {
logsDiv.scrollIntoView({ behavior: 'smooth', block: 'end' });
}
}
$: if (logs) {
// Wait for DOM update
setTimeout(scrollLogsToBottom, 0);
}
let logInterval: any = null;
async function getLogs() {
Expand Down Expand Up @@ -224,7 +237,7 @@
{#if showLogs && logs}
<div style="margin-top:10px">
<hr />
<pre>
<pre bind:this={logsDiv}>
{logs}
</pre>
</div>
Expand Down

0 comments on commit 8ed6681

Please sign in to comment.