##// END OF EJS Templates
Merge pull request #6026 from takluyver/kernelspec-rest-launching...
Merge pull request #6026 from takluyver/kernelspec-rest-launching Kernelspecs in REST API for kernels and sessions

File last commit:

r17223:6a78ad85
r17234:b537531d merge
Show More
session.js
120 lines | 3.4 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Almost done!...
r17198 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
Zachary Sailer
manual rebase static/services (add session.js)
r12987
Jonathan Frederic
Almost done!...
r17198 define([
'base/js/namespace',
Jonathan Frederic
MWE,...
r17200 'jquery',
Jonathan Frederic
Almost done!...
r17198 'base/js/utils',
'services/kernels/js/kernel',
Jonathan Frederic
Fix imports of "modules",...
r17202 ], function(IPython, $, utils, kernel) {
MinRK
review pass on multidir js
r13103 "use strict";
Jonathan Frederic
Almost done!...
r17198
jon
In person review with @ellisonbg
r17210 var Session = function(options){
Zachary Sailer
manual rebase static/services (add session.js)
r12987 this.kernel = null;
Zachary Sailer
Fixed session js ajax request....
r13060 this.id = null;
jon
In person review with @ellisonbg
r17210 this.notebook = options.notebook;
Jonathan Frederic
Some JS test fixes
r17212 this.name = options.notebook_name;
this.path = options.notebook_path;
Thomas Kluyver
Update JS for kernels and sessions APIs
r17223 this.kernel_name = options.kernel_name;
Jonathan Frederic
Some JS test fixes
r17212 this.base_url = options.base_url;
Zachary Sailer
manual rebase static/services (add session.js)
r12987 };
MinRK
Cells shouldn't know about Sessions
r13133 Session.prototype.start = function(callback) {
MinRK
review pass on multidir js
r13103 var that = this;
var model = {
notebook : {
name : this.name,
path : this.path
Thomas Kluyver
Update JS for kernels and sessions APIs
r17223 },
kernel : {
name : this.kernel_name
MinRK
review pass on multidir js
r13103 }
};
Zachary Sailer
changes after session manager code review
r13057 var settings = {
processData : false,
cache : false,
type : "POST",
MinRK
review pass on multidir js
r13103 data: JSON.stringify(model),
Zachary Sailer
changes after session manager code review
r13057 dataType : "json",
MinRK
Cells shouldn't know about Sessions
r13133 success : function (data, status, xhr) {
that._handle_start_success(data);
if (callback) {
callback(data, status, xhr);
}
},
MinRK
log all failed ajax API requests
r16445 error : utils.log_ajax_error,
Zachary Sailer
changes after session manager code review
r13057 };
MinRK
s/base_project_url/base_url/...
r15238 var url = utils.url_join_encode(this.base_url, 'api/sessions');
Zachary Sailer
changes after session manager code review
r13057 $.ajax(url, settings);
Zachary Sailer
manual rebase static/services (add session.js)
r12987 };
MinRK
Cells shouldn't know about Sessions
r13133 Session.prototype.rename_notebook = function (name, path) {
Zachary Sailer
Fixed session js ajax request....
r13060 this.name = name;
this.path = path;
MinRK
review pass on multidir js
r13103 var model = {
notebook : {
name : this.name,
path : this.path
}
};
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997 var settings = {
processData : false,
cache : false,
type : "PATCH",
MinRK
review pass on multidir js
r13103 data: JSON.stringify(model),
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997 dataType : "json",
MinRK
log all failed ajax API requests
r16445 error : utils.log_ajax_error,
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997 };
MinRK
s/base_project_url/base_url/...
r15238 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997 $.ajax(url, settings);
MinRK
review pass on multidir js
r13103 };
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997
MinRK
Cells shouldn't know about Sessions
r13133 Session.prototype.delete = function() {
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997 var settings = {
processData : false,
cache : false,
type : "DELETE",
dataType : "json",
MinRK
log all failed ajax API requests
r16445 error : utils.log_ajax_error,
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997 };
Paul Ivanov
fix: JS kernel state should reflect killed state
r13308 this.kernel.running = false;
MinRK
s/base_project_url/base_url/...
r15238 var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id);
Zachary Sailer
Add 'patch' to session & notebook, rename working
r12997 $.ajax(url, settings);
};
Zachary Sailer
manual rebase static/services (add session.js)
r12987 // Kernel related things
/**
MinRK
Cells shouldn't know about Sessions
r13133 * Create the Kernel object associated with this Session.
Zachary Sailer
manual rebase static/services (add session.js)
r12987 *
MinRK
Cells shouldn't know about Sessions
r13133 * @method _handle_start_success
Zachary Sailer
manual rebase static/services (add session.js)
r12987 */
MinRK
Cells shouldn't know about Sessions
r13133 Session.prototype._handle_start_success = function (data, status, xhr) {
this.id = data.id;
MinRK
remove base_kernel_url
r15310 var kernel_service_url = utils.url_path_join(this.base_url, "api/kernels");
Thomas Kluyver
Update JS for kernels and sessions APIs
r17223 this.kernel = new kernel.Kernel(kernel_service_url, this.notebook, this.kernel_name);
MinRK
Cells shouldn't know about Sessions
r13133 this.kernel._kernel_started(data.kernel);
Zachary Sailer
manual rebase static/services (add session.js)
r12987 };
/**
* Prompt the user to restart the IPython kernel.
*
* @method restart_kernel
*/
Session.prototype.restart_kernel = function () {
Zachary Sailer
fix restart/interrupt kernel buttons
r12994 this.kernel.restart();
Zachary Sailer
manual rebase static/services (add session.js)
r12987 };
Zachary Sailer
fix restart/interrupt kernel buttons
r12994 Session.prototype.interrupt_kernel = function() {
this.kernel.interrupt();
Zachary Sailer
fix kill_and_exit button in notebook
r12995 };
Session.prototype.kill_kernel = function() {
MinRK
review pass on multidir js
r13103 this.kernel.kill();
Zachary Sailer
fix kill_and_exit button in notebook
r12995 };
Zachary Sailer
fix restart/interrupt kernel buttons
r12994
Jonathan Frederic
Almost done!...
r17198 // For backwards compatability.
Zachary Sailer
manual rebase static/services (add session.js)
r12987 IPython.Session = Session;
Jonathan Frederic
Return dicts instead of classes,...
r17201 return {'Session': Session};
Jonathan Frederic
Almost done!...
r17198 });