|
@@ -10,51 +10,32 @@ import {
|
|
|
JupyterFrontEndPlugin
|
|
|
} from '@jupyterlab/application';
|
|
|
import { MainAreaWidget } from '@jupyterlab/apputils';
|
|
|
-import { LabIcon } from '@jupyterlab/ui-components';
|
|
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
|
import DataViewWidget from './DataViewWidget';
|
|
|
import DataTableWidget from './DataTableWidget';
|
|
|
import TaskViewWidget from './TaskViewWidget';
|
|
|
import MonitorViewWidget from './MonitorViewWidget';
|
|
|
-import cliSvgStr from '../style/icons/cli.svg';
|
|
|
-import timerSvgStr from '../style/icons/timer.svg';
|
|
|
-import monitorSvgStr from '../style/icons/monitor.svg';
|
|
|
+import { cliIcon, monitorIcon, timerIcon } from './icons';
|
|
|
+import config from './api/config';
|
|
|
|
|
|
-const cliIcon = new LabIcon({
|
|
|
- name: 'cli',
|
|
|
- svgstr: cliSvgStr
|
|
|
-});
|
|
|
-
|
|
|
-const timerIcon = new LabIcon({
|
|
|
- name: 'timer',
|
|
|
- svgstr: timerSvgStr
|
|
|
-});
|
|
|
-
|
|
|
-const monitorIcon = new LabIcon({
|
|
|
- name: 'monitor',
|
|
|
- svgstr: monitorSvgStr
|
|
|
-});
|
|
|
+const PLUGIN_ID = '@jupyterlab/jldbq-extension:plugin';
|
|
|
|
|
|
const plugin: JupyterFrontEndPlugin<void> = {
|
|
|
- id: '@jupyterlab/jldbq-extension:plugin',
|
|
|
+ id: PLUGIN_ID,
|
|
|
autoStart: true,
|
|
|
requires: [ISettingRegistry],
|
|
|
activate: async (app: JupyterFrontEnd, registry: ISettingRegistry) => {
|
|
|
- // let backend: string;
|
|
|
- // try {
|
|
|
- // const settings = await registry.load(
|
|
|
- // '@jupyterlab/jldbq-extension:plugin'
|
|
|
- // );
|
|
|
- // backend = settings.composite['flaskBackend'] as string;
|
|
|
- // } catch (err) {
|
|
|
- // console.log(err);
|
|
|
- // backend = 'http://localhost:5000';
|
|
|
- // }
|
|
|
+ registry.pluginChanged.connect(async (_sender, plugin) => {
|
|
|
+ if (plugin === PLUGIN_ID) {
|
|
|
+ await updateConfig(registry);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ await updateConfig(registry);
|
|
|
|
|
|
- const manager = 'testlocal';
|
|
|
+ const manager = 'testlocal'; // TODO:
|
|
|
|
|
|
const dataViewWidget = new DataViewWidget(manager);
|
|
|
- dataViewWidget.id = 'DatabaseView';
|
|
|
+ dataViewWidget.id = 'jldbq-data';
|
|
|
dataViewWidget.title.icon = cliIcon;
|
|
|
dataViewWidget.title.caption = '数据开发';
|
|
|
dataViewWidget.title.label = '数据开发';
|
|
@@ -84,3 +65,9 @@ const plugin: JupyterFrontEndPlugin<void> = {
|
|
|
};
|
|
|
|
|
|
export default plugin;
|
|
|
+
|
|
|
+async function updateConfig(registry: ISettingRegistry) {
|
|
|
+ const settings = await registry.load(PLUGIN_ID);
|
|
|
+ const endpoint = settings.composite['flaskBackend'] as string;
|
|
|
+ config.endpoint = endpoint;
|
|
|
+}
|