jupyter-js-notebook
Advanced tools
Comparing version 0.12.0 to 0.12.1
@@ -175,2 +175,5 @@ import { INotebookSession, IContentsManager } from 'jupyter-js-services'; | ||
* Save the notebook and clear the dirty state of the model. | ||
* | ||
* #### Notes | ||
* Also updates the metadata if there is a current session. | ||
*/ | ||
@@ -183,2 +186,6 @@ save(): Promise<void>; | ||
/** | ||
* Save the notebook contents to disk. | ||
*/ | ||
private _save(); | ||
/** | ||
* Handle a change in the cells list. | ||
@@ -185,0 +192,0 @@ */ |
@@ -265,11 +265,19 @@ "use strict"; | ||
* Save the notebook and clear the dirty state of the model. | ||
* | ||
* #### Notes | ||
* Also updates the metadata if there is a current session. | ||
*/ | ||
NotebookModel.prototype.save = function () { | ||
var _this = this; | ||
var content = serialize_1.serialize(this); | ||
var name = this.session.notebookPath; | ||
return this._manager.save(name, { | ||
type: 'notebook', | ||
content: content | ||
}).then(function () { _this.dirty = false; }); | ||
if (!this.session || this.session.isDisposed) { | ||
return this._save(); | ||
} | ||
return this.session.kernel.getKernelSpec().then(function (spec) { | ||
_this.metadata.kernelspec.display_name = spec.display_name; | ||
_this.metadata.kernelspec.name = _this.session.kernel.name; | ||
return _this.session.kernel.kernelInfo(); | ||
}).then(function (info) { | ||
_this.metadata.language_info = info.language_info; | ||
return _this._save(); | ||
}); | ||
}; | ||
@@ -315,2 +323,12 @@ /** | ||
/** | ||
* Save the notebook contents to disk. | ||
*/ | ||
NotebookModel.prototype._save = function () { | ||
var _this = this; | ||
var content = serialize_1.serialize(this); | ||
var name = this.session.notebookPath; | ||
return this._manager.save(name, { type: 'notebook', content: content }) | ||
.then(function () { _this.dirty = false; }); | ||
}; | ||
/** | ||
* Handle a change in the cells list. | ||
@@ -317,0 +335,0 @@ */ |
@@ -0,1 +1,2 @@ | ||
import { INotebookSession, IKernel } from 'jupyter-js-services'; | ||
import { Message } from 'phosphor-messaging'; | ||
@@ -5,4 +6,4 @@ import { IChangedArgs } from 'phosphor-properties'; | ||
import { Widget } from 'phosphor-widget'; | ||
import { ICellModel } from '../cells'; | ||
import { INotebookModel } from './model'; | ||
import { ICellModel } from '../cells'; | ||
import './codemirror-ipython'; | ||
@@ -180,2 +181,6 @@ import './codemirror-ipythongfm'; | ||
/** | ||
* Handle a change to the kernel. | ||
*/ | ||
protected handleKernel(session: INotebookSession, kernel: IKernel): void; | ||
/** | ||
* Handle `click` events for the widget. | ||
@@ -182,0 +187,0 @@ */ |
@@ -417,3 +417,8 @@ // Copyright (c) Jupyter Development Team. | ||
this._model = model; | ||
this.kernelNameNode.textContent = model.metadata.kernelspec.display_name; | ||
if (model.metadata && model.metadata.kernelspec) { | ||
this.kernelNameNode.textContent = model.metadata.kernelspec.display_name; | ||
} | ||
else { | ||
this.kernelNameNode.textContent = 'No Kernel!'; | ||
} | ||
if (model.cells.length) { | ||
@@ -748,3 +753,4 @@ var cell = model.cells.get(model.activeCellIndex); | ||
var node = this.kernelIndicatorNode; | ||
this.model.session.kernel.statusChanged.connect(function (sender, status) { | ||
var session = this.model.session; | ||
session.statusChanged.connect(function (sender, status) { | ||
if (status === jupyter_js_services_1.KernelStatus.Idle) { | ||
@@ -757,3 +763,3 @@ node.classList.remove(TOOLBAR_BUSY); | ||
}); | ||
if (this.model.session.status === jupyter_js_services_1.KernelStatus.Idle) { | ||
if (session.status === jupyter_js_services_1.KernelStatus.Idle) { | ||
node.classList.remove(TOOLBAR_BUSY); | ||
@@ -764,4 +770,15 @@ } | ||
} | ||
session.kernelChanged.connect(this.handleKernel, this); | ||
this.handleKernel(session, session.kernel); | ||
}; | ||
/** | ||
* Handle a change to the kernel. | ||
*/ | ||
NotebookToolbar.prototype.handleKernel = function (session, kernel) { | ||
var _this = this; | ||
kernel.getKernelSpec().then(function (spec) { | ||
_this.kernelNameNode.textContent = spec.display_name; | ||
}); | ||
}; | ||
/** | ||
* Handle `click` events for the widget. | ||
@@ -768,0 +785,0 @@ */ |
{ | ||
"name": "jupyter-js-notebook", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"description": "Notebook widget for Jupyter", | ||
@@ -10,3 +10,3 @@ "main": "lib/index.js", | ||
"diff-match-patch": "^1.0.0", | ||
"jupyter-js-services": "^0.5.2", | ||
"jupyter-js-services": "^0.6.1", | ||
"jupyter-js-ui": "^0.2.0", | ||
@@ -13,0 +13,0 @@ "marked": "^0.3.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169040
5424
- Removedjupyter-js-services@0.5.5(transitive)
Updatedjupyter-js-services@^0.6.1