Skip to content

Commit

Permalink
Implement #3027
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Oct 14, 2024
1 parent 090a9a9 commit a5122a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion frontend/components/DiscreteProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cl } from "../common/ClassTable.js"
import { html, useEffect, useRef, useState } from "../imports/Preact.js"

export const DiscreteProgressBar = ({ total, done, busy, failed_indices }) => {
export const DiscreteProgressBar = ({ onClick, total, done, busy, failed_indices }) => {
total = Math.max(1, total)

return html`
Expand All @@ -13,6 +13,7 @@ export const DiscreteProgressBar = ({ total, done, busy, failed_indices }) => {
"big": total >= 48,
})}
data-total=${total}
onClick=${onClick}
>
${[...Array(total)].map((_, i) => {
return html`<div
Expand Down
15 changes: 11 additions & 4 deletions frontend/components/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,20 @@ export const ProgressBar = ({ notebook, backend_launch_phase, status }) => {
`}
onClick=${(e) => {
if (!binder_loading) {
const running_cell = Object.values(notebook.cell_results).find((c) => c.running) ?? Object.values(notebook.cell_results).find((c) => c.queued)
if (running_cell) {
scroll_cell_into_view(running_cell.cell_id)
}
scroll_to_busy_cell(notebook)
}
}}
aria-hidden="true"
title=${title}
></loading-bar>`
}

export const scroll_to_busy_cell = (notebook) => {
const running_cell_id =
notebook == null
? (document.querySelector("pluto-cell.running") ?? document.querySelector("pluto-cell.queued"))?.id
: (Object.values(notebook.cell_results).find((c) => c.running) ?? Object.values(notebook.cell_results).find((c) => c.queued))?.cell_id
if (running_cell_id) {
scroll_cell_into_view(running_cell_id)
}
}
5 changes: 4 additions & 1 deletion frontend/components/StatusTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { prettytime, useMillisSinceTruthy } from "./RunArea.js"
import { DiscreteProgressBar } from "./DiscreteProgressBar.js"
import { PkgTerminalView } from "./PkgTerminalView.js"
import { NotifyWhenDone } from "./NotifyWhenDone.js"
import { scroll_to_busy_cell } from "./ProgressBar.js"

/**
* @param {{
Expand Down Expand Up @@ -172,7 +173,9 @@ const StatusItem = ({ status_tree, path, my_clock_is_ahead_by, nbpkg, backend_la

let failed_indices = kids.reduce((acc, x, i) => (x.success === false ? [...acc, i] : acc), [])

return html`<${DiscreteProgressBar} busy=${busy} done=${done} total=${total} failed_indices=${failed_indices} />`
const onClick = mystatus.name === "evaluate" ? () => scroll_to_busy_cell() : undefined

return html`<${DiscreteProgressBar} busy=${busy} done=${done} total=${total} failed_indices=${failed_indices} onClick=${onClick} />`
}

const inner = is_open
Expand Down

0 comments on commit a5122a7

Please sign in to comment.