Skip to content

Commit c21421f

Browse files
committed
Show kernel status
1 parent 91c6fa5 commit c21421f

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

src/doc/common/static/jupyter-sphinx-furo.js

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,56 @@ const observer2 = new MutationObserver(callback);
3434
observer2.observe(document.getElementsByClassName("content")[0], { childList: true, subtree: true });
3535

3636

37-
// Run custom code once the kernel is ready
37+
// Listen to the kernel status changes
3838
// https://thebe.readthedocs.io/en/stable/events.html
3939
thebelab.on("status", function (evt, data) {
40-
if (data.status === 'ready') {
40+
if (data.status === 'building') {
41+
const elements = document.querySelectorAll('.thebelab-cell');
42+
elements.forEach(element => {
43+
element.style.filter = 'opacity(50%)';
44+
});
45+
const element = document.getElementById("thebelab-activate-button");
46+
element.innerHTML = "Building";
47+
element.style.right = '.4rem';
48+
}
49+
else if (data.status === 'built') {
50+
const elements = document.querySelectorAll('.thebelab-cell');
51+
elements.forEach(element => {
52+
element.style.filter = 'opacity(60%)';
53+
});
54+
const element = document.getElementById("thebelab-activate-button");
55+
element.innerHTML = "Built";
56+
element.style.right = '.4rem';
57+
}
58+
else if (data.status === 'launching') {
59+
const elements = document.querySelectorAll('.thebelab-cell');
60+
elements.forEach(element => {
61+
element.style.filter = 'opacity(70%)';
62+
});
63+
const element = document.getElementById("thebelab-activate-button");
64+
element.innerHTML = "Launching";
65+
element.style.right = '.4rem';
66+
}
67+
else if (data.status === 'failed') {
68+
const elements = document.querySelectorAll('.thebelab-cell');
69+
elements.forEach(element => {
70+
element.style.filter = 'opacity(50%)';
71+
});
72+
const element = document.getElementById("thebelab-activate-button");
73+
element.innerHTML = 'Failed: ' + data.message;
74+
element.style.right = '.4rem';
75+
element.style.width = 'auto';
76+
element.style.color = 'red';
77+
}
78+
else if (data.status === 'ready') {
79+
const elements = document.querySelectorAll('.thebelab-cell');
80+
elements.forEach(element => {
81+
element.style.filter = 'opacity(100%)';
82+
});
83+
const element = document.getElementById("thebelab-activate-button");
84+
element.innerHTML = "Ready";
85+
element.style.right = null;
86+
// Run custom code when the kernel is ready
4187
const kernel = data.kernel;
4288
kernel.requestExecute({code: "%display latex"});
4389
}

0 commit comments

Comments
 (0)