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 | * The function is called on kernel's idle status message.
|
93 | * It is used to keep track number of executed
|
94 | * cell or Comm custom messages and the status of kernel.
|
95 | *
|
96 | * @param nb - The notebook which contains the executed code
|
97 | * cell.
|
98 | * @param msg_id - The id of message.
|
99 | *
|
100 | * ### Note
|
101 | *
|
102 | * To keep track of cells executed under 1 second,
|
103 | * the execution state is marked as `needReset` 1 second after executing
|
104 | * these cells. This `Timeout` will be cleared if there is any cell
|
105 | * scheduled after that.
|
106 | */
|
107 | private _cellExecutedCallback;
|
108 | /**
|
109 | * This function is called on kernel's `execute_input` message to start
|
110 | * the elapsed time counter.
|
111 | *
|
112 | * @param nb - The notebook which contains the scheduled execution request.
|
113 | */
|
114 | private _startTimer;
|
115 | /**
|
116 | * The function is called on kernel's `execute_request` message or Comm message, it is
|
117 | * used to keep track number of scheduled cell or Comm execution message
|
118 | * and the status of kernel.
|
119 | *
|
120 | * @param nb - The notebook which contains the scheduled code.
|
121 | * cell
|
122 | * @param msg_id - The id of message.
|
123 | */
|
124 | private _cellScheduledCallback;
|
125 | /**
|
126 | * Increment the executed time of input execution state
|
127 | * and emit `stateChanged` signal to re-render the indicator.
|
128 | *
|
129 | * @param data - the state to be updated.
|
130 | */
|
131 | private _tick;
|
132 | /**
|
133 | * Reset the input execution state.
|
134 | *
|
135 | * @param data - the state to be rested.
|
136 | */
|
137 | private _resetTime;
|
138 | get renderFlag(): boolean;
|
139 | updateRenderOption(options: {
|
140 | showOnToolBar: boolean;
|
141 | showProgress: boolean;
|
142 | }): void;
|
143 | /**
|
144 | * The option to show the indicator on status bar or toolbar.
|
145 | */
|
146 | private _displayOption;
|
147 | /**
|
148 | * Current activated notebook.
|
149 | */
|
150 | private _currentNotebook;
|
151 | /**
|
152 | * A weak map to hold execution status of multiple notebooks.
|
153 | */
|
154 | private _notebookExecutionProgress;
|
155 | /**
|
156 | * A flag to show or hide the indicator.
|
157 | */
|
158 | private _renderFlag;
|
159 | }
|
160 | function createExecutionIndicatorItem(panel: NotebookPanel, translator: ITranslator, loadSettings: Promise<ISettingRegistry.ISettings> | undefined): Widget;
|
161 | function getSettingValue(settings: ISettingRegistry.ISettings): {
|
162 | showOnToolBar: boolean;
|
163 | showProgress: boolean;
|
164 | };
|
165 | }
|
166 |
|
167 |
|
168 |
|
169 | declare namespace Private {
|
170 | interface IExecutionState {
|
171 | |
172 |
|
173 |
|
174 |
|
175 | executionStatus: string;
|
176 | |
177 |
|
178 |
|
179 | kernelStatus: ISessionContext.KernelDisplayStatus;
|
180 | |
181 |
|
182 |
|
183 | totalTime: number;
|
184 | |
185 |
|
186 |
|
187 |
|
188 | interval: number;
|
189 | |
190 |
|
191 |
|
192 |
|
193 | timeout: number;
|
194 | |
195 |
|
196 |
|
197 |
|
198 | scheduledCell: Set<string>;
|
199 | |
200 |
|
201 |
|
202 |
|
203 | scheduledCellNumber: number;
|
204 | |
205 |
|
206 |
|
207 |
|
208 | needReset: boolean;
|
209 | }
|
210 | type DisplayOption = {
|
211 | |
212 |
|
213 |
|
214 | showOnToolBar: boolean;
|
215 | |
216 |
|
217 |
|
218 |
|
219 | showProgress: boolean;
|
220 | };
|
221 | }
|
222 | export {};
|