Skip to content

Commit

Permalink
#6214 add UI options (#6798)
Browse files Browse the repository at this point in the history
* #6423 expose full bootstrap styles for lab, and fix font path issue

* #6423 Create and register BeakerxTree JupyterLabPlugin

* #6423 BeakerXTreeWidget - recreate layout using "@phosphor/widgets" Panel

* #6423 BannerWidget - implementation using "@phosphor/widgets"

* #6423 SyncIndicatorWidget

* #6423 JVMOptionsWidget

* #6423 BeakerxApi and Urls for BeakerxTree

* #6423 add overflow to Widget

* #6423 remove unused code

* #6423 DefaultOptionsWidget, DefaultOptionsModel and HeapGBValidator

* #6423 PropertiesWidget, PropertiesModel

* #6423 SyncIndicatorWidget

* #6423 Messages

* #6423 OtherOptionsWidget, OtherOptionsModel

* #6423 BeakerxApi

* #6423 BeakerxApi JVMOptionsWidget

* #6423 Restore widget state on reload

* #6423 change => keyup

* #6423 change command label

* #6423 wip

* #6423 move tree source from js/lab to js/notebook

* #6423 packages, tsconfig, jquery

* #6423 fix compilation errors

* #6423 working tree widget in notebook

* #6423 remove not needed files

* #6423 remove paths from .gitignore

* #6423 use BeakerXTreeWidget in lab

* #6423 fix missed baseUrl TODO; BeakerxApi => BeakerXApi; fix NaN showing when changing heap size to empty string

* #6423 fix

* #6214 add UIOptionsWidget, UIOptionsModel, messages and logic

* #6214 remove console.log

* #6214 change widget template

* #6214 add show_publication to IUIOptions

* #6214 add show_publication UIOptionsWidget

* #6214 add JVMOptionsChangedMessage

* #6214 refactor ui_options are not part of jvm_options, load and save are performed on TreeModel/Widget level

* #6214 rename BeakerXTreeWidget => TreeWidget; introduce isLab and CodeCell options; move BeakerXApi creation into TreeWidget

* #6214 extract IApiSettingsResponse

* #6214 extract IJVMOptions

* #6214 extract IUIOptions

* #6214 extract ITreeWidgetOptions

* #6214 DefaultOptionsWidgetInterface

* #6214 PropertiesWidgetInterface

* #6214 OtherOptionsWidgetInterface

* #6214 DefaultOptionsModel

* #6214 OtherOptionsModel

* #6214 PropertiesModel

* #6214 export default

* #6214 remove extracted OtherOptionsModel class from file

* #6214 JVMOptionsModel

* #6214 remove types/interfaces there were extracted

* #6214 HeapGBValidator

* #6214 fix import

* #6214 add TreeWidgetModel; UIOptionsModel

* #6214 add UIOptionsWidget, UIOptionsWidgetInterface

* #6214 fix after move

* #6214 extract model

* #6214 add banner fix imports

* #6214 pass CodeCell to TreeWidget

* #6214 use saved ui_options

* #6214 remove not needed code

* #6214 handle show_publication

* #6214 move UIOptionsHelper to extension directory

* #6214 remove comment

* #6214 remove not needed option in lab

* #6214 cs fixes

* #6214 fix uiOptionsModel undefined case

* #6214 show publication should be enabled by default; set default options in the backend

* #6214 add margin to wide cells

* #6214 better handling of autoCloseBrackets; disable improve fonts handle

* #6214 hide improve fonts checkbox

* #6214 fix margins
  • Loading branch information
piorek authored and scottdraves committed Feb 8, 2018
1 parent afd129b commit fa28a12
Show file tree
Hide file tree
Showing 33 changed files with 1,043 additions and 335 deletions.
6 changes: 6 additions & 0 deletions beakerx/beakerx/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
"heap_GB": null,
"other": [],
"properties": {}
},
"ui_options": {
"auto_close": false,
"improve_fonts": true,
"wide_cells": true,
"show_publication": true
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions js/lab/src/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { JSONExt } from "@phosphor/coreutils";
import { PageConfig } from "@jupyterlab/coreutils";

const BeakerXTreeLib = require("../lib/tree.js").default;
const BeakerXTreeWidget = BeakerXTreeLib.BeakerXTreeWidget;
const BeakerXApi = BeakerXTreeLib.BeakerXApi;
const TreeWidget = BeakerXTreeLib.TreeWidget;

function activate(app: JupyterLab, palette: ICommandPalette, restorer: ILayoutRestorer) {
let widget:any;
Expand All @@ -34,9 +33,11 @@ function activate(app: JupyterLab, palette: ICommandPalette, restorer: ILayoutRe
label: 'BeakerX Options',
execute: () => {
if (!widget) {
widget = new BeakerXTreeWidget(
new BeakerXApi(PageConfig.getBaseUrl())
);
let options = {
baseUrl: PageConfig.getBaseUrl(),
isLab: true,
};
widget = new TreeWidget(options);
widget.update();
}
if (!tracker.has(widget)) {
Expand Down
6 changes: 3 additions & 3 deletions js/notebook/src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define([
'./plot/plotApi',
'./shared/bkCoreManager',
'big.js',
'./extension/gistPublish/index'
'./extension/UIOptionsHelper'
], function(
configmod,
comm,
Expand All @@ -62,7 +62,7 @@ define([
plotApi,
bkCoreManager,
big,
GistPublish
UIOptionsHelper
) {
"use strict";

Expand All @@ -75,7 +75,7 @@ define([
var commUtils = require('./extension/comm');
var initCellUtils = require('./extension/initializationCells');

GistPublish.registerFeature();
UIOptionsHelper.registerFeature(base_url);

function installKernelHandler() {
var kernel = Jupyter.notebook.kernel;
Expand Down
82 changes: 82 additions & 0 deletions js/notebook/src/extension/UIOptionsHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import './../global.env';

import BeakerXApi from "../tree/Utils/BeakerXApi";
import * as GistPublish from "./gistPublish/index";


export function registerFeature(baseUrl: string): void {
if (!!Jupyter.NotebookList) {
return;
}

const api = new BeakerXApi(baseUrl);
api.loadSettings()
.then((data) => {

setupAutoCloseBrackets(data.ui_options.auto_close);
setupWideCells(data.ui_options.wide_cells);
// setupImproveFonts(data.ui_options.improve_fonts);
setupShowPublication(data.ui_options.show_publication);

})
.catch((e) => {
console.log(e);
});
}

function setupAutoCloseBrackets(autoCloseBrackets: boolean): void {
// new cells
Jupyter.CodeCell.options_default.cm_config.autoCloseBrackets = autoCloseBrackets;

// existing
const code_cells = Jupyter.notebook.get_cells().filter((cell) => {
return cell.cell_type = 'code';
});

for (let cell of code_cells) {
let cm = cell.code_mirror;
if (cm.getOption('autoCloseBrackets') !== autoCloseBrackets) {
cm.setOption('autoCloseBrackets', autoCloseBrackets);
}
}

}

function setupWideCells(wideCells: boolean): void {
if (!wideCells) {
return;
}

let s = document.createElement('style');
s.innerText = `#notebook_panel .container { width:auto; margin: 0 16px; }`;

document.body.appendChild(s);
}

// function setupImproveFonts(improveFonts: boolean) {
// // TODO;
// console.log('handle improve fonts', improveFonts);
// }

function setupShowPublication(showPublication: boolean) {
if (!showPublication) {
return;
}
GistPublish.registerFeature();
}
24 changes: 19 additions & 5 deletions js/notebook/src/tree-lab.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import BeakerXTreeWidget from './tree/TreeWidget';
import BeakerXApi from "./tree/BeakerXApi";
/*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import TreeWidget from "./tree/TreeWidget";

export default {
BeakerXTreeWidget: BeakerXTreeWidget,
BeakerXApi: BeakerXApi,
}
TreeWidget: TreeWidget,
}
10 changes: 6 additions & 4 deletions js/notebook/src/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ define([
var Widget = require('@phosphor/widgets').Widget;

function load() {
var base_url = (Jupyter.notebook_list || Jupyter.notebook).base_url;
var BeakerXTreeWidget = require('./tree/TreeWidget').default;
var BeakerxApi = require('./tree/BeakerXApi').default;
var bxWidget = new BeakerXTreeWidget(new BeakerxApi(base_url));
var TreeWidget = require('./tree/TreeWidget').default;
var options = {
baseUrl: (Jupyter.notebook_list || Jupyter.notebook).base_url,
isLab: false
};
var bxWidget = new TreeWidget(options);

Widget.attach(bxWidget, $('.tab-content').get(0));
$('#tabs').append(
Expand Down
Loading

0 comments on commit fa28a12

Please sign in to comment.