UNPKG

jupyterlab-emrys

Version:

A computational environment for Jupyter. Powered by Emrys

87 lines (86 loc) 2.72 kB
// Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. "use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var phosphor_panel_1 = require('phosphor-panel'); var dialog_1 = require('../dialog'); var widget_1 = require('./widget'); /** * The class name added to console panels. */ var PANEL_CLASS = 'jp-ConsolePanel'; /** * A panel which contains a console and the ability to add other children. */ var ConsolePanel = (function (_super) { __extends(ConsolePanel, _super); /** * Construct a console panel. */ function ConsolePanel(options) { _super.call(this); this._console = null; this.addClass(PANEL_CLASS); // Create console widget. this._console = options.console || new widget_1.ConsoleWidget({ session: options.session, rendermime: options.rendermime }); this.addChild(this._console); } Object.defineProperty(ConsolePanel.prototype, "content", { /** * The console widget used by the panel. * * #### Notes * This is a read-only property. */ get: function () { return this._console; }, enumerable: true, configurable: true }); /** * Dispose of the resources held by the widget. */ ConsolePanel.prototype.dispose = function () { if (this.isDisposed) { return; } // Dispose console widget. this._console.dispose(); this._console = null; _super.prototype.dispose.call(this); }; /** * Handle `'close-request'` messages. */ ConsolePanel.prototype.onCloseRequest = function (msg) { var _this = this; var session = this.content.session; if (!session.kernel) { this.dispose(); } session.kernel.getKernelSpec().then(function (spec) { var name = spec.display_name; return dialog_1.showDialog({ title: 'Shut down kernel?', body: "Shut down " + name + "?" }); }).then(function (value) { if (value && value.text === 'OK') { return session.shutdown(); } }).then(function () { _super.prototype.onCloseRequest.call(_this, msg); _this.dispose(); }); }; return ConsolePanel; }(phosphor_panel_1.Panel)); exports.ConsolePanel = ConsolePanel;