Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50654 views
1
// Copyright (c) IPython Development Team.
2
// Distributed under the terms of the Modified BSD License.
3
4
define([
5
'base/js/namespace',
6
'jquery',
7
'tree/js/notebooklist',
8
], function(IPython, $, notebooklist) {
9
"use strict";
10
11
var KernelList = function (selector, options) {
12
/**
13
* Constructor
14
*
15
* Parameters:
16
* selector: string
17
* options: dictionary
18
* Dictionary of keyword arguments.
19
* session_list: SessionList instance
20
* base_url: string
21
* notebook_path: string
22
*/
23
notebooklist.NotebookList.call(this, selector, $.extend({
24
element_name: 'running'},
25
options));
26
};
27
28
KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
29
30
KernelList.prototype.add_duplicate_button = function () {
31
/**
32
* do nothing
33
*/
34
};
35
36
KernelList.prototype.sessions_loaded = function (d) {
37
this.sessions = d;
38
this.clear_list();
39
var item, path;
40
for (path in d) {
41
if (!d.hasOwnProperty(path)) {
42
// nothing is safe in javascript
43
continue;
44
}
45
item = this.new_item(-1);
46
this.add_link({
47
name: path,
48
path: path,
49
type: 'notebook',
50
}, item);
51
}
52
$('#running_list_placeholder').toggle($.isEmptyObject(d));
53
};
54
55
KernelList.prototype.add_link = function (model, item) {
56
notebooklist.NotebookList.prototype.add_link.apply(this, [model, item])
57
58
var running_indicator = item.find(".item_buttons")
59
.text('');
60
61
var that = this;
62
var shutdown_button = $('<button/>')
63
.addClass('btn btn-warning btn-xs')
64
.text('Shutdown')
65
.click(function() {
66
var path = $(this).parent().parent().parent().data('path');
67
that.shutdown_notebook(path);
68
})
69
.appendTo(running_indicator);
70
};
71
72
// Backwards compatability.
73
IPython.KernelList = KernelList;
74
75
return {'KernelList': KernelList};
76
});
77
78