66 'tree/js/notebooklist' ,
77] , function ( $ , Jupyter , dialog , utils , notebooklist ) {
88 "use strict" ;
9-
9+
1010 var TensorboardList = function ( selector , options ) {
1111 this . base_url = Jupyter . notebook_list . base_url ;
1212 this . init_elements ( ) ;
@@ -48,7 +48,7 @@ define([
4848 . attr ( 'type' , 'text/css' )
4949 . attr ( 'href' , static_url + 'style.css' )
5050 ) ;
51-
51+
5252 // tensorboad running list panel
5353 $ ( "#accordion" ) . append ( '<div class="panel panel-default">\
5454 <div class="panel-heading">\
@@ -66,31 +66,63 @@ define([
6666 </div>\
6767 </div>\
6868 </div>' ) ;
69-
69+
7070 // new tensorboard menu on current directory
71- $ ( "#new-menu" ) . append ( '<li role="presentation" id="new-tensorboard">\
72- <a role="menuitem" tabindex="-1" href="#">Tensorboard</a>\
71+ $ ( "#new-menu" ) . append ( '<li role="presentation" class="dropdown-submenu dropleft">\
72+ <a role="menuitem" tabindex="-1" href="#">Tensorboard...</a>\
73+ <ul class="dropdown-menu" style="right:100%;left:-100%">\
74+ <li id="new-tensorboard"><a>Current directory</a></li>\
75+ <li id="new-tensorboard-custom"><a>Custom directory...</a></li>\
76+ </ul>\
7377 </li>' ) ;
74-
78+
7579 // tensorboard button when select a directory
7680 $ ( ".dynamic-buttons:first" ) . append ( '<button id="#tensorboard-button"\
7781 title="Create Tensorboard Instance with selected logdir"\
7882 class="tensorboard-button btn btn-default btn-xs">Tensorboard</button>' ) ;
7983 } ;
80-
84+
8185 TensorboardList . prototype . bind_events = function ( ) {
8286 var that = this ;
87+
8388 $ ( '#refresh_running_list' ) . click ( function ( ) {
8489 that . load_tensorboards ( ) ;
8590 } ) ;
8691 $ ( '#new-tensorboard' ) . click ( $ . proxy ( function ( ) {
8792 that . new_tensorboard ( Jupyter . notebook_list . notebook_path ) ;
8893 } , this ) ) ;
94+ $ ( '#new-tensorboard-custom' ) . click ( function ( ) {
95+ that . dir_selection_dialog ( ) ;
96+ } ) ;
8997 $ ( ".tensorboard-button" ) . click ( $ . proxy ( function ( ) {
9098 that . new_tensorboard ( Jupyter . notebook_list . selected [ 0 ] . path ) ;
9199 } , this ) ) ;
92100 } ;
93101
102+ TensorboardList . prototype . dir_selection_dialog = function ( ) {
103+ var that = this ;
104+ dialog . modal ( {
105+ title : 'Specify a log directory' ,
106+ body : '<div class="form-group">\
107+ <input id="tensorboard-dir-input" class="form-control" type="text" placeholder="Type path to directory"/>\
108+ <small class="form-text text-muted">Specify a relative or absolute path</small>\
109+ </div>' ,
110+ sanitize : false ,
111+ buttons : {
112+ 'Cancel' : { 'class' : 'btn-secondary' } ,
113+ 'OK' : {
114+ 'class' : 'btn-primary' ,
115+ 'id' : 'new-tensorboard-custom-submit' ,
116+ 'click' : function ( ) {
117+ that . new_tensorboard ( $ ( '#tensorboard-dir-input' ) . val ( ) ) ;
118+ }
119+ }
120+ } ,
121+ notebook : Jupyter . notebook ,
122+ keyboard_manager : Jupyter . keyboard_manager
123+ } ) ;
124+ } ;
125+
94126 TensorboardList . prototype . new_tensorboard = function ( logdir ) {
95127 var that = this ;
96128 var settings = {
@@ -101,15 +133,15 @@ define([
101133 success : function ( data , status , xhr ) {
102134 that . load_tensorboards ( ) ;
103135 var name = data . name ;
104- var loc = utils . url_path_join ( that . base_url , 'tensorboard' ,
136+ var loc = utils . url_path_join ( that . base_url , 'tensorboard' ,
105137 utils . encode_uri_components ( name ) ) + "/" ;
106138 var win = window . open ( loc , 'tensorboard' + name ) ;
107139 } ,
108140 error : ajax_error ,
109141 } ;
110142 var url = utils . url_path_join ( this . base_url , 'api/tensorboard' ) ;
111143 utils . ajax ( url , settings ) ;
112-
144+
113145 var list_items = $ ( '.list_item' ) ;
114146 for ( var i = 0 ; i < list_items . length ; i ++ ) {
115147 var $list_item = $ ( list_items [ i ] ) ;
0 commit comments