@@ -131,8 +131,8 @@ const extension: JupyterFrontEndPlugin<IDashboardTracker> = {
131131 const model = widget . content . model ;
132132 // TODO: Make scrollMode changable in JL. Default 'infinite' for now.
133133 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 ;
136136 } ) ;
137137
138138 // Add commands to context menus.
@@ -442,8 +442,8 @@ function addCommands(
442442 label : 'Set Dashboard Dimensions' ,
443443 execute : async args => {
444444 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 ;
447447 await showDialog ( {
448448 title : 'Enter Dimensions' ,
449449 body : new Private . ResizeHandler ( width , height ) ,
@@ -458,14 +458,14 @@ function addCommands(
458458 }
459459 if ( ! newWidth ) {
460460 if ( ! model . width ) {
461- newWidth = Dashboard . DEFAULT_WIDTH ;
461+ newWidth = window . innerWidth ;
462462 } else {
463463 newWidth = model . width ;
464464 }
465465 }
466466 if ( ! newHeight ) {
467467 if ( ! model . height ) {
468- newHeight = Dashboard . DEFAULT_HEIGHT ;
468+ newHeight = window . innerHeight ;
469469 } else {
470470 newHeight = model . height ;
471471 }
@@ -543,9 +543,17 @@ function addCommands(
543543
544544 commands . addCommand ( CommandIDs . saveToMetadata , {
545545 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+
549557 }
550558 } ) ;
551559
@@ -588,7 +596,7 @@ function addCommands(
588596
589597 commands . addCommand ( CommandIDs . openFromMetadata , {
590598 label : 'Open Metadata Dashboard' ,
591- execute : args => {
599+ execute : async args => {
592600 const notebook = notebookTracker . currentWidget ;
593601 const notebookMetadata = getMetadata ( notebook ) ;
594602 if ( ! ( 'views' in notebookMetadata ) ) {
@@ -602,7 +610,20 @@ function addCommands(
602610 throw new Error ( `Dashboard id ${ dashboardId } doesn't exist in notebook ${ notebookId } ` ) ;
603611 }
604612 } 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+ }
606627 }
607628
608629 const dashboardView = notebookMetadata . views [ dashboardId ] ;
0 commit comments