Show More
@@ -1,112 +1,113 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | define([ |
|
4 | define([ | |
5 | 'jquery', |
|
5 | 'jquery', | |
6 | 'base/js/namespace', |
|
6 | 'base/js/namespace', | |
7 | 'base/js/utils', |
|
7 | 'base/js/utils', | |
8 | 'base/js/dialog', |
|
8 | 'base/js/dialog', | |
9 | ], function ($, IPython, utils, dialog) { |
|
9 | ], function ($, IPython, utils, dialog) { | |
10 | "use strict"; |
|
10 | "use strict"; | |
11 |
|
11 | |||
12 | var NewNotebookWidget = function (selector, options) { |
|
12 | var NewNotebookWidget = function (selector, options) { | |
13 | this.selector = selector; |
|
13 | this.selector = selector; | |
14 | this.base_url = options.base_url; |
|
14 | this.base_url = options.base_url; | |
15 | this.notebook_path = options.notebook_path; |
|
15 | this.notebook_path = options.notebook_path; | |
16 | this.contents = options.contents; |
|
16 | this.contents = options.contents; | |
17 | this.current_selection = null; |
|
17 | this.current_selection = null; | |
18 | this.kernelspecs = {}; |
|
18 | this.kernelspecs = {}; | |
19 | if (this.selector !== undefined) { |
|
19 | if (this.selector !== undefined) { | |
20 | this.element = $(selector); |
|
20 | this.element = $(selector); | |
21 | this.request_kernelspecs(); |
|
21 | this.request_kernelspecs(); | |
22 | } |
|
22 | } | |
23 | this.bind_events(); |
|
23 | this.bind_events(); | |
24 | }; |
|
24 | }; | |
25 |
|
25 | |||
26 | NewNotebookWidget.prototype.bind_events = function () { |
|
26 | NewNotebookWidget.prototype.bind_events = function () { | |
27 | var that = this; |
|
27 | var that = this; | |
28 | this.element.find('#new_notebook').click(function () { |
|
28 | this.element.find('#new_notebook').click(function () { | |
29 | that.new_notebook(); |
|
29 | that.new_notebook(); | |
30 | }); |
|
30 | }); | |
31 | }; |
|
31 | }; | |
32 |
|
32 | |||
33 | NewNotebookWidget.prototype.request_kernelspecs = function () { |
|
33 | NewNotebookWidget.prototype.request_kernelspecs = function () { | |
34 | /** request and then load kernel specs */ |
|
34 | /** request and then load kernel specs */ | |
35 | var url = utils.url_join_encode(this.base_url, 'api/kernelspecs'); |
|
35 | var url = utils.url_join_encode(this.base_url, 'api/kernelspecs'); | |
36 | utils.promising_ajax(url).then($.proxy(this._load_kernelspecs, this)); |
|
36 | utils.promising_ajax(url).then($.proxy(this._load_kernelspecs, this)); | |
37 | }; |
|
37 | }; | |
38 |
|
38 | |||
39 | NewNotebookWidget.prototype._load_kernelspecs = function (data) { |
|
39 | NewNotebookWidget.prototype._load_kernelspecs = function (data) { | |
40 | /** load kernelspec list */ |
|
40 | /** load kernelspec list */ | |
41 | this.kernelspecs = {}; |
|
41 | this.kernelspecs = {}; | |
42 | var menu = this.element.find("#new-notebook-menu"); |
|
42 | var menu = this.element.find("#new-notebook-menu"); | |
43 | for (var i = 0; i < data.length; i++) { |
|
43 | for (var i = 0; i < data.length; i++) { | |
44 | var ks = data[i]; |
|
44 | var ks = data[i]; | |
45 | this.kernelspecs[ks.name] = ks; |
|
45 | this.kernelspecs[ks.name] = ks; | |
46 | var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>') |
|
46 | var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>') | |
47 | .attr('href', '#') |
|
47 | .attr('href', '#') | |
48 | .click($.proxy(this.new_with_kernel, this, ks.name)) |
|
48 | .click($.proxy(this.new_with_kernel, this, ks.name)) | |
49 | .text(ks.display_name) |
|
49 | .text(ks.display_name) | |
50 | .attr('title', 'Create a new notebook with ' + ks.display_name) |
|
50 | .attr('title', 'Create a new notebook with ' + ks.display_name) | |
51 | ); |
|
51 | ); | |
52 | menu.append(ksentry); |
|
52 | menu.append(ksentry); | |
53 | } |
|
53 | } | |
54 | this._load_default_kernelspec(); |
|
54 | this._load_default_kernelspec(); | |
55 | }; |
|
55 | }; | |
56 |
|
56 | |||
57 | NewNotebookWidget.prototype._load_default_kernelspec = function () { |
|
57 | NewNotebookWidget.prototype._load_default_kernelspec = function () { | |
58 | /** load default kernelspec name from localStorage, if defined */ |
|
58 | /** load default kernelspec name from localStorage, if defined */ | |
59 | this.select_kernel(localStorage.default_kernel_name); |
|
59 | this.select_kernel(localStorage.default_kernel_name); | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 | NewNotebookWidget.prototype.select_kernel = function (kernel_name) { |
|
62 | NewNotebookWidget.prototype.select_kernel = function (kernel_name) { | |
63 | /** select the current default kernel */ |
|
63 | /** select the current default kernel */ | |
64 | this.current_selection = kernel_name; |
|
64 | this.current_selection = kernel_name; | |
65 | var spec = this.kernelspecs[kernel_name]; |
|
65 | var spec = this.kernelspecs[kernel_name]; | |
66 | var display_name; |
|
66 | var display_name; | |
67 | if (spec) { |
|
67 | if (spec) { | |
68 | display_name = spec.display_name; |
|
68 | display_name = spec.display_name; | |
69 | localStorage.default_kernel_name = kernel_name; |
|
69 | localStorage.default_kernel_name = kernel_name; | |
|
70 | this.element.find("#current-kernel").text(display_name); | |||
70 | } else { |
|
71 | } else { | |
71 | display_name = 'default kernel'; |
|
72 | display_name = 'default kernel'; | |
72 | delete localStorage.default_kernel_name; |
|
73 | delete localStorage.default_kernel_name; | |
73 | } |
|
74 | } | |
74 | this.element.find("#new_notebook").attr('title', |
|
75 | this.element.find("#new_notebook").attr('title', | |
75 | 'Create a new notebook with ' + display_name |
|
76 | 'Create a new notebook with ' + display_name | |
76 | ); |
|
77 | ); | |
77 | }; |
|
78 | }; | |
78 |
|
79 | |||
79 | NewNotebookWidget.prototype.new_with_kernel = function (kernel_name) { |
|
80 | NewNotebookWidget.prototype.new_with_kernel = function (kernel_name) { | |
80 | /** record current selection and open a new notebook */ |
|
81 | /** record current selection and open a new notebook */ | |
81 | this.select_kernel(kernel_name); |
|
82 | this.select_kernel(kernel_name); | |
82 | this.new_notebook(kernel_name); |
|
83 | this.new_notebook(kernel_name); | |
83 | }; |
|
84 | }; | |
84 |
|
85 | |||
85 | NewNotebookWidget.prototype.new_notebook = function (kernel_name) { |
|
86 | NewNotebookWidget.prototype.new_notebook = function (kernel_name) { | |
86 | /** create and open a new notebook */ |
|
87 | /** create and open a new notebook */ | |
87 | var that = this; |
|
88 | var that = this; | |
88 | kernel_name = kernel_name || this.current_selection; |
|
89 | kernel_name = kernel_name || this.current_selection; | |
89 | var w = window.open(); |
|
90 | var w = window.open(); | |
90 | this.contents.new_untitled(that.notebook_path, {type: "notebook"}).then( |
|
91 | this.contents.new_untitled(that.notebook_path, {type: "notebook"}).then( | |
91 | function (data) { |
|
92 | function (data) { | |
92 | var url = utils.url_join_encode( |
|
93 | var url = utils.url_join_encode( | |
93 | that.base_url, 'notebooks', data.path |
|
94 | that.base_url, 'notebooks', data.path | |
94 | ); |
|
95 | ); | |
95 | if (kernel_name) { |
|
96 | if (kernel_name) { | |
96 | url += "?kernel_name=" + kernel_name; |
|
97 | url += "?kernel_name=" + kernel_name; | |
97 | } |
|
98 | } | |
98 | w.location = url; |
|
99 | w.location = url; | |
99 | }, |
|
100 | }, | |
100 | function (error) { |
|
101 | function (error) { | |
101 | w.close(); |
|
102 | w.close(); | |
102 | dialog.modal({ |
|
103 | dialog.modal({ | |
103 | title : 'Creating Notebook Failed', |
|
104 | title : 'Creating Notebook Failed', | |
104 | body : "The error was: " + error.message, |
|
105 | body : "The error was: " + error.message, | |
105 | buttons : {'OK' : {'class' : 'btn-primary'}} |
|
106 | buttons : {'OK' : {'class' : 'btn-primary'}} | |
106 | }); |
|
107 | }); | |
107 | } |
|
108 | } | |
108 | ); |
|
109 | ); | |
109 | }; |
|
110 | }; | |
110 |
|
111 | |||
111 | return {'NewNotebookWidget': NewNotebookWidget}; |
|
112 | return {'NewNotebookWidget': NewNotebookWidget}; | |
112 | }); |
|
113 | }); |
@@ -1,152 +1,153 b'' | |||||
1 | {% extends "page.html" %} |
|
1 | {% extends "page.html" %} | |
2 |
|
2 | |||
3 | {% block title %}{{page_title}}{% endblock %} |
|
3 | {% block title %}{{page_title}}{% endblock %} | |
4 |
|
4 | |||
5 |
|
5 | |||
6 | {% block stylesheet %} |
|
6 | {% block stylesheet %} | |
7 | {{super()}} |
|
7 | {{super()}} | |
8 | <link rel="stylesheet" href="{{ static_url("tree/css/override.css") }}" type="text/css" /> |
|
8 | <link rel="stylesheet" href="{{ static_url("tree/css/override.css") }}" type="text/css" /> | |
9 | {% endblock %} |
|
9 | {% endblock %} | |
10 |
|
10 | |||
11 | {% block params %} |
|
11 | {% block params %} | |
12 |
|
12 | |||
13 | data-base-url="{{base_url}}" |
|
13 | data-base-url="{{base_url}}" | |
14 | data-notebook-path="{{notebook_path}}" |
|
14 | data-notebook-path="{{notebook_path}}" | |
15 | data-terminals-available="{{terminals_available}}" |
|
15 | data-terminals-available="{{terminals_available}}" | |
16 |
|
16 | |||
17 | {% endblock %} |
|
17 | {% endblock %} | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | {% block site %} |
|
20 | {% block site %} | |
21 |
|
21 | |||
22 | <div id="ipython-main-app" class="container"> |
|
22 | <div id="ipython-main-app" class="container"> | |
23 |
|
23 | |||
24 | <div id="tab_content" class="tabbable"> |
|
24 | <div id="tab_content" class="tabbable"> | |
25 | <ul id="tabs" class="nav nav-tabs"> |
|
25 | <ul id="tabs" class="nav nav-tabs"> | |
26 | <li class="active"><a href="#notebooks" data-toggle="tab">Notebooks</a></li> |
|
26 | <li class="active"><a href="#notebooks" data-toggle="tab">Notebooks</a></li> | |
27 | <li><a href="#running" data-toggle="tab">Running</a></li> |
|
27 | <li><a href="#running" data-toggle="tab">Running</a></li> | |
28 | {% if terminals_available %} |
|
28 | {% if terminals_available %} | |
29 | <li><a href="#terminals" data-toggle="tab">Terminals</a></li> |
|
29 | <li><a href="#terminals" data-toggle="tab">Terminals</a></li> | |
30 | {% endif %} |
|
30 | {% endif %} | |
31 | <li><a href="#clusters" data-toggle="tab">Clusters</a></li> |
|
31 | <li><a href="#clusters" data-toggle="tab">Clusters</a></li> | |
32 | </ul> |
|
32 | </ul> | |
33 |
|
33 | |||
34 | <div class="tab-content"> |
|
34 | <div class="tab-content"> | |
35 | <div id="notebooks" class="tab-pane active"> |
|
35 | <div id="notebooks" class="tab-pane active"> | |
36 | <div id="notebook_toolbar" class="row"> |
|
36 | <div id="notebook_toolbar" class="row"> | |
37 | <div class="col-sm-8 no-padding"> |
|
37 | <div class="col-sm-8 no-padding"> | |
38 | <form id='alternate_upload' class='alternate_upload' > |
|
38 | <form id='alternate_upload' class='alternate_upload' > | |
39 | <span id="notebook_list_info" style="position:absolute" > |
|
39 | <span id="notebook_list_info" style="position:absolute" > | |
40 | To import a notebook, drag the file onto the listing below or <strong>click here</strong>. |
|
40 | To import a notebook, drag the file onto the listing below or <strong>click here</strong>. | |
41 | </span> |
|
41 | </span> | |
42 | <input type="file" name="datafile" class="fileinput" multiple='multiple'> |
|
42 | <input type="file" name="datafile" class="fileinput" multiple='multiple'> | |
43 | </form> |
|
43 | </form> | |
44 | </div> |
|
44 | </div> | |
45 | <div class="col-sm-4 no-padding tree-buttons"> |
|
45 | <div class="col-sm-4 no-padding tree-buttons"> | |
46 | <span id="notebook_buttons" class="pull-right"> |
|
46 | <span id="notebook_buttons" class="pull-right"> | |
47 | <div id="new-notebook-buttons" class="btn-group"> |
|
47 | <div id="new-notebook-buttons" class="btn-group"> | |
48 | <button id="new_notebook" class="btn btn-default btn-xs"> |
|
48 | <button id="new_notebook" class="btn btn-default btn-xs"> | |
49 | New Notebook |
|
49 | New Notebook | |
50 | </button> |
|
50 | </button> | |
51 | <button class="dropdown-toggle btn btn-default btn-xs" data-toggle="dropdown"> |
|
51 | <button class="dropdown-toggle btn btn-default btn-xs" data-toggle="dropdown"> | |
|
52 | <span id="current-kernel"></span> | |||
52 | <span class="caret"></span> |
|
53 | <span class="caret"></span> | |
53 | </button> |
|
54 | </button> | |
54 | <ul id="new-notebook-menu" class="dropdown-menu"></ul> |
|
55 | <ul id="new-notebook-menu" class="dropdown-menu"></ul> | |
55 | </div> |
|
56 | </div> | |
56 |
|
57 | |||
57 |
|
58 | |||
58 | <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> |
|
59 | <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> | |
59 | </span> |
|
60 | </span> | |
60 | </div> |
|
61 | </div> | |
61 | </div> |
|
62 | </div> | |
62 |
|
63 | |||
63 | <div id="notebook_list"> |
|
64 | <div id="notebook_list"> | |
64 | <div id="notebook_list_header" class="row list_header"> |
|
65 | <div id="notebook_list_header" class="row list_header"> | |
65 | <div id="project_name"> |
|
66 | <div id="project_name"> | |
66 | <ul class="breadcrumb"> |
|
67 | <ul class="breadcrumb"> | |
67 | <li><a href="{{breadcrumbs[0][0]}}"><i class="fa fa-home"></i></a></li> |
|
68 | <li><a href="{{breadcrumbs[0][0]}}"><i class="fa fa-home"></i></a></li> | |
68 | {% for crumb in breadcrumbs[1:] %} |
|
69 | {% for crumb in breadcrumbs[1:] %} | |
69 | <li><a href="{{crumb[0]}}">{{crumb[1]}}</a></li> |
|
70 | <li><a href="{{crumb[0]}}">{{crumb[1]}}</a></li> | |
70 | {% endfor %} |
|
71 | {% endfor %} | |
71 | </ul> |
|
72 | </ul> | |
72 | </div> |
|
73 | </div> | |
73 | </div> |
|
74 | </div> | |
74 | </div> |
|
75 | </div> | |
75 | </div> |
|
76 | </div> | |
76 |
|
77 | |||
77 | <div id="running" class="tab-pane"> |
|
78 | <div id="running" class="tab-pane"> | |
78 |
|
79 | |||
79 | <div id="running_toolbar" class="row"> |
|
80 | <div id="running_toolbar" class="row"> | |
80 | <div class="col-sm-8 no-padding"> |
|
81 | <div class="col-sm-8 no-padding"> | |
81 | <span id="running_list_info">Currently running IPython notebooks</span> |
|
82 | <span id="running_list_info">Currently running IPython notebooks</span> | |
82 | </div> |
|
83 | </div> | |
83 | <div class="col-sm-4 no-padding tree-buttons"> |
|
84 | <div class="col-sm-4 no-padding tree-buttons"> | |
84 | <span id="running_buttons" class="pull-right"> |
|
85 | <span id="running_buttons" class="pull-right"> | |
85 | <button id="refresh_running_list" title="Refresh running list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> |
|
86 | <button id="refresh_running_list" title="Refresh running list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> | |
86 | </span> |
|
87 | </span> | |
87 | </div> |
|
88 | </div> | |
88 | </div> |
|
89 | </div> | |
89 |
|
90 | |||
90 | <div id="running_list"> |
|
91 | <div id="running_list"> | |
91 | <div id="running_list_header" class="row list_header"> |
|
92 | <div id="running_list_header" class="row list_header"> | |
92 | <div> There are no notebooks running. </div> |
|
93 | <div> There are no notebooks running. </div> | |
93 | </div> |
|
94 | </div> | |
94 | </div> |
|
95 | </div> | |
95 | </div> |
|
96 | </div> | |
96 |
|
97 | |||
97 | {% if terminals_available %} |
|
98 | {% if terminals_available %} | |
98 | <div id="terminals" class="tab-pane"> |
|
99 | <div id="terminals" class="tab-pane"> | |
99 |
|
100 | |||
100 | <div id="terminal_toolbar" class="row"> |
|
101 | <div id="terminal_toolbar" class="row"> | |
101 | <div class="col-xs-8 no-padding"> |
|
102 | <div class="col-xs-8 no-padding"> | |
102 | <span id="terminal_list_info">Currently running terminals</span> |
|
103 | <span id="terminal_list_info">Currently running terminals</span> | |
103 | </div> |
|
104 | </div> | |
104 | <div class="col-xs-4 no-padding tree-buttons"> |
|
105 | <div class="col-xs-4 no-padding tree-buttons"> | |
105 | <span id="terminal_buttons" class="pull-right"> |
|
106 | <span id="terminal_buttons" class="pull-right"> | |
106 | <button id="new_terminal" title="New terminal" class="btn btn-default btn-xs">New Terminal</button> |
|
107 | <button id="new_terminal" title="New terminal" class="btn btn-default btn-xs">New Terminal</button> | |
107 | <button id="refresh_terminal_list" title="Refresh terminal list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> |
|
108 | <button id="refresh_terminal_list" title="Refresh terminal list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> | |
108 | </span> |
|
109 | </span> | |
109 | </div> |
|
110 | </div> | |
110 | </div> |
|
111 | </div> | |
111 |
|
112 | |||
112 | <div id="terminal_list"> |
|
113 | <div id="terminal_list"> | |
113 | <div id="terminal_list_header" class="row list_header"> |
|
114 | <div id="terminal_list_header" class="row list_header"> | |
114 | <div> There are no terminals running. </div> |
|
115 | <div> There are no terminals running. </div> | |
115 | </div> |
|
116 | </div> | |
116 | </div> |
|
117 | </div> | |
117 | </div> |
|
118 | </div> | |
118 | {% endif %} |
|
119 | {% endif %} | |
119 |
|
120 | |||
120 | <div id="clusters" class="tab-pane"> |
|
121 | <div id="clusters" class="tab-pane"> | |
121 |
|
122 | |||
122 | <div id="cluster_toolbar" class="row"> |
|
123 | <div id="cluster_toolbar" class="row"> | |
123 | <div class="col-xs-8 no-padding"> |
|
124 | <div class="col-xs-8 no-padding"> | |
124 | <span id="cluster_list_info">IPython parallel computing clusters</span> |
|
125 | <span id="cluster_list_info">IPython parallel computing clusters</span> | |
125 | </div> |
|
126 | </div> | |
126 | <div class="col-xs-4 no-padding tree-buttons"> |
|
127 | <div class="col-xs-4 no-padding tree-buttons"> | |
127 | <span id="cluster_buttons" class="pull-right"> |
|
128 | <span id="cluster_buttons" class="pull-right"> | |
128 | <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> |
|
129 | <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> | |
129 | </span> |
|
130 | </span> | |
130 | </div> |
|
131 | </div> | |
131 | </div> |
|
132 | </div> | |
132 |
|
133 | |||
133 | <div id="cluster_list"> |
|
134 | <div id="cluster_list"> | |
134 | <div id="cluster_list_header" class="row list_header"> |
|
135 | <div id="cluster_list_header" class="row list_header"> | |
135 | <div class="profile_col col-xs-4">profile</div> |
|
136 | <div class="profile_col col-xs-4">profile</div> | |
136 | <div class="status_col col-xs-3">status</div> |
|
137 | <div class="status_col col-xs-3">status</div> | |
137 | <div class="engines_col col-xs-3" title="Enter the number of engines to start or empty for default"># of engines</div> |
|
138 | <div class="engines_col col-xs-3" title="Enter the number of engines to start or empty for default"># of engines</div> | |
138 | <div class="action_col col-xs-2">action</div> |
|
139 | <div class="action_col col-xs-2">action</div> | |
139 | </div> |
|
140 | </div> | |
140 | </div> |
|
141 | </div> | |
141 | </div> |
|
142 | </div> | |
142 | </div> |
|
143 | </div> | |
143 |
|
144 | |||
144 | </div> |
|
145 | </div> | |
145 |
|
146 | |||
146 | {% endblock %} |
|
147 | {% endblock %} | |
147 |
|
148 | |||
148 | {% block script %} |
|
149 | {% block script %} | |
149 | {{super()}} |
|
150 | {{super()}} | |
150 |
|
151 | |||
151 | <script src="{{ static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script> |
|
152 | <script src="{{ static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script> | |
152 | {% endblock %} |
|
153 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now