@@ -32,9 +32,10 @@ export namespace CommandIDs {
32
32
export const deleteJob = 'scheduling:delete-job' ;
33
33
export const createJobFileBrowser = 'scheduling:create-from-filebrowser' ;
34
34
export const createJobCurrentNotebook = 'scheduling:create-from-notebook' ;
35
- export const showNotebookJobs = 'scheduling:show-notebook-jobs ' ;
35
+ export const restoreLayout = 'scheduling:restore-layout ' ;
36
36
export const stopJob = 'scheduling:stop-job' ;
37
37
export const downloadFiles = 'scheduling:download-files' ;
38
+ export const listJobsFromLauncher = 'scheduling:list-jobs-from-launcher' ;
38
39
}
39
40
40
41
export const NotebookJobsPanelId = 'notebook-jobs-panel' ;
@@ -68,19 +69,14 @@ const advancedOptions: JupyterFrontEndPlugin<Scheduler.IAdvancedOptions> = {
68
69
}
69
70
} ;
70
71
71
- // Default Telemetry Handler
72
- const telemetryHandler = async (
73
- eventLog : Scheduler . IEventLog
74
- ) : Promise < void > => {
75
- console . log ( JSON . stringify ( eventLog , undefined , 4 ) ) ;
76
- } ;
77
-
78
72
const telemetry : JupyterFrontEndPlugin < Scheduler . TelemetryHandler > = {
79
73
id : '@jupyterlab/scheduler:TelemetryHandler' ,
80
74
autoStart : true ,
81
75
provides : Scheduler . TelemetryHandler ,
82
76
activate : ( app : JupyterFrontEnd ) => {
83
- return telemetryHandler ;
77
+ return async ( e : Scheduler . IEventLog ) => {
78
+ /*noop*/
79
+ } ;
84
80
}
85
81
} ;
86
82
@@ -174,21 +170,34 @@ async function activatePlugin(
174
170
namespace : 'jupyterlab-scheduler'
175
171
} ) ;
176
172
restorer . restore ( widgetTracker , {
177
- command : CommandIDs . showNotebookJobs ,
173
+ command : CommandIDs . restoreLayout ,
178
174
args : widget => widget . content . model . toJson ( ) ,
179
175
name : ( ) => 'jupyterlab-scheduler'
180
176
} ) ;
181
177
182
178
let mainAreaWidget : MainAreaWidget < NotebookJobsPanel > | undefined ;
183
179
let jobsPanel : NotebookJobsPanel | undefined ;
184
180
181
+ const eventLogger : Scheduler . EventLogger = eventName => {
182
+ if ( ! eventName ) {
183
+ return ;
184
+ }
185
+ const eventLog = {
186
+ body : {
187
+ name : `org.jupyter.jupyter-scheduler.${ eventName } `
188
+ } ,
189
+ timestamp : new Date ( )
190
+ } ;
191
+ telemetryHandler ( eventLog ) . then ( ) ;
192
+ } ;
193
+
185
194
const showJobsPanel = async ( data : IJobsModel ) => {
186
195
if ( ! mainAreaWidget || mainAreaWidget . isDisposed ) {
187
196
// Create new jobs panel widget
188
197
jobsPanel = new NotebookJobsPanel ( {
189
198
app,
190
199
translator,
191
- telemetryHandler ,
200
+ eventLogger ,
192
201
advancedOptions : advancedOptions
193
202
} ) ;
194
203
// Create new main area widget
@@ -222,14 +231,15 @@ async function activatePlugin(
222
231
223
232
// Commands
224
233
225
- commands . addCommand ( CommandIDs . showNotebookJobs , {
226
- execute : async args => showJobsPanel ( args as IJobsModel ) ,
227
- label : trans . __ ( 'Notebook Jobs' ) ,
228
- icon : eventNoteIcon
234
+ commands . addCommand ( CommandIDs . restoreLayout , {
235
+ execute : async args => {
236
+ showJobsPanel ( args as IJobsModel ) ;
237
+ }
229
238
} ) ;
230
239
231
240
commands . addCommand ( CommandIDs . createJobFileBrowser , {
232
241
execute : async ( ) => {
242
+ eventLogger ( 'file-browser.create-job' ) ;
233
243
const widget = fileBrowserTracker . currentWidget ;
234
244
const filePath = getSelectedFilePath ( widget ) ?? '' ;
235
245
@@ -252,6 +262,7 @@ async function activatePlugin(
252
262
253
263
commands . addCommand ( CommandIDs . createJobCurrentNotebook , {
254
264
execute : async ( ) => {
265
+ eventLogger ( 'notebook-header.create-job' ) ;
255
266
// Get the current notebook's name and path
256
267
const contentsModel =
257
268
notebookTracker . currentWidget ?. context ?. contentsModel ;
@@ -301,8 +312,22 @@ async function activatePlugin(
301
312
302
313
// Add to launcher
303
314
if ( launcher ) {
315
+ commands . addCommand ( CommandIDs . listJobsFromLauncher , {
316
+ execute : async ( ) => {
317
+ eventLogger ( 'launcher.show-jobs' ) ;
318
+ showJobsPanel ( {
319
+ jobsView : JobsView . ListJobs
320
+ } ) ;
321
+ } ,
322
+ label : trans . __ ( 'Notebook Jobs' ) ,
323
+ icon : eventNoteIcon
324
+ } ) ;
325
+
304
326
launcher . add ( {
305
- command : CommandIDs . showNotebookJobs
327
+ command : CommandIDs . listJobsFromLauncher ,
328
+ args : {
329
+ launcher : true
330
+ }
306
331
} ) ;
307
332
}
308
333
}
0 commit comments