Skip to content

Commit

Permalink
improve handling of restored connections in js
Browse files Browse the repository at this point in the history
- dismiss 'connection lost' dialog on reconnect
- set busy status on reconnect (if not busy, idle will come soon after via kernel_ready)
  • Loading branch information
minrk committed Oct 4, 2017
1 parent 68602fa commit 65c9817
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion notebook/static/notebook/js/notificationarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ define([

this.events.on('kernel_connected.Kernel', function () {
knw.info("Connected", 500);
// trigger busy in the status to clear broken-link state immediately
// a kernel_ready event will come when the kernel becomes responsive.
$kernel_ind_icon
.attr('class', 'kernel_busy_icon')
.attr('title', i18n.msg._('Kernel Connected'));
});

this.events.on('kernel_restarting.Kernel', function () {
Expand Down Expand Up @@ -161,7 +166,7 @@ define([
" The notebook will continue trying to reconnect. Check your" +
" network connection or notebook server configuration.");

dialog.kernel_modal({
var the_dialog = dialog.kernel_modal({
title: i18n.msg._("Connection failed"),
body: msg,
keyboard_manager: that.keyboard_manager,
Expand All @@ -170,6 +175,16 @@ define([
"OK": {}
}
});

// hide the dialog on reconnect if it's still visible
function dismiss() {
the_dialog.modal('hide');
}
that.events.on("kernel_connected.Kernel", dismiss);
the_dialog.on("hidden.bs.modal", function () {
// clear handler on dismiss
that.events.off("kernel_connected.Kernel", dismiss);
});
}
});

Expand Down

0 comments on commit 65c9817

Please sign in to comment.