Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@jupyterlab/coreutils": "^5.0.0 || ^6.0.0",
"@jupyterlab/docregistry": "^3.0.0 || ^4.0.0",
"@jupyterlab/notebook": "^3.0.0 || ^4.0.0",
"@jupyterlab/services": "^6.0.0 || ^7.0.0",
"@lumino/disposable": "^1.4.3 || ^2.0.0",
"@lumino/widgets": "^1.17.0 || ^2.0.0",
"@types/jquery": "^3",
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IDisposable, DisposableDelegate } from '@lumino/disposable';
import { Widget } from '@lumino/widgets';

import { PageConfig } from '@jupyterlab/coreutils';
import { ServerConnection } from '@jupyterlab/services';

import {
JupyterFrontEnd,
Expand Down Expand Up @@ -306,9 +307,13 @@ function showBinderLink<T>(panel: NotebookPanel): Promise<Dialog.IResult<T>> {
function activate(app: JupyterFrontEnd): void {
console.log('Activating jupyter-offlinenotebook JupyterLab extension');
const baseUrl = PageConfig.getBaseUrl();
$.getJSON(baseUrl + 'offlinenotebook/config', (data) => {
offline.initialise(data);
// addButtons();
const settings = ServerConnection.makeSettings();
ServerConnection.makeRequest(
baseUrl + 'offlinenotebook/config',
{},
settings,
).then(async (response) => {
offline.initialise(await response.json());
});
app.docRegistry.addWidgetExtension('Notebook', new OfflineNotebookButtons());
}
Expand Down
13 changes: 11 additions & 2 deletions tests/test_offlinenotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
from time import sleep
from urllib.request import urlopen
from urllib.error import URLError

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
Expand Down Expand Up @@ -87,6 +88,16 @@ def start_jupyter(self, jupyterdir, app):
}
self.jupyter_proc = subprocess.Popen(command, cwd=str(jupyterdir), env=env)

# Wait for Jupyter to start
for n in range(10):
sleep(1)
try:
with urlopen(f"http://localhost:{PORT}", timeout=2) as _:
pass
except URLError:
continue
print(f"jupyter-{app} started")

def initialise_firefox(self, downloaddir, url):
profile = FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
Expand Down Expand Up @@ -342,8 +353,6 @@ def test_offline_lab(self, tmpdir):
class TestServer(FirefoxTestBase):
def test_server_config(self, tmpdir):
self.start_jupyter(tmpdir, "server")
# Wait for server to start
sleep(2)

with urlopen(CONFIG_URL) as r:
assert json.load(r) == {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"esModuleInterop": true,
"incremental": true,
"jsx": "react",
"lib": ["DOM", "ES2018", "ES2020.Intl"],
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
Expand Down
Loading