first crack
This commit is contained in:
parent
13767b7255
commit
c537db3216
3 changed files with 34 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
import ujson
|
||||
from notebook.base.handlers import IPythonHandler
|
||||
|
||||
|
||||
|
@ -6,7 +7,7 @@ class IFrameHandler(IPythonHandler):
|
|||
self.iframes = iframes
|
||||
|
||||
def get(self):
|
||||
self.finish(self.iframes)
|
||||
self.finish(ujson.dumps(self.iframes))
|
||||
|
||||
|
||||
def load_jupyter_server_extension(nb_server_app):
|
||||
|
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
jupyterlab
|
||||
ujson
|
30
src/index.ts
30
src/index.ts
|
@ -105,6 +105,36 @@ function activate(app: JupyterLab, docManager: IDocumentManager, palette: IComma
|
|||
|
||||
// Add the command to the palette.
|
||||
palette.addItem({command: open_command, category: 'Tools'});
|
||||
|
||||
// grab sites from serverextension
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "/iframes", true);
|
||||
xhr.onload = function (e:any) {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
let sites = JSON.parse(xhr.responseText);
|
||||
for(let site of sites){
|
||||
console.log(site);
|
||||
let command = 'iframe:open-' + site;
|
||||
app.commands.addCommand(command, {
|
||||
label: 'Open ' + site,
|
||||
isEnabled: () => true,
|
||||
execute: () => {
|
||||
widget = new IFrameWidget(site);
|
||||
app.shell.addToMainArea(widget);
|
||||
app.shell.activateById(widget.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.error(xhr.statusText);
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
xhr.onerror = function (e) {
|
||||
console.error(xhr.statusText);
|
||||
};
|
||||
xhr.send(null);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue