Show More
@@ -78,14 +78,12 b' define([' | |||||
78 | * @param {function} [error] - functon executed on ajax error |
|
78 | * @param {function} [error] - functon executed on ajax error | |
79 | */ |
|
79 | */ | |
80 | Session.prototype.start = function (success, error) { |
|
80 | Session.prototype.start = function (success, error) { | |
81 | if (this.kernel !== null) { |
|
|||
82 | throw new Error("session has already been started"); |
|
|||
83 | }; |
|
|||
84 |
|
||||
85 | var that = this; |
|
81 | var that = this; | |
86 | var on_success = function (data, status, xhr) { |
|
82 | var on_success = function (data, status, xhr) { | |
87 | var kernel_service_url = utils.url_path_join(that.base_url, "api/kernels"); |
|
83 | if (!that.kernel) { | |
88 | that.kernel = new kernel.Kernel(kernel_service_url, that.ws_url, that.notebook, that.kernel_model.name); |
|
84 | var kernel_service_url = utils.url_path_join(that.base_url, "api/kernels"); | |
|
85 | that.kernel = new kernel.Kernel(kernel_service_url, that.ws_url, that.notebook, that.kernel_model.name); | |||
|
86 | } | |||
89 | that.events.trigger('kernel_started.Session', {session: that, kernel: that.kernel}); |
|
87 | that.events.trigger('kernel_started.Session', {session: that, kernel: that.kernel}); | |
90 | that.kernel._kernel_started(data.kernel); |
|
88 | that.kernel._kernel_started(data.kernel); | |
91 | if (success) { |
|
89 | if (success) { | |
@@ -186,6 +184,24 b' define([' | |||||
186 | }); |
|
184 | }); | |
187 | }; |
|
185 | }; | |
188 |
|
186 | |||
|
187 | Session.prototype.restart = function (options, success, error) { | |||
|
188 | var that = this; | |||
|
189 | var start = function () { | |||
|
190 | if (options && options.notebook_name) { | |||
|
191 | that.notebook_model.name = options.notebook_name; | |||
|
192 | } | |||
|
193 | if (options && options.notebook_path) { | |||
|
194 | that.notebook_model.path = options.notebook_path; | |||
|
195 | } | |||
|
196 | if (options && options.kernel_name) { | |||
|
197 | that.kernel_model.name = options.kernel_name; | |||
|
198 | } | |||
|
199 | that.kernel_model.id = null; | |||
|
200 | that.start(success, error); | |||
|
201 | }; | |||
|
202 | this.delete(start, start); | |||
|
203 | }; | |||
|
204 | ||||
189 | // Helper functions |
|
205 | // Helper functions | |
190 |
|
206 | |||
191 | /** |
|
207 | /** |
General Comments 0
You need to be logged in to leave comments.
Login now