Show More
@@ -1,198 +1,198 b'' | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 | 2 | // Copyright (C) 2011 The IPython Development Team |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
|
6 | 6 | //---------------------------------------------------------------------------- |
|
7 | 7 | |
|
8 | 8 | //============================================================================ |
|
9 | 9 | // NotebookList |
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | 12 | var IPython = (function (IPython) { |
|
13 | 13 | "use strict"; |
|
14 | 14 | |
|
15 | 15 | var utils = IPython.utils; |
|
16 | 16 | |
|
17 | 17 | var ClusterList = function (selector, options) { |
|
18 | 18 | this.selector = selector; |
|
19 | 19 | if (this.selector !== undefined) { |
|
20 | 20 | this.element = $(selector); |
|
21 | 21 | this.style(); |
|
22 | 22 | this.bind_events(); |
|
23 | 23 | } |
|
24 | 24 | options = options || {}; |
|
25 | 25 | this.options = options; |
|
26 | 26 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); |
|
27 | 27 | this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath"); |
|
28 | 28 | }; |
|
29 | 29 | |
|
30 | 30 | ClusterList.prototype.style = function () { |
|
31 | 31 | $('#cluster_list').addClass('list_container'); |
|
32 | 32 | $('#cluster_toolbar').addClass('list_toolbar'); |
|
33 | 33 | $('#cluster_list_info').addClass('toolbar_info'); |
|
34 | 34 | $('#cluster_buttons').addClass('toolbar_buttons'); |
|
35 | 35 | }; |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | ClusterList.prototype.bind_events = function () { |
|
39 | 39 | var that = this; |
|
40 | 40 | $('#refresh_cluster_list').click(function () { |
|
41 | 41 | that.load_list(); |
|
42 | 42 | }); |
|
43 | 43 | }; |
|
44 | 44 | |
|
45 | 45 | |
|
46 | 46 | ClusterList.prototype.load_list = function () { |
|
47 | 47 | var settings = { |
|
48 | 48 | processData : false, |
|
49 | 49 | cache : false, |
|
50 | 50 | type : "GET", |
|
51 | 51 | dataType : "json", |
|
52 | 52 | success : $.proxy(this.load_list_success, this), |
|
53 | 53 | error : utils.log_ajax_error, |
|
54 | 54 | }; |
|
55 | 55 | var url = utils.url_join_encode(this.base_url, 'clusters'); |
|
56 | 56 | $.ajax(url, settings); |
|
57 | 57 | }; |
|
58 | 58 | |
|
59 | 59 | |
|
60 | 60 | ClusterList.prototype.clear_list = function () { |
|
61 | 61 | this.element.children('.list_item').remove(); |
|
62 | 62 | }; |
|
63 | 63 | |
|
64 | 64 | ClusterList.prototype.load_list_success = function (data, status, xhr) { |
|
65 | 65 | this.clear_list(); |
|
66 | 66 | var len = data.length; |
|
67 | 67 | for (var i=0; i<len; i++) { |
|
68 | 68 | var element = $('<div/>'); |
|
69 | 69 | var item = new ClusterItem(element, this.options); |
|
70 | 70 | item.update_state(data[i]); |
|
71 | 71 | element.data('item', item); |
|
72 | 72 | this.element.append(element); |
|
73 | 73 | } |
|
74 | 74 | }; |
|
75 | 75 | |
|
76 | 76 | |
|
77 | 77 | var ClusterItem = function (element, options) { |
|
78 | 78 | this.element = $(element); |
|
79 | 79 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); |
|
80 | 80 | this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath"); |
|
81 | 81 | this.data = null; |
|
82 | 82 | this.style(); |
|
83 | 83 | }; |
|
84 | 84 | |
|
85 | 85 | ClusterItem.prototype.style = function () { |
|
86 | 86 | this.element.addClass('list_item').addClass("row"); |
|
87 | 87 | }; |
|
88 | 88 | |
|
89 | 89 | ClusterItem.prototype.update_state = function (data) { |
|
90 | 90 | this.data = data; |
|
91 | 91 | if (data.status === 'running') { |
|
92 | 92 | this.state_running(); |
|
93 | 93 | } else if (data.status === 'stopped') { |
|
94 | 94 | this.state_stopped(); |
|
95 | 95 | } |
|
96 | 96 | }; |
|
97 | 97 | |
|
98 | 98 | |
|
99 | 99 | ClusterItem.prototype.state_stopped = function () { |
|
100 | 100 | var that = this; |
|
101 | 101 | var profile_col = $('<div/>').addClass('profile_col col-md-4').text(this.data.profile); |
|
102 | 102 | var status_col = $('<div/>').addClass('status_col col-md-3').text('stopped'); |
|
103 | 103 | var engines_col = $('<div/>').addClass('engine_col col-md-3'); |
|
104 | 104 | var input = $('<input/>').attr('type','number') |
|
105 | 105 | .attr('min',1) |
|
106 | 106 | .attr('size',3) |
|
107 | .addClass('engine_num_input'); | |
|
107 | .addClass('engine_num_input form-control'); | |
|
108 | 108 | engines_col.append(input); |
|
109 | 109 | var start_button = $('<button/>').addClass("btn btn-default btn-xs").text("Start"); |
|
110 | 110 | var action_col = $('<div/>').addClass('action_col col-md-2').append( |
|
111 | 111 | $("<span/>").addClass("item_buttons btn-group").append( |
|
112 | 112 | start_button |
|
113 | 113 | ) |
|
114 | 114 | ); |
|
115 | 115 | this.element.empty() |
|
116 | 116 | .append(profile_col) |
|
117 | 117 | .append(status_col) |
|
118 | 118 | .append(engines_col) |
|
119 | 119 | .append(action_col); |
|
120 | 120 | start_button.click(function (e) { |
|
121 | 121 | var n = that.element.find('.engine_num_input').val(); |
|
122 | 122 | if (!/^\d+$/.test(n) && n.length>0) { |
|
123 | 123 | status_col.text('invalid engine #'); |
|
124 | 124 | } else { |
|
125 | 125 | var settings = { |
|
126 | 126 | cache : false, |
|
127 | 127 | data : {n:n}, |
|
128 | 128 | type : "POST", |
|
129 | 129 | dataType : "json", |
|
130 | 130 | success : function (data, status, xhr) { |
|
131 | 131 | that.update_state(data); |
|
132 | 132 | }, |
|
133 | 133 | error : function (xhr, status, error) { |
|
134 | 134 | status_col.text("error starting cluster"); |
|
135 | 135 | utils.log_ajax_error(xhr, status, error); |
|
136 | 136 | } |
|
137 | 137 | }; |
|
138 | 138 | status_col.text('starting'); |
|
139 | 139 | var url = utils.url_join_encode( |
|
140 | 140 | that.base_url, |
|
141 | 141 | 'clusters', |
|
142 | 142 | that.data.profile, |
|
143 | 143 | 'start' |
|
144 | 144 | ); |
|
145 | 145 | $.ajax(url, settings); |
|
146 | 146 | } |
|
147 | 147 | }); |
|
148 | 148 | }; |
|
149 | 149 | |
|
150 | 150 | |
|
151 | 151 | ClusterItem.prototype.state_running = function () { |
|
152 | 152 | var that = this; |
|
153 | 153 | var profile_col = $('<div/>').addClass('profile_col col-md-4').text(this.data.profile); |
|
154 | 154 | var status_col = $('<div/>').addClass('status_col col-md-3').text('running'); |
|
155 | 155 | var engines_col = $('<div/>').addClass('engines_col col-md-3').text(this.data.n); |
|
156 | 156 | var stop_button = $('<button/>').addClass("btn btn-default btn-xs").text("Stop"); |
|
157 | 157 | var action_col = $('<div/>').addClass('action_col col-md-2').append( |
|
158 | 158 | $("<span/>").addClass("item_buttons btn-group").append( |
|
159 | 159 | stop_button |
|
160 | 160 | ) |
|
161 | 161 | ); |
|
162 | 162 | this.element.empty() |
|
163 | 163 | .append(profile_col) |
|
164 | 164 | .append(status_col) |
|
165 | 165 | .append(engines_col) |
|
166 | 166 | .append(action_col); |
|
167 | 167 | stop_button.click(function (e) { |
|
168 | 168 | var settings = { |
|
169 | 169 | cache : false, |
|
170 | 170 | type : "POST", |
|
171 | 171 | dataType : "json", |
|
172 | 172 | success : function (data, status, xhr) { |
|
173 | 173 | that.update_state(data); |
|
174 | 174 | }, |
|
175 | 175 | error : function (xhr, status, error) { |
|
176 | 176 | utils.log_ajax_error(xhr, status, error), |
|
177 | 177 | status_col.text("error stopping cluster"); |
|
178 | 178 | } |
|
179 | 179 | }; |
|
180 | 180 | status_col.text('stopping'); |
|
181 | 181 | var url = utils.url_join_encode( |
|
182 | 182 | that.base_url, |
|
183 | 183 | 'clusters', |
|
184 | 184 | that.data.profile, |
|
185 | 185 | 'stop' |
|
186 | 186 | ); |
|
187 | 187 | $.ajax(url, settings); |
|
188 | 188 | }); |
|
189 | 189 | }; |
|
190 | 190 | |
|
191 | 191 | |
|
192 | 192 | IPython.ClusterList = ClusterList; |
|
193 | 193 | IPython.ClusterItem = ClusterItem; |
|
194 | 194 | |
|
195 | 195 | return IPython; |
|
196 | 196 | |
|
197 | 197 | }(IPython)); |
|
198 | 198 |
@@ -1,141 +1,140 b'' | |||
|
1 | 1 | |
|
2 | 2 | /** |
|
3 | 3 | * Primary styles |
|
4 | 4 | * |
|
5 | 5 | * Author: IPython Development Team |
|
6 | 6 | */ |
|
7 | 7 | |
|
8 | 8 | @dashboard_tb_pad: 4px; |
|
9 | 9 | @dashboard_lr_pad: 7px; |
|
10 | 10 | // These are the total heights of the Bootstrap small and mini buttons. These values |
|
11 | 11 | // are not less variables so we have to track them statically. |
|
12 | 12 | @btn_small_height: 26px; |
|
13 | 13 | @btn_mini_height: 22px; |
|
14 | 14 | @dark_dashboard_color: darken(@border_color, 30%); |
|
15 | 15 | |
|
16 | 16 | ul#tabs { |
|
17 | 17 | margin-bottom: @dashboard_tb_pad; |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | 20 | ul#tabs a { |
|
21 | 21 | padding-top: @dashboard_tb_pad; |
|
22 | 22 | padding-bottom: @dashboard_tb_pad; |
|
23 | 23 | } |
|
24 | 24 | |
|
25 | 25 | ul.breadcrumb { |
|
26 | 26 | a:focus, a:hover { |
|
27 | 27 | text-decoration: none; |
|
28 | 28 | } |
|
29 | 29 | i.icon-home { |
|
30 | 30 | font-size: 16px; |
|
31 | 31 | margin-right: 4px; |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | 34 | span { |
|
35 | 35 | color: @dark_dashboard_color; |
|
36 | 36 | } |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | .list_toolbar { |
|
40 | 40 | padding: @dashboard_tb_pad 0 @dashboard_tb_pad 0; |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | .list_toolbar [class*="span"] { |
|
44 | 44 | min-height: @btn_small_height; |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | .list_header { |
|
48 | 48 | font-weight: bold; |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | .list_container { |
|
52 | 52 | margin-top: @dashboard_tb_pad; |
|
53 | 53 | margin-bottom: 5*@dashboard_tb_pad; |
|
54 | 54 | border: 1px solid @border_color; |
|
55 | 55 | border-radius: 4px; |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | .list_container > div { |
|
59 | 59 | border-bottom: 1px solid @border_color; |
|
60 | 60 | &:hover .list-item{ |
|
61 | 61 | background-color: red; |
|
62 | 62 | }; |
|
63 | 63 | } |
|
64 | 64 | |
|
65 | 65 | .list_container > div:last-child { |
|
66 | 66 | border: none; |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | .list_item { |
|
70 | 70 | &:hover .list_item { |
|
71 | 71 | background-color: #ddd; |
|
72 | 72 | }; |
|
73 | 73 | a {text-decoration: none;} |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | .list_header>div, .list_item>div { |
|
77 | 77 | padding-top: @dashboard_tb_pad; |
|
78 | 78 | padding-bottom: @dashboard_tb_pad; |
|
79 | 79 | padding-left: @dashboard_lr_pad; |
|
80 | 80 | padding-right: @dashboard_lr_pad; |
|
81 | height: @btn_mini_height; | |
|
82 | 81 | line-height: @btn_mini_height; |
|
83 | 82 | } |
|
84 | 83 | |
|
85 | 84 | .item_name { |
|
86 | 85 | line-height: @btn_mini_height; |
|
87 | 86 | height: @btn_small_height; |
|
88 | 87 | } |
|
89 | 88 | |
|
90 | 89 | .item_icon { |
|
91 | 90 | font-size: 14px; |
|
92 | 91 | color: @dark_dashboard_color; |
|
93 | 92 | margin-right: @dashboard_lr_pad; |
|
94 | 93 | } |
|
95 | 94 | |
|
96 | 95 | .item_buttons { |
|
97 | 96 | line-height: 1em; |
|
98 | 97 | } |
|
99 | 98 | |
|
100 | 99 | .toolbar_info { |
|
101 | 100 | height: @btn_small_height; |
|
102 | 101 | line-height: @btn_small_height; |
|
103 | 102 | } |
|
104 | 103 | |
|
105 | 104 | input.nbname_input, input.engine_num_input { |
|
106 | 105 | // These settings give these inputs a height that matches @btn_mini_height = 22 |
|
107 | 106 | padding-top: 3px; |
|
108 | 107 | padding-bottom: 3px; |
|
109 | height: 14px; | |
|
108 | height: @btn_mini_height; | |
|
110 | 109 | line-height: 14px; |
|
111 | 110 | margin: 0px; |
|
112 | 111 | } |
|
113 | 112 | |
|
114 | 113 | input.engine_num_input { |
|
115 | 114 | width: 60px; |
|
116 | 115 | } |
|
117 | 116 | |
|
118 | 117 | .highlight_text { |
|
119 | 118 | color: blue; |
|
120 | 119 | } |
|
121 | 120 | |
|
122 | 121 | #project_name > .breadcrumb { |
|
123 | 122 | padding: 0px; |
|
124 | 123 | margin-bottom: 0px; |
|
125 | 124 | background-color: transparent; |
|
126 | 125 | font-weight: bold; |
|
127 | 126 | |
|
128 | 127 | } |
|
129 | 128 | |
|
130 | 129 | .tab-content .row { |
|
131 | 130 | margin-left: 0px; |
|
132 | 131 | margin-right: 0px; |
|
133 | 132 | } |
|
134 | 133 | |
|
135 | 134 | .folder_icon:before { |
|
136 | 135 | .icon(@folder-close-alt) |
|
137 | 136 | } |
|
138 | 137 | |
|
139 | 138 | .notebook_icon:before { |
|
140 | 139 | .icon(@book) |
|
141 | 140 | } |
@@ -1,121 +1,121 b'' | |||
|
1 | 1 | {% extends "page.html" %} |
|
2 | 2 | |
|
3 | 3 | {% block title %}{{page_title}}{% endblock %} |
|
4 | 4 | |
|
5 | 5 | |
|
6 | 6 | {% block stylesheet %} |
|
7 | 7 | {{super()}} |
|
8 | 8 | <link rel="stylesheet" href="{{ static_url("tree/css/override.css") }}" type="text/css" /> |
|
9 | 9 | {% endblock %} |
|
10 | 10 | |
|
11 | 11 | {% block params %} |
|
12 | 12 | |
|
13 | 13 | data-project="{{project}}" |
|
14 | 14 | data-base-url="{{base_url}}" |
|
15 | 15 | data-notebook-path="{{notebook_path}}" |
|
16 | 16 | |
|
17 | 17 | {% endblock %} |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | {% block site %} |
|
21 | 21 | |
|
22 | 22 | <div id="ipython-main-app" class="container"> |
|
23 | 23 | |
|
24 | 24 | <div id="tab_content" class="tabbable"> |
|
25 | 25 | <ul id="tabs" class="nav nav-tabs"> |
|
26 | 26 | <li class="active"><a href="#notebooks" data-toggle="tab">Notebooks</a></li> |
|
27 | 27 | <li><a href="#running" data-toggle="tab">Running</a></li> |
|
28 | 28 | <li><a href="#clusters" data-toggle="tab">Clusters</a></li> |
|
29 | 29 | </ul> |
|
30 | 30 | |
|
31 | 31 | <div class="tab-content"> |
|
32 | 32 | <div id="notebooks" class="tab-pane active"> |
|
33 | 33 | <div id="notebook_toolbar" class="row"> |
|
34 | 34 | <div class="span8"> |
|
35 | 35 | <form id='alternate_upload' class='alternate_upload' > |
|
36 | 36 | <span id="notebook_list_info" style="position:absolute" > |
|
37 | 37 | To import a notebook, drag the file onto the listing below or <strong>click here</strong>. |
|
38 | 38 | </span> |
|
39 | 39 | <input type="file" name="datafile" class="fileinput" multiple='multiple'> |
|
40 | 40 | </form> |
|
41 | 41 | </div> |
|
42 | 42 | <div class="span4 clearfix"> |
|
43 | 43 | <span id="notebook_buttons" class="pull-right"> |
|
44 | 44 | <button id="new_notebook" title="Create new notebook" class="btn btn-default btn-sm">New Notebook</button> |
|
45 | 45 | <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-default btn-sm"><i class="icon-refresh"></i></button> |
|
46 | 46 | </span> |
|
47 | 47 | </div> |
|
48 | 48 | </div> |
|
49 | 49 | |
|
50 | 50 | <div id="notebook_list"> |
|
51 | 51 | <div id="notebook_list_header" class="row list_header"> |
|
52 | 52 | <div id="project_name"> |
|
53 | 53 | <ul class="breadcrumb"> |
|
54 | 54 | <li><a href="{{breadcrumbs[0][0]}}"><i class="icon-home"></i></a><span>/</span></li> |
|
55 | 55 | {% for crumb in breadcrumbs[1:] %} |
|
56 | 56 | <li><a href="{{crumb[0]}}">{{crumb[1]}}</a> <span>/</span></li> |
|
57 | 57 | {% endfor %} |
|
58 | 58 | </ul> |
|
59 | 59 | </div> |
|
60 | 60 | </div> |
|
61 | 61 | </div> |
|
62 | 62 | </div> |
|
63 | 63 | |
|
64 | 64 | <div id="running" class="tab-pane"> |
|
65 | 65 | |
|
66 | 66 | <div id="running_toolbar" class="row"> |
|
67 | 67 | <div class="span8"> |
|
68 | 68 | <span id="running_list_info">Currently running IPython notebooks</span> |
|
69 | 69 | </div> |
|
70 | 70 | <div class="span4" class="clearfix"> |
|
71 | 71 | <span id="running_buttons" class="pull-right"> |
|
72 | 72 | <button id="refresh_running_list" title="Refresh running list" class="btn btn-default btn-sm"><i class="icon-refresh"></i></button> |
|
73 | 73 | </span> |
|
74 | 74 | </div> |
|
75 | 75 | </div> |
|
76 | 76 | |
|
77 | 77 | <div id="running_list"> |
|
78 |
<div id="running_list_header" class="row |
|
|
78 | <div id="running_list_header" class="row warning"> | |
|
79 | 79 | <div> There are no notebooks running. </div> |
|
80 | 80 | </div> |
|
81 | 81 | </div> |
|
82 | 82 | </div> |
|
83 | 83 | |
|
84 | 84 | <div id="clusters" class="tab-pane"> |
|
85 | 85 | |
|
86 | 86 | <div id="cluster_toolbar" class="row"> |
|
87 | 87 | <div class="span8"> |
|
88 | 88 | <span id="cluster_list_info">IPython parallel computing clusters</span> |
|
89 | 89 | </div> |
|
90 | 90 | <div class="span4" class="clearfix"> |
|
91 | 91 | <span id="cluster_buttons" class="pull-right"> |
|
92 | 92 | <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-default btn-sm"><i class="icon-refresh"></i></button> |
|
93 | 93 | </span> |
|
94 | 94 | </div> |
|
95 | 95 | </div> |
|
96 | 96 | |
|
97 | 97 | <div id="cluster_list"> |
|
98 | 98 | <div id="cluster_list_header" class="row list_header"> |
|
99 | 99 | <div class="profile_col col-md-4">profile</div> |
|
100 | 100 | <div class="status_col col-md-3">status</div> |
|
101 | 101 | <div class="engines_col col-md-3" title="Enter the number of engines to start or empty for default"># of engines</div> |
|
102 | 102 | <div class="action_col col-md-2">action</div> |
|
103 | 103 | </div> |
|
104 | 104 | </div> |
|
105 | 105 | </div> |
|
106 | 106 | </div> |
|
107 | 107 | |
|
108 | 108 | </div> |
|
109 | 109 | |
|
110 | 110 | {% endblock %} |
|
111 | 111 | |
|
112 | 112 | {% block script %} |
|
113 | 113 | {{super()}} |
|
114 | 114 | <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script> |
|
115 | 115 | <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script> |
|
116 | 116 | <script src="{{static_url("tree/js/sessionlist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
117 | 117 | <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
118 | 118 | <script src="{{static_url("tree/js/kernellist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
119 | 119 | <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
120 | 120 | <script src="{{static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script> |
|
121 | 121 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now