Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50655 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
'base/js/utils',
8
], function(IPython, $, utils) {
9
"use strict";
10
11
var SesssionList = function (options) {
12
/**
13
* Constructor
14
*
15
* Parameters:
16
* options: dictionary
17
* Dictionary of keyword arguments.
18
* events: $(Events) instance
19
* base_url : string
20
*/
21
this.events = options.events;
22
this.sessions = {};
23
this.base_url = options.base_url || utils.get_body_data("baseUrl");
24
25
// Add collapse arrows.
26
$('#running .panel-group .panel .panel-heading a').each(function(index, el) {
27
var $link = $(el);
28
var $icon = $('<i />')
29
.addClass('fa fa-caret-down');
30
$link.append($icon);
31
$link.down = true;
32
$link.click(function () {
33
if ($link.down) {
34
$link.down = false;
35
// jQeury doesn't know how to animate rotations. Abuse
36
// jQueries animate function by using an unused css attribute
37
// to do the animation (borderSpacing).
38
$icon.animate({ borderSpacing: 90 }, {
39
step: function(now,fx) {
40
$icon.css('transform','rotate(-' + now + 'deg)');
41
}
42
}, 250);
43
} else {
44
$link.down = true;
45
// See comment above.
46
$icon.animate({ borderSpacing: 0 }, {
47
step: function(now,fx) {
48
$icon.css('transform','rotate(-' + now + 'deg)');
49
}
50
}, 250);
51
}
52
});
53
});
54
};
55
56
SesssionList.prototype.load_sessions = function(){
57
var that = this;
58
var settings = {
59
processData : false,
60
cache : false,
61
type : "GET",
62
dataType : "json",
63
success : $.proxy(that.sessions_loaded, this),
64
error : utils.log_ajax_error,
65
};
66
var url = utils.url_join_encode(this.base_url, 'api/sessions');
67
$.ajax(url, settings);
68
};
69
70
SesssionList.prototype.sessions_loaded = function(data){
71
this.sessions = {};
72
var len = data.length;
73
var nb_path;
74
for (var i=0; i<len; i++) {
75
nb_path = data[i].notebook.path;
76
this.sessions[nb_path] = data[i].id;
77
}
78
this.events.trigger('sessions_loaded.Dashboard', this.sessions);
79
};
80
81
// Backwards compatability.
82
IPython.SesssionList = SesssionList;
83
84
return {'SesssionList': SesssionList};
85
});
86
87