1
1
import {
2
+ ILabShell ,
2
3
JupyterFrontEnd ,
3
4
JupyterFrontEndPlugin ,
4
5
} from '@jupyterlab/application' ;
5
6
import { INotebookTracker } from '@jupyterlab/notebook' ;
6
7
import { LabIcon } from '@jupyterlab/ui-components' ;
7
8
import { ICommandPalette } from '@jupyterlab/apputils' ;
9
+ import { IConsoleTracker } from '@jupyterlab/console' ;
8
10
import { KernelUsagePanel } from './panel' ;
9
11
import tachometer from '../style/tachometer.svg' ;
10
12
@@ -13,6 +15,7 @@ import { IStatusBar } from '@jupyterlab/statusbar';
13
15
import { ITranslator } from '@jupyterlab/translation' ;
14
16
15
17
import { MemoryUsage } from './memoryUsage' ;
18
+ import { KernelWidgetTracker } from './tracker' ;
16
19
17
20
namespace CommandIDs {
18
21
export const getKernelUsage = 'kernel-usage:get' ;
@@ -46,13 +49,15 @@ const memoryStatusPlugin: JupyterFrontEndPlugin<void> = {
46
49
const kernelUsagePlugin : JupyterFrontEndPlugin < void > = {
47
50
id : '@jupyter-server/resource-usage:kernel-panel-item' ,
48
51
autoStart : true ,
49
- optional : [ ICommandPalette ] ,
52
+ optional : [ ICommandPalette , ILabShell , IConsoleTracker ] ,
50
53
requires : [ ITranslator , INotebookTracker ] ,
51
54
activate : (
52
55
app : JupyterFrontEnd ,
53
56
translator : ITranslator ,
54
57
notebookTracker : INotebookTracker ,
55
- palette : ICommandPalette | null
58
+ palette : ICommandPalette | null ,
59
+ labShell : ILabShell | null ,
60
+ consoleTracker : IConsoleTracker | null
56
61
) => {
57
62
const trans = translator . load ( 'jupyter-resource-usage' ) ;
58
63
@@ -62,10 +67,15 @@ const kernelUsagePlugin: JupyterFrontEndPlugin<void> = {
62
67
let panel : KernelUsagePanel | null = null ;
63
68
64
69
function createPanel ( ) {
65
- if ( ( ! panel || panel . isDisposed ) && notebookTracker ) {
70
+ if ( ! panel || panel . isDisposed ) {
71
+ const tracker = new KernelWidgetTracker ( {
72
+ notebookTracker,
73
+ labShell,
74
+ consoleTracker,
75
+ } ) ;
76
+
66
77
panel = new KernelUsagePanel ( {
67
- widgetAdded : notebookTracker . widgetAdded ,
68
- currentNotebookChanged : notebookTracker . currentChanged ,
78
+ currentChanged : tracker . currentChanged ,
69
79
trans : trans ,
70
80
} ) ;
71
81
shell . add ( panel , 'right' , { rank : 200 } ) ;
0 commit comments