Skip to content

Commit

Permalink
feat: pause log following on mouse over
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Jan 27, 2025
1 parent 3e39bfd commit 1187776
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
padding: 0;
overflow: hidden;
}

body > div {
margin: 16px;
}
Expand Down Expand Up @@ -60,7 +61,7 @@
<iframe id="logs" src='data:text/html,<p>Click on a task to see logs</p>'
onload="this.contentWindow.scrollTo(0, this.contentWindow.document.body.scrollHeight);"></iframe>
</div>
<div><label><input type="checkbox" id="follow" checked>Follow</label></div>
<div id="follow"></div>
</div>

<script id="js">
Expand Down Expand Up @@ -132,6 +133,7 @@
name.textContent = n;
message.textContent = g.node(n).message;
logs.src = `/logs/${n}`;
follow.innerHTML = 'Following logs';
});

// set the width and height of the svg to that of the graph
Expand Down Expand Up @@ -175,14 +177,17 @@
);

setInterval(() => {
if (follow.checked && !logs.src.startsWith('data:')) {
if (follow.innerHTML.includes( 'Following') && !logs.src.startsWith('data:')) {
// update the src causing a reload, and also scroll to the bottom
const x = logs.src;
logs.src = '';
logs.src = x;
}
}, 3000);

logs.addEventListener('mouseover', () => follow.innerHTML = 'Paused logs');
logs.addEventListener('mouseout', () => follow.innerHTML = 'Following logs');

const resize = () => {
const innerWidth = window.innerWidth - 32;
const innerHeight = window.innerHeight - 32 - 32 - 16 - 16 - 8;
Expand Down

0 comments on commit 1187776

Please sign in to comment.