mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Merge pull request #5215 from ivanov/running-kernels
Dashboard "Running" Tab
This commit is contained in:
commit
f8ab13b675
40
IPython/html/static/tree/js/kernellist.js
Normal file
40
IPython/html/static/tree/js/kernellist.js
Normal file
@ -0,0 +1,40 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// Copyright (C) 2014 The IPython Development Team
|
||||
//
|
||||
// Distributed under the terms of the BSD License. The full license is in
|
||||
// the file COPYING, distributed as part of this software.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//============================================================================
|
||||
// Running Kernels List
|
||||
//============================================================================
|
||||
|
||||
var IPython = (function (IPython) {
|
||||
"use strict";
|
||||
|
||||
var utils = IPython.utils;
|
||||
|
||||
var KernelList = function (selector, options) {
|
||||
IPython.NotebookList.call(this, selector, options, 'running');
|
||||
};
|
||||
|
||||
KernelList.prototype = Object.create(IPython.NotebookList.prototype);
|
||||
|
||||
KernelList.prototype.sessions_loaded = function (d) {
|
||||
this.sessions = d;
|
||||
this.clear_list();
|
||||
var item;
|
||||
for (var path in d) {
|
||||
item = this.new_notebook_item(-1);
|
||||
this.add_link('', path, item);
|
||||
this.add_shutdown_button(item, this.sessions[path]);
|
||||
}
|
||||
|
||||
$('#running_list_header').toggle($.isEmptyObject(d));
|
||||
}
|
||||
|
||||
IPython.KernelList = KernelList;
|
||||
|
||||
return IPython;
|
||||
|
||||
}(IPython));
|
@ -22,8 +22,10 @@ $(document).ready(function () {
|
||||
base_url : IPython.utils.get_body_data("baseUrl"),
|
||||
notebook_path : IPython.utils.get_body_data("notebookPath"),
|
||||
};
|
||||
IPython.session_list = new IPython.SesssionList(opts);
|
||||
IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts);
|
||||
IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts);
|
||||
IPython.kernel_list = new IPython.KernelList('#running_list', opts);
|
||||
IPython.login_widget = new IPython.LoginWidget('#login_widget', opts);
|
||||
|
||||
var interval_id=0;
|
||||
@ -35,14 +37,14 @@ $(document).ready(function () {
|
||||
//refresh immediately , then start interval
|
||||
if($('.upload_button').length == 0)
|
||||
{
|
||||
IPython.notebook_list.load_sessions();
|
||||
IPython.session_list.load_sessions();
|
||||
IPython.cluster_list.load_list();
|
||||
}
|
||||
if (!interval_id){
|
||||
interval_id = setInterval(function(){
|
||||
if($('.upload_button').length == 0)
|
||||
{
|
||||
IPython.notebook_list.load_sessions();
|
||||
IPython.session_list.load_sessions();
|
||||
IPython.cluster_list.load_list();
|
||||
}
|
||||
}, time_refresh*1000);
|
||||
@ -71,7 +73,7 @@ $(document).ready(function () {
|
||||
|
||||
// bound the upload method to the on change of the file select list
|
||||
$("#alternate_upload").change(function (event){
|
||||
IPython.notebook_list.handelFilesUpload(event,'form');
|
||||
IPython.notebook_list.handleFilesUpload(event,'form');
|
||||
});
|
||||
|
||||
// set hash on tab click
|
||||
|
@ -14,7 +14,10 @@ var IPython = (function (IPython) {
|
||||
|
||||
var utils = IPython.utils;
|
||||
|
||||
var NotebookList = function (selector, options) {
|
||||
var NotebookList = function (selector, options, element_name) {
|
||||
var that = this
|
||||
// allow code re-use by just changing element_name in kernellist.js
|
||||
this.element_name = element_name || 'notebook';
|
||||
this.selector = selector;
|
||||
if (this.selector !== undefined) {
|
||||
this.element = $(selector);
|
||||
@ -25,32 +28,35 @@ var IPython = (function (IPython) {
|
||||
this.sessions = {};
|
||||
this.base_url = options.base_url || utils.get_body_data("baseUrl");
|
||||
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
|
||||
$([IPython.events]).on('sessions_loaded.Dashboard',
|
||||
function(e, d) { that.sessions_loaded(d); });
|
||||
};
|
||||
|
||||
NotebookList.prototype.style = function () {
|
||||
$('#notebook_toolbar').addClass('list_toolbar');
|
||||
$('#drag_info').addClass('toolbar_info');
|
||||
$('#notebook_buttons').addClass('toolbar_buttons');
|
||||
$('#notebook_list_header').addClass('list_header');
|
||||
var prefix = '#' + this.element_name
|
||||
$(prefix + '_toolbar').addClass('list_toolbar');
|
||||
$(prefix + '_list_info').addClass('toolbar_info');
|
||||
$(prefix + '_buttons').addClass('toolbar_buttons');
|
||||
$(prefix + '_list_header').addClass('list_header');
|
||||
this.element.addClass("list_container");
|
||||
};
|
||||
|
||||
|
||||
NotebookList.prototype.bind_events = function () {
|
||||
var that = this;
|
||||
$('#refresh_notebook_list').click(function () {
|
||||
that.load_list();
|
||||
$('#refresh_' + this.element_name + '_list').click(function () {
|
||||
that.load_sessions();
|
||||
});
|
||||
this.element.bind('dragover', function () {
|
||||
return false;
|
||||
});
|
||||
this.element.bind('drop', function(event){
|
||||
that.handelFilesUpload(event,'drop');
|
||||
that.handleFilesUpload(event,'drop');
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
NotebookList.prototype.handelFilesUpload = function(event, dropOrForm) {
|
||||
NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) {
|
||||
var that = this;
|
||||
var files;
|
||||
if(dropOrForm =='drop'){
|
||||
@ -98,37 +104,12 @@ var IPython = (function (IPython) {
|
||||
};
|
||||
|
||||
NotebookList.prototype.load_sessions = function(){
|
||||
var that = this;
|
||||
var settings = {
|
||||
processData : false,
|
||||
cache : false,
|
||||
type : "GET",
|
||||
dataType : "json",
|
||||
success : $.proxy(that.sessions_loaded, this)
|
||||
};
|
||||
var url = utils.url_join_encode(this.base_url, 'api/sessions');
|
||||
$.ajax(url,settings);
|
||||
IPython.session_list.load_sessions();
|
||||
};
|
||||
|
||||
|
||||
NotebookList.prototype.sessions_loaded = function(data){
|
||||
this.sessions = {};
|
||||
var len = data.length;
|
||||
if (len > 0) {
|
||||
for (var i=0; i<len; i++) {
|
||||
var nb_path;
|
||||
if (!data[i].notebook.path) {
|
||||
nb_path = data[i].notebook.name;
|
||||
}
|
||||
else {
|
||||
nb_path = utils.url_path_join(
|
||||
data[i].notebook.path,
|
||||
data[i].notebook.name
|
||||
);
|
||||
}
|
||||
this.sessions[nb_path] = data[i].id;
|
||||
}
|
||||
}
|
||||
this.sessions = data;
|
||||
this.load_list();
|
||||
};
|
||||
|
||||
|
52
IPython/html/static/tree/js/sessionlist.js
Normal file
52
IPython/html/static/tree/js/sessionlist.js
Normal file
@ -0,0 +1,52 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// Copyright (C) 2014 The IPython Development Team
|
||||
//
|
||||
// Distributed under the terms of the BSD License. The full license is in
|
||||
// the file COPYING, distributed as part of this software.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//============================================================================
|
||||
// Running Kernels List
|
||||
//============================================================================
|
||||
|
||||
var IPython = (function (IPython) {
|
||||
"use strict";
|
||||
|
||||
var utils = IPython.utils;
|
||||
|
||||
var SesssionList = function (options) {
|
||||
this.sessions = {};
|
||||
this.base_url = options.base_url || utils.get_body_data("baseUrl");
|
||||
};
|
||||
|
||||
SesssionList.prototype.load_sessions = function(){
|
||||
var that = this;
|
||||
var settings = {
|
||||
processData : false,
|
||||
cache : false,
|
||||
type : "GET",
|
||||
dataType : "json",
|
||||
success : $.proxy(that.sessions_loaded, this)
|
||||
};
|
||||
var url = utils.url_join_encode(this.base_url, 'api/sessions');
|
||||
$.ajax(url, settings);
|
||||
};
|
||||
|
||||
SesssionList.prototype.sessions_loaded = function(data){
|
||||
this.sessions = {};
|
||||
var len = data.length;
|
||||
var nb_path;
|
||||
for (var i=0; i<len; i++) {
|
||||
nb_path = utils.url_path_join(
|
||||
data[i].notebook.path,
|
||||
data[i].notebook.name
|
||||
);
|
||||
this.sessions[nb_path] = data[i].id;
|
||||
}
|
||||
$([IPython.events]).trigger('sessions_loaded.Dashboard', this.sessions);
|
||||
};
|
||||
IPython.SesssionList = SesssionList;
|
||||
|
||||
return IPython;
|
||||
|
||||
}(IPython));
|
@ -24,6 +24,7 @@ data-notebook-path="{{notebook_path}}"
|
||||
<div id="tab_content" class="tabbable">
|
||||
<ul id="tabs" class="nav nav-tabs">
|
||||
<li class="active"><a href="#notebooks" data-toggle="tab">Notebooks</a></li>
|
||||
<li><a href="#running" data-toggle="tab">Running</a></li>
|
||||
<li><a href="#clusters" data-toggle="tab">Clusters</a></li>
|
||||
</ul>
|
||||
|
||||
@ -32,9 +33,9 @@ data-notebook-path="{{notebook_path}}"
|
||||
<div id="notebook_toolbar" class="row-fluid">
|
||||
<div class="span8">
|
||||
<form id='alternate_upload' class='alternate_upload' >
|
||||
<span id="drag_info" style="position:absolute" >
|
||||
<span id="notebook_list_info" style="position:absolute" >
|
||||
To import a notebook, drag the file onto the listing below or <strong>click here</strong>.
|
||||
</span>
|
||||
</span>
|
||||
<input type="file" name="datafile" class="fileinput" multiple='multiple'>
|
||||
</form>
|
||||
</div>
|
||||
@ -60,6 +61,26 @@ data-notebook-path="{{notebook_path}}"
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="running" class="tab-pane">
|
||||
|
||||
<div id="running_toolbar" class="row-fluid">
|
||||
<div class="span8">
|
||||
<span id="running_list_info">Currently running IPython notebooks</span>
|
||||
</div>
|
||||
<div class="span4" class="clearfix">
|
||||
<span id="running_buttons" class="pull-right">
|
||||
<button id="refresh_running_list" title="Refresh running list" class="btn btn-small"><i class="icon-refresh"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="running_list">
|
||||
<div id="running_list_header" class="row-fluid list_header">
|
||||
<div> There are no notebooks running. </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="clusters" class="tab-pane">
|
||||
|
||||
<div id="cluster_toolbar" class="row-fluid">
|
||||
@ -92,7 +113,9 @@ data-notebook-path="{{notebook_path}}"
|
||||
{{super()}}
|
||||
<script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("tree/js/sessionlist.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("tree/js/kernellist.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user