mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Merge pull request #4842 from Carreau/fix-JG-complaint
more subtle kernel indicator
This commit is contained in:
commit
e322d96481
@ -69,17 +69,17 @@ var IPython = (function (IPython) {
|
||||
|
||||
NotificationArea.prototype.init_notification_widgets = function() {
|
||||
var knw = this.new_notification_widget('kernel');
|
||||
var $kernel_indic = $("#kernel_indicator");
|
||||
|
||||
// Kernel events
|
||||
$([IPython.events]).on('status_idle.Kernel',function () {
|
||||
IPython.save_widget.update_document_title();
|
||||
knw.set_message('Kernel Idle',200);
|
||||
}
|
||||
);
|
||||
$kernel_indic.attr('class','icon-circle-blank').attr('title','Kernel Idle');
|
||||
});
|
||||
|
||||
$([IPython.events]).on('status_busy.Kernel',function () {
|
||||
window.document.title='(Busy) '+window.document.title;
|
||||
knw.set_message("Kernel busy");
|
||||
$kernel_indic.attr('class','icon-circle').attr('title','Kernel Busy');
|
||||
});
|
||||
|
||||
$([IPython.events]).on('status_restarting.Kernel',function () {
|
||||
|
@ -26,6 +26,9 @@ var IPython = (function (IPython) {
|
||||
this.element.hide();
|
||||
var that = this;
|
||||
|
||||
this.inner = $('<span/>');
|
||||
this.element.append(this.inner);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -40,10 +43,13 @@ var IPython = (function (IPython) {
|
||||
// if timeout <= 0
|
||||
// click_callback : function called if user click on notification
|
||||
// could return false to prevent the notification to be dismissed
|
||||
NotificationWidget.prototype.set_message = function (msg, timeout, click_callback) {
|
||||
NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, opts) {
|
||||
var opts = opts || {};
|
||||
var callback = click_callback || function() {return false;};
|
||||
var that = this;
|
||||
this.element.text(msg);
|
||||
this.inner.attr('class', opts.icon);
|
||||
this.inner.attr('title', opts.title);
|
||||
this.inner.text(msg);
|
||||
this.element.fadeIn(100);
|
||||
if (this.timeout !== null) {
|
||||
clearTimeout(this.timeout);
|
||||
@ -51,13 +57,13 @@ var IPython = (function (IPython) {
|
||||
}
|
||||
if (timeout !== undefined && timeout >=0) {
|
||||
this.timeout = setTimeout(function () {
|
||||
that.element.fadeOut(100, function () {that.element.text('');});
|
||||
that.element.fadeOut(100, function () {that.inner.text('');});
|
||||
that.timeout = null;
|
||||
}, timeout);
|
||||
} else {
|
||||
this.element.click(function() {
|
||||
if( callback() != false ) {
|
||||
that.element.fadeOut(100, function () {that.element.text('');});
|
||||
that.element.fadeOut(100, function () {that.inner.text('');});
|
||||
that.element.unbind('click');
|
||||
}
|
||||
if (that.timeout !== undefined) {
|
||||
@ -70,7 +76,7 @@ var IPython = (function (IPython) {
|
||||
|
||||
|
||||
NotificationWidget.prototype.get_message = function () {
|
||||
return this.element.html();
|
||||
return this.inner.html();
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,5 +6,17 @@
|
||||
border: 1px solid #ccc;
|
||||
border-radius: @baseBorderRadius;
|
||||
background: rgba(240, 240, 240, 0.5);
|
||||
|
||||
&.span {
|
||||
padding-right:2px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#indicator_area{
|
||||
color: @navbarLinkColor;
|
||||
padding: 2px 2px;
|
||||
margin: 2px -9px 2px 4px;
|
||||
z-index: 10;
|
||||
|
||||
}
|
||||
|
189
IPython/html/static/style/ipython.min.css
vendored
189
IPython/html/static/style/ipython.min.css
vendored
File diff suppressed because one or more lines are too long
1559
IPython/html/static/style/style.min.css
vendored
1559
IPython/html/static/style/style.min.css
vendored
File diff suppressed because one or more lines are too long
@ -248,6 +248,9 @@ class="notebook_app"
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<div class='pull-right' id="indicator_area">
|
||||
<div id="kernel_indicator"></div>
|
||||
</div>
|
||||
<div id="notification_area"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,12 +12,7 @@ casper.notebook_test(function () {
|
||||
cell.execute();
|
||||
});
|
||||
|
||||
this.waitFor(function(){
|
||||
return this.evaluate(function() {
|
||||
return $("#notification_kernel")[0].textContent.indexOf('busy') !== -1;
|
||||
});
|
||||
});
|
||||
|
||||
this.wait_for_busy();
|
||||
|
||||
// interrupt using menu item (Kernel -> Interrupt)
|
||||
this.thenClick('li#int_kernel');
|
||||
|
@ -58,6 +58,14 @@ casper.delete_current_notebook = function () {
|
||||
});
|
||||
};
|
||||
|
||||
casper.wait_for_busy = function () {
|
||||
this.waitFor(function () {
|
||||
return this.evaluate(function () {
|
||||
return IPython._status == 'busy';
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
casper.wait_for_idle = function () {
|
||||
this.waitFor(function () {
|
||||
return this.evaluate(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user