Commit 703bed34 authored by Mark Ghiorso's avatar Mark Ghiorso

Show a comic in teh panel

parent bf00d910
......@@ -10,6 +10,10 @@ import {
Widget
} from '@phosphor/widgets';
import {
ServerConnection
} from '@jupyterlab/services';
import '../style/index.css';
......@@ -22,13 +26,25 @@ const extension: JupyterLabPlugin<void> = {
requires: [ICommandPalette],
activate: (app, palette: ICommandPalette) => {
console.log('JupyterLab extension jupyterlab_gitlab is activated!');
// Create a single widget
let widget: Widget = new Widget();
widget.id = 'xkcd-jupyterlab';
widget.title.label = 'xkcd.com';
widget.title.closable = true;
// Add an image element to the panel
let img = document.createElement('img');
widget.node.appendChild(img);
// Fetch info about a random comic
let settings = ServerConnection.makeSettings();
ServerConnection.makeRequest({url: 'https:////egszlpbmle.execute-api.us-east-1.amazonaws.com/prod'}, settings).then(response => {
img.src = response.data.img;
img.alt = response.data.title;
img.title = response.data.alt;
});
// Add an application command
const command: string = 'xkcd:open';
app.commands.addCommand(command, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment