##// END OF EJS Templates
Fixed session js ajax request....
Zachary Sailer -
Show More
@@ -66,7 +66,6 b' var IPython = (function (IPython) {'
66 this.input_prompt_number = null;
66 this.input_prompt_number = null;
67 this.collapsed = false;
67 this.collapsed = false;
68 this.cell_type = "code";
68 this.cell_type = "code";
69 this.last_msg_id = null;
70
69
71
70
72 var cm_overwrite_options = {
71 var cm_overwrite_options = {
@@ -241,12 +240,9 b' var IPython = (function (IPython) {'
241 * @method execute
240 * @method execute
242 */
241 */
243 CodeCell.prototype.execute = function () {
242 CodeCell.prototype.execute = function () {
244 this.output_area.clear_output();
243 this.output_area.clear_output(true, true, true);
245 this.set_input_prompt('*');
244 this.set_input_prompt('*');
246 this.element.addClass("running");
245 this.element.addClass("running");
247 if (this.last_msg_id) {
248 this.kernel.clear_callbacks_for_msg(this.last_msg_id);
249 }
250 var callbacks = {
246 var callbacks = {
251 'execute_reply': $.proxy(this._handle_execute_reply, this),
247 'execute_reply': $.proxy(this._handle_execute_reply, this),
252 'output': $.proxy(this.output_area.handle_output, this.output_area),
248 'output': $.proxy(this.output_area.handle_output, this.output_area),
@@ -254,7 +250,7 b' var IPython = (function (IPython) {'
254 'set_next_input': $.proxy(this._handle_set_next_input, this),
250 'set_next_input': $.proxy(this._handle_set_next_input, this),
255 'input_request': $.proxy(this._handle_input_request, this)
251 'input_request': $.proxy(this._handle_input_request, this)
256 };
252 };
257 this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
253 var msg_id = this.session.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
258 };
254 };
259
255
260 /**
256 /**
@@ -390,8 +386,8 b' var IPython = (function (IPython) {'
390 };
386 };
391
387
392
388
393 CodeCell.prototype.clear_output = function (wait) {
389 CodeCell.prototype.clear_output = function (stdout, stderr, other) {
394 this.output_area.clear_output(wait);
390 this.output_area.clear_output(stdout, stderr, other);
395 };
391 };
396
392
397
393
@@ -13,31 +13,31 b' var IPython = (function (IPython) {'
13
13
14 var Session = function(notebook_name, notebook_path, Notebook){
14 var Session = function(notebook_name, notebook_path, Notebook){
15 this.kernel = null;
15 this.kernel = null;
16 this.kernel_id = null;
16 this.id = null;
17 this.session_id = null;
17 this.name = notebook_name;
18 this.notebook_name = notebook_name;
18 this.path = notebook_path;
19 this.notebook_path = notebook_path;
20 this.notebook = Notebook;
19 this.notebook = Notebook;
21 this._baseProjectUrl = Notebook.baseProjectUrl()
20 this._baseProjectUrl = Notebook.baseProjectUrl()
22 };
21 };
23
22
24 Session.prototype.start = function() {
23 Session.prototype.start = function() {
25 var that = this
24 var that = this
26 var notebook = {'notebook':{'name': this.notebook_name, 'path': this.notebook_path}}
25 var notebook = {'notebook':{'name': this.name, 'path': this.path}}
27 var settings = {
26 var settings = {
28 processData : false,
27 processData : false,
29 cache : false,
28 cache : false,
30 type : "POST",
29 type : "POST",
31 data: JSON.stringify(notebook),
30 data: JSON.stringify(notebook),
32 dataType : "json",
31 dataType : "json",
32 success : $.proxy(this.start_kernel, that),
33 };
33 };
34 var url = this._baseProjectUrl + 'api/sessions';
34 var url = this._baseProjectUrl + 'api/sessions';
35 $.ajax(url, settings);
35 $.ajax(url, settings);
36 };
36 };
37
37
38 Session.prototype.notebook_rename = function (name, path) {
38 Session.prototype.notebook_rename = function (name, path) {
39 this.notebook_name = name;
39 this.name = name;
40 this.notebook_path = path;
40 this.path = path;
41 var notebook = {'notebook':{'name':name, 'path': path}};
41 var notebook = {'notebook':{'name':name, 'path': path}};
42 var settings = {
42 var settings = {
43 processData : false,
43 processData : false,
@@ -68,7 +68,7 b' var IPython = (function (IPython) {'
68 * @method start_kernel
68 * @method start_kernel
69 */
69 */
70 Session.prototype.start_kernel = function (json) {
70 Session.prototype.start_kernel = function (json) {
71 this.session_id = json.id;
71 this.id = json.id;
72 this.kernel_content = json.kernel;
72 this.kernel_content = json.kernel;
73 var base_url = $('body').data('baseKernelUrl') + "api/kernels";
73 var base_url = $('body').data('baseKernelUrl') + "api/kernels";
74 this.kernel = new IPython.Kernel(base_url, this.session_id);
74 this.kernel = new IPython.Kernel(base_url, this.session_id);
@@ -112,14 +112,15 b' var IPython = (function (IPython) {'
112
112
113 NotebookList.prototype.sessions_loaded = function(data){
113 NotebookList.prototype.sessions_loaded = function(data){
114 this.sessions = new Object();
114 this.sessions = new Object();
115 console.log(data)
115 var len = data.length;
116 var len = data.length;
116 if (len != 0) {
117 if (len != 0) {
117 for (var i=0; i<len; i++) {
118 for (var i=0; i<len; i++) {
118 if (data[i]['path']==null) {
119 if (data[i]['notebook']['path']==null) {
119 nb_path = data[i]['name'];
120 nb_path = data[i]['notebook']['name'];
120 }
121 }
121 else {
122 else {
122 nb_path = data[i]['path'] + data[i]['name'];
123 nb_path = data[i]['notebook']['path'] + data[i]['notebook']['name'];
123 }
124 }
124 this.sessions[nb_path]= data[i]['id'];
125 this.sessions[nb_path]= data[i]['id'];
125 }
126 }
@@ -352,4 +353,3 b' var IPython = (function (IPython) {'
352 return IPython;
353 return IPython;
353
354
354 }(IPython));
355 }(IPython));
355
General Comments 0
You need to be logged in to leave comments. Login now