jupyterlab-emrys
Version:
A computational environment for Jupyter. Powered by Emrys
121 lines (120 loc) • 4.82 kB
JavaScript
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
;
var jupyter_js_services_1 = require('jupyter-js-services');
var plugin_1 = require('../filebrowser/plugin');
var phosphor_widget_1 = require('phosphor-widget');
var phosphor_tabs_1 = require('phosphor-tabs');
/**
* The landing page extension.
*/
exports.landingExtension = {
id: 'jupyter.extensions.landing',
requires: [jupyter_js_services_1.ServiceManager, plugin_1.PathTracker],
activate: activateLanding
};
function activateLanding(app, services, pathTracker) {
var widget = new phosphor_widget_1.Widget();
widget.id = 'landing-jupyterlab';
widget.title.text = 'Launcher';
widget.title.closable = true;
widget.addClass('jp-Landing');
var dialog = document.createElement('div');
dialog.className = 'jp-Landing-dialog';
widget.node.appendChild(dialog);
var logo = document.createElement('span');
logo.className = 'jp-ImageJupyterLab jp-Landing-logo';
dialog.appendChild(logo);
var previewMessages = ["the emrys version", "the emrys edition", "emrys edition", "the emrys variety", "the emrys variant"];
var subtitle = document.createElement('span');
subtitle.textContent = previewMessages[Math.floor(Math.random() * previewMessages.length)];
subtitle.className = 'jp-Landing-subtitle';
dialog.appendChild(subtitle);
var tour = document.createElement('span');
tour.className = 'jp-Landing-tour';
dialog.appendChild(tour);
tour.addEventListener('click', function () {
app.commands.execute('about-jupyterlab:show');
});
var header = document.createElement('span');
header.textContent = 'Start a new activity';
header.className = 'jp-Landing-header';
dialog.appendChild(header);
var body = document.createElement('div');
body.className = 'jp-Landing-body';
dialog.appendChild(body);
for (var _i = 0, _a = ['Notebook', 'Console', 'Terminal', 'Text Editor']; _i < _a.length; _i++) {
var name_1 = _a[_i];
var column = document.createElement('div');
body.appendChild(column);
column.className = 'jp-Landing-column';
var img_1 = document.createElement('span');
var imgName = name_1.replace(' ', '');
img_1.className = "jp-Image" + imgName + " jp-Landing-image";
column.appendChild(img_1);
var text = document.createElement('span');
text.textContent = name_1;
text.className = 'jp-Landing-text';
column.appendChild(text);
}
var img = body.getElementsByClassName('jp-ImageNotebook')[0];
img.addEventListener('click', function () {
app.commands.execute('file-operations:new-notebook');
});
img = body.getElementsByClassName('jp-ImageConsole')[0];
img.addEventListener('click', function () {
app.commands.execute("console:create-" + services.kernelspecs.default);
});
img = body.getElementsByClassName('jp-ImageTextEditor')[0];
img.addEventListener('click', function () {
app.commands.execute('file-operations:new-text-file');
});
img = body.getElementsByClassName('jp-ImageTerminal')[0];
img.addEventListener('click', function () {
app.commands.execute('terminal:create-new');
});
var cwd = document.createElement('div');
cwd.className = 'jp-Landing-cwd';
var folderImage = document.createElement('span');
folderImage.className = 'jp-Landing-folder';
var path = document.createElement('span');
path.textContent = 'home';
pathTracker.pathChanged.connect(function () {
if (pathTracker.path.length > 0) {
path.textContent = 'home > ';
var path2 = pathTracker.path;
path2 = path2.replace("/", " > ");
path.textContent += path2;
}
else {
path.textContent = "home";
}
});
path.className = 'jp-Landing-path';
cwd.appendChild(folderImage);
cwd.appendChild(path);
dialog.appendChild(cwd);
app.commands.add([{
id: 'jupyterlab-launcher:show',
handler: function () {
if (!widget.isAttached) {
app.shell.addToMainArea(widget);
}
var stack = widget.parent;
if (!stack) {
return;
}
var tabs = stack.parent;
if (tabs instanceof phosphor_tabs_1.TabPanel) {
tabs.currentWidget = widget;
}
app.shell.activateMain(widget.id);
}
}]);
app.palette.add([{
command: 'jupyterlab-launcher:show',
text: 'JupyterLab Launcher',
category: 'Help'
}]);
app.shell.addToMainArea(widget);
}