From 65c9817806b5f902041a8ca3e521c13ef16caf99 Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 4 Oct 2017 11:49:43 +0200 Subject: [PATCH] improve handling of restored connections in js - dismiss 'connection lost' dialog on reconnect - set busy status on reconnect (if not busy, idle will come soon after via kernel_ready) --- notebook/static/notebook/js/notificationarea.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/notificationarea.js b/notebook/static/notebook/js/notificationarea.js index ed183db42bd..078712da3bc 100644 --- a/notebook/static/notebook/js/notificationarea.js +++ b/notebook/static/notebook/js/notificationarea.js @@ -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 () { @@ -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, @@ -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); + }); } });