瀏覽代碼

clear TODO items

Mehmet Bektas 5 年之前
父節點
當前提交
746b0a8e82

+ 3 - 3
packages/logconsole-extension/schema/plugin.json

@@ -1,8 +1,8 @@
 {
   "jupyter.lab.setting-icon-class": "jp-SettingsIcon",
-  "jupyter.lab.setting-icon-label": "Output Console",
-  "title": "Output Console",
-  "description": "Output Console settings.",
+  "jupyter.lab.setting-icon-label": "Log Console",
+  "title": "Log Console",
+  "description": "Log Console settings.",
   "properties": {
     "maxLogEntries": {
       "type": "number",

+ 19 - 20
packages/logconsole-extension/src/index.tsx

@@ -354,12 +354,6 @@ function activateLogConsole(
       } else {
         logConsoleWidget.activate();
       }
-
-      // TODO, repeat in command?
-      status.model.entryLimit = entryLimit;
-      status.model.markSourceLogsRead(status.model.activeSource);
-      status.model.highlightingEnabled = false;
-      status.model.stateChanged.emit(void 0);
     }
   });
 
@@ -376,20 +370,6 @@ function activateLogConsole(
     logConsoleWidget.title.iconClass = 'lab-output-console-icon';
     logConsolePanel.entryLimit = entryLimit;
 
-    app.shell.add(logConsoleWidget, 'main', {
-      ref: '',
-      mode: 'split-bottom'
-    });
-
-    logConsoleWidget.update();
-
-    app.shell.activateById(logConsoleWidget.id);
-    status.model.highlightingEnabled = false;
-
-    if (activeSource) {
-      logConsolePanel.activeSource = activeSource;
-    }
-
     const addTimestampButton = new ToolbarButton({
       onClick: (): void => {
         if (!logConsolePanel.activeSource) {
@@ -427,10 +407,29 @@ function activateLogConsole(
 
     void tracker.add(logConsoleWidget);
 
+    logConsolePanel.attached.connect(() => {
+      status.model.markSourceLogsRead(status.model.activeSource);
+      status.model.highlightingEnabled = false;
+      status.model.stateChanged.emit(void 0);
+    }, this);
+
     logConsoleWidget.disposed.connect(() => {
       logConsoleWidget = null;
       status.model.highlightingEnabled = highlightingEnabled;
+    }, this);
+
+    app.shell.add(logConsoleWidget, 'main', {
+      ref: '',
+      mode: 'split-bottom'
     });
+
+    logConsoleWidget.update();
+
+    app.shell.activateById(logConsoleWidget.id);
+
+    if (activeSource) {
+      logConsolePanel.activeSource = activeSource;
+    }
   };
 
   app.commands.addCommand(command, {

+ 1 - 1
packages/logconsole-extension/style/index.css

@@ -9,8 +9,8 @@
 @import url('~@jupyterlab/rendermime/style/index.css');
 @import url('~@jupyterlab/docregistry/style/index.css');
 @import url('~@jupyterlab/application/style/index.css');
+@import url('~@jupyterlab/logconsole/style/index.css');
 @import url('~@jupyterlab/mainmenu/style/index.css');
 @import url('~@jupyterlab/notebook/style/index.css');
-@import url('~@jupyterlab/logconsole/style/index.css');
 
 @import url('./base.css');

+ 3 - 3
packages/logconsole-extension/tsconfig.json

@@ -19,13 +19,13 @@
       "path": "../docregistry"
     },
     {
-      "path": "../mainmenu"
+      "path": "../logconsole"
     },
     {
-      "path": "../notebook"
+      "path": "../mainmenu"
     },
     {
-      "path": "../logconsole"
+      "path": "../notebook"
     },
     {
       "path": "../rendermime"

+ 10 - 4
packages/logconsole/src/index.tsx

@@ -286,8 +286,7 @@ export class LogConsolePanel extends StackedPanel {
     super();
 
     this._loggerRegistry = loggerRegistry;
-    this.addClass('jlab-output-logger-view');
-    this.node.style.overflowY = 'auto'; // TODO: use CSS class
+    this.addClass('jp-LogConsolePanel');
 
     loggerRegistry.registryChanged.connect(
       (sender: ILoggerRegistry, args: ILoggerRegistryChange) => {
@@ -309,12 +308,16 @@ export class LogConsolePanel extends StackedPanel {
     this._updateOutputAreas();
     this._showOutputFromSource(this._activeSource);
     this._showPlaceholderIfNoMessage();
+    this.attached.emit();
   }
 
   private _bindLoggerSignals() {
     const loggers = this._loggerRegistry.getLoggers();
     for (let logger of loggers) {
-      // TODO: optimize
+      if (this._loggersWatched.has(logger.source)) {
+        continue;
+      }
+
       logger.logChanged.connect((sender: ILogger, args: ILoggerChange) => {
         this._updateOutputAreas();
         this._showPlaceholderIfNoMessage();
@@ -327,6 +330,8 @@ export class LogConsolePanel extends StackedPanel {
           outputArea.rendermime = sender.rendermime;
         }
       }, this);
+
+      this._loggersWatched.add(logger.source);
     }
   }
 
@@ -394,7 +399,6 @@ export class LogConsolePanel extends StackedPanel {
       loggerIds.add(viewId);
 
       // add view for logger if not exist
-      // TODO: or rendermime changed
       if (!this._outputAreas.has(viewId)) {
         const outputArea = new LogConsoleOutputArea({
           rendermime: logger.rendermime,
@@ -456,10 +460,12 @@ export class LogConsolePanel extends StackedPanel {
     }
   }
 
+  readonly attached = new Signal<this, void>(this);
   private _loggerRegistry: ILoggerRegistry;
   private _outputAreas = new Map<string, LogConsoleOutputArea>();
   private _activeSource: string = null;
   private _entryLimit: number = DEFAULT_LOG_ENTRY_LIMIT;
   private _scrollTimer: number = null;
   private _placeholder: Widget;
+  private _loggersWatched: Set<string> = new Set();
 }

+ 6 - 2
packages/logconsole/style/base.css

@@ -75,11 +75,15 @@
   width: calc(100% - 135px);
 }
 
-.jlab-output-logger-view .jp-OutputArea-child {
+.jp-LogConsolePanel {
+  overflow-y: auto;
+}
+
+.jp-LogConsolePanel .jp-OutputArea-child {
   border-bottom: 1px solid var(--jp-border-color3);
 }
 
-.jlab-output-logger-view .jp-OutputArea-prompt {
+.jp-LogConsolePanel .jp-OutputArea-prompt {
   width: 85px;
   color: var(--jp-ui-font-color2);
   font-size: 13px;

+ 6 - 6
packages/metapackage/tsconfig.json

@@ -123,6 +123,12 @@
     {
       "path": "../launcher-extension"
     },
+    {
+      "path": "../logconsole"
+    },
+    {
+      "path": "../logconsole-extension"
+    },
     {
       "path": "../mainmenu"
     },
@@ -153,12 +159,6 @@
     {
       "path": "../outputarea"
     },
-    {
-      "path": "../logconsole"
-    },
-    {
-      "path": "../logconsole-extension"
-    },
     {
       "path": "../pdf-extension"
     },