1 | import { ISessionContext, VDomModel, VDomRenderer } from '@jupyterlab/apputils';
|
2 | import { ITranslator } from '@jupyterlab/translation';
|
3 | import React from 'react';
|
4 | import { Notebook } from './widget';
|
5 | import { NotebookPanel } from './panel';
|
6 | import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
7 | import { Widget } from '@lumino/widgets';
|
8 |
|
9 |
|
10 |
|
11 | export declare function ExecutionIndicatorComponent(props: ExecutionIndicatorComponent.IProps): React.ReactElement<ExecutionIndicatorComponent.IProps>;
|
12 |
|
13 |
|
14 |
|
15 | declare namespace ExecutionIndicatorComponent {
|
16 | |
17 |
|
18 |
|
19 | interface IProps {
|
20 | |
21 |
|
22 |
|
23 | displayOption: Private.DisplayOption;
|
24 | |
25 |
|
26 |
|
27 | state?: Private.IExecutionState;
|
28 | |
29 |
|
30 |
|
31 | translator?: ITranslator;
|
32 | }
|
33 | }
|
34 |
|
35 |
|
36 |
|
37 | export declare class ExecutionIndicator extends VDomRenderer<ExecutionIndicator.Model> {
|
38 | |
39 |
|
40 |
|
41 | constructor(translator?: ITranslator, showProgress?: boolean);
|
42 | /**
|
43 | * Render the execution status item.
|
44 | */
|
45 | render(): JSX.Element | null;
|
46 | private translator;
|
47 | }
|
48 | /**
|
49 | * A namespace for ExecutionIndicator statics.
|
50 | */
|
51 | export declare namespace ExecutionIndicator {
|
52 | |
53 |
|
54 |
|
55 | class Model extends VDomModel {
|
56 | constructor();
|
57 | /**
|
58 | * Attach a notebook with session context to model in order to keep
|
59 | * track of multiple notebooks. If a session context is already
|
60 | * attached, only set current activated notebook to input.
|
61 | *
|
62 | * @param data - The notebook and session context to be attached to model
|
63 | */
|
64 | attachNotebook(data: {
|
65 | content?: Notebook;
|
66 | context?: ISessionContext;
|
67 | } | null): void;
|
68 | /**
|
69 | * The current activated notebook in model.
|
70 | */
|
71 | get currentNotebook(): Notebook | null;
|
72 | /**
|
73 | * The display options for progress bar and elapsed time.
|
74 | */
|
75 | get displayOption(): Private.DisplayOption;
|
76 | /**
|
77 | * Set the display options for progress bar and elapsed time.
|
78 | *
|
79 | * @param options - Options to be used
|
80 | */
|
81 | set displayOption(options: Private.DisplayOption);
|
82 | /**
|
83 | * Get the execution state associated with a notebook.
|
84 | *
|
85 | * @param nb - The notebook used to identify execution
|
86 | * state.
|
87 | *
|
88 | * @return - The associated execution state.
|
89 | */
|
90 | executionState(nb: Notebook): Private.IExecutionState | undefined;
|
91 | /**
|
92 | * Schedule switch to idle status and clearing of the timer.
|
93 | *
|
94 | * ### Note
|
95 | *
|
96 | * To keep track of cells executed under 1 second,
|
97 | * the execution state is marked as `needReset` 1 second after executing
|
98 | * these cells. This `Timeout` will be cleared if there is any cell
|
99 | * scheduled after that.
|
100 | */
|
101 | private _scheduleSwitchToIdle;
|
102 | /**
|
103 | * The function is called on kernel's idle status message.
|
104 | * It is used to keep track of number of executed
|
105 | * cells or Comm custom messages and the status of kernel.
|
106 | *
|
107 | * @param nb - The notebook which contains the executed code cell.
|
108 | * @param msg_id - The id of message.
|
109 | */
|
110 | private _cellExecutedCallback;
|
111 | /**
|
112 | * The function is called on kernel's restarting status message.
|
113 | * It is used to clear the state tracking the number of executed
|
114 | * cells.
|
115 | *
|
116 | * @param nb - The notebook which contains the executed code cell.
|
117 | */
|
118 | private _restartHandler;
|
119 | /**
|
120 | * This function is called on kernel's `execute_input` message to start
|
121 | * the elapsed time counter.
|
122 | *
|
123 | * @param nb - The notebook which contains the scheduled execution request.
|
124 | */
|
125 | private _startTimer;
|
126 | /**
|
127 | * The function is called on kernel's `execute_request` message or Comm message, it is
|
128 | * used to keep track number of scheduled cell or Comm execution message
|
129 | * and the status of kernel.
|
130 | *
|
131 | * @param nb - The notebook which contains the scheduled code.
|
132 | * cell
|
133 | * @param msg_id - The id of message.
|
134 | */
|
135 | private _cellScheduledCallback;
|
136 | /**
|
137 | * Increment the executed time of input execution state
|
138 | * and emit `stateChanged` signal to re-render the indicator.
|
139 | *
|
140 | * @param data - the state to be updated.
|
141 | */
|
142 | private _tick;
|
143 | /**
|
144 | * Reset the input execution state.
|
145 | *
|
146 | * @param data - the state to be rested.
|
147 | */
|
148 | private _resetTime;
|
149 | get renderFlag(): boolean;
|
150 | updateRenderOption(options: {
|
151 | showOnToolBar: boolean;
|
152 | showProgress: boolean;
|
153 | }): void;
|
154 | /**
|
155 | * The option to show the indicator on status bar or toolbar.
|
156 | */
|
157 | private _displayOption;
|
158 | /**
|
159 | * Current activated notebook.
|
160 | */
|
161 | private _currentNotebook;
|
162 | /**
|
163 | * A weak map to hold execution status of multiple notebooks.
|
164 | */
|
165 | private _notebookExecutionProgress;
|
166 | /**
|
167 | * A flag to show or hide the indicator.
|
168 | */
|
169 | private _renderFlag;
|
170 | }
|
171 | function createExecutionIndicatorItem(panel: NotebookPanel, translator: ITranslator, loadSettings: Promise<ISettingRegistry.ISettings> | undefined): Widget;
|
172 | function getSettingValue(settings: ISettingRegistry.ISettings): {
|
173 | showOnToolBar: boolean;
|
174 | showProgress: boolean;
|
175 | };
|
176 | }
|
177 |
|
178 |
|
179 |
|
180 | declare namespace Private {
|
181 | interface IExecutionState {
|
182 | |
183 |
|
184 |
|
185 |
|
186 | executionStatus: string;
|
187 | |
188 |
|
189 |
|
190 | kernelStatus: ISessionContext.KernelDisplayStatus;
|
191 | |
192 |
|
193 |
|
194 | totalTime: number;
|
195 | |
196 |
|
197 |
|
198 |
|
199 | interval: number;
|
200 | |
201 |
|
202 |
|
203 |
|
204 | timeout: number;
|
205 | |
206 |
|
207 |
|
208 |
|
209 | scheduledCell: Set<string>;
|
210 | |
211 |
|
212 |
|
213 |
|
214 | scheduledCellNumber: number;
|
215 | |
216 |
|
217 |
|
218 |
|
219 | needReset: boolean;
|
220 | }
|
221 | type DisplayOption = {
|
222 | |
223 |
|
224 |
|
225 | showOnToolBar: boolean;
|
226 | |
227 |
|
228 |
|
229 |
|
230 | showProgress: boolean;
|
231 | };
|
232 | }
|
233 | export {};
|