@@ -131,8 +131,8 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
131
131
const model = widget . content . model ;
132
132
// TODO: Make scrollMode changable in JL. Default 'infinite' for now.
133
133
model . scrollMode = 'infinite' ;
134
- model . width = Dashboard . DEFAULT_WIDTH ;
135
- model . height = Dashboard . DEFAULT_HEIGHT ;
134
+ model . width = ( widget . content . layout as DashboardLayout ) . width ;
135
+ model . height = ( widget . content . layout as DashboardLayout ) . height ;
136
136
} ) ;
137
137
138
138
// Add commands to context menus.
@@ -442,8 +442,8 @@ function addCommands(
442
442
label : 'Set Dashboard Dimensions' ,
443
443
execute : async args => {
444
444
const model = dashboardTracker . currentWidget . model ;
445
- const width = model . width ? model . width : Dashboard . DEFAULT_WIDTH ;
446
- const height = model . height ? model . height : Dashboard . DEFAULT_HEIGHT ;
445
+ const width = model . width ? model . width : window . innerWidth ;
446
+ const height = model . height ? model . height : window . innerHeight ;
447
447
await showDialog ( {
448
448
title : 'Enter Dimensions' ,
449
449
body : new Private . ResizeHandler ( width , height ) ,
@@ -458,14 +458,14 @@ function addCommands(
458
458
}
459
459
if ( ! newWidth ) {
460
460
if ( ! model . width ) {
461
- newWidth = Dashboard . DEFAULT_WIDTH ;
461
+ newWidth = window . innerWidth ;
462
462
} else {
463
463
newWidth = model . width ;
464
464
}
465
465
}
466
466
if ( ! newHeight ) {
467
467
if ( ! model . height ) {
468
- newHeight = Dashboard . DEFAULT_HEIGHT ;
468
+ newHeight = window . innerHeight ;
469
469
} else {
470
470
newHeight = model . height ;
471
471
}
@@ -543,9 +543,17 @@ function addCommands(
543
543
544
544
commands . addCommand ( CommandIDs . saveToMetadata , {
545
545
label : 'Save Dashboard To Notebook Metadata' ,
546
- execute : args => {
547
- const dashboard = dashboardTracker . currentWidget ;
548
- dashboard . saveToNotebookMetadata ( ) ;
546
+ execute : async args => {
547
+
548
+ const name = await InputDialog . getText ( {
549
+ title : 'Dashboard name' ,
550
+ text : 'default'
551
+ } ) ;
552
+ if ( name . value ) {
553
+ const dashboard = dashboardTracker . currentWidget ;
554
+ dashboard . saveToNotebookMetadata ( name . value ) ;
555
+ }
556
+
549
557
}
550
558
} ) ;
551
559
@@ -588,7 +596,7 @@ function addCommands(
588
596
589
597
commands . addCommand ( CommandIDs . openFromMetadata , {
590
598
label : 'Open Metadata Dashboard' ,
591
- execute : args => {
599
+ execute : async args => {
592
600
const notebook = notebookTracker . currentWidget ;
593
601
const notebookMetadata = getMetadata ( notebook ) ;
594
602
if ( ! ( 'views' in notebookMetadata ) ) {
@@ -602,7 +610,20 @@ function addCommands(
602
610
throw new Error ( `Dashboard id ${ dashboardId } doesn't exist in notebook ${ notebookId } ` ) ;
603
611
}
604
612
} else {
605
- dashboardId = Object . keys ( notebookMetadata . views ) [ 0 ]
613
+ const dashboardIds = Object . keys ( notebookMetadata . views ) ;
614
+ const nameMap = new Map < string , string > (
615
+ dashboardIds . map ( id => [ notebookMetadata . views [ id ] . name , id ] )
616
+ ) ;
617
+ const dashboardName = await InputDialog . getItem ( {
618
+ title : 'Select a Dashboard' ,
619
+ current : 0 ,
620
+ items : Array . from ( nameMap . keys ( ) ) ,
621
+ } ) ;
622
+ if ( dashboardName . value ) {
623
+ dashboardId = nameMap . get ( dashboardName . value ) ;
624
+ } else {
625
+ return ;
626
+ }
606
627
}
607
628
608
629
const dashboardView = notebookMetadata . views [ dashboardId ] ;
0 commit comments