Show More
@@ -0,0 +1,128 b'' | |||||
|
1 | //---------------------------------------------------------------------------- | |||
|
2 | // Copyright (C) 2008-2011 The IPython Development Team | |||
|
3 | // | |||
|
4 | // Distributed under the terms of the BSD License. The full license is in | |||
|
5 | // the file COPYING, distributed as part of this software. | |||
|
6 | //---------------------------------------------------------------------------- | |||
|
7 | ||||
|
8 | //============================================================================ | |||
|
9 | // NotebookList | |||
|
10 | //============================================================================ | |||
|
11 | ||||
|
12 | var IPython = (function (IPython) { | |||
|
13 | ||||
|
14 | var ClusterList = function (selector) { | |||
|
15 | this.selector = selector; | |||
|
16 | if (this.selector !== undefined) { | |||
|
17 | this.element = $(selector); | |||
|
18 | this.style(); | |||
|
19 | this.bind_events(); | |||
|
20 | } | |||
|
21 | }; | |||
|
22 | ||||
|
23 | ClusterList.prototype.style = function () { | |||
|
24 | $('#cluster_toolbar').addClass('list_toolbar'); | |||
|
25 | $('#cluster_list_info').addClass('toolbar_info'); | |||
|
26 | $('#cluster_buttons').addClass('toolbar_buttons'); | |||
|
27 | $('div#cluster_header').addClass('list_header ui-widget ui-widget-header'); | |||
|
28 | $('#refresh_cluster_list').button({ | |||
|
29 | icons : {primary: 'ui-icon-arrowrefresh-1-s'}, | |||
|
30 | text : false | |||
|
31 | }); | |||
|
32 | }; | |||
|
33 | ||||
|
34 | ||||
|
35 | ClusterList.prototype.bind_events = function () { | |||
|
36 | var that = this; | |||
|
37 | $('#refresh_cluster_list').click(function () { | |||
|
38 | that.load_list(); | |||
|
39 | }); | |||
|
40 | }; | |||
|
41 | ||||
|
42 | ||||
|
43 | ClusterList.prototype.load_list = function () { | |||
|
44 | var settings = { | |||
|
45 | processData : false, | |||
|
46 | cache : false, | |||
|
47 | type : "GET", | |||
|
48 | dataType : "json", | |||
|
49 | success : $.proxy(this.load_list_success, this) | |||
|
50 | }; | |||
|
51 | var url = $('body').data('baseProjectUrl') + 'clusters'; | |||
|
52 | $.ajax(url, settings); | |||
|
53 | }; | |||
|
54 | ||||
|
55 | ||||
|
56 | ClusterList.prototype.clear_list = function () { | |||
|
57 | this.element.children('.list_item').remove(); | |||
|
58 | } | |||
|
59 | ||||
|
60 | ClusterList.prototype.load_list_success = function (data, status, xhr) { | |||
|
61 | console.log(data); | |||
|
62 | this.clear_list(); | |||
|
63 | var len = data.length; | |||
|
64 | for (var i=0; i<len; i++) { | |||
|
65 | var item_div = $('<div/>'); | |||
|
66 | item_div.addClass('list_item ui-widget ui-widget-content ui-helper-clearfix'); | |||
|
67 | item_div.css('border-top-style','none'); | |||
|
68 | var item = new ClusterItem(item_div); | |||
|
69 | item.update_state(data[i]); | |||
|
70 | item_div.data('item', item); | |||
|
71 | console.log('appending item', item); | |||
|
72 | this.element.append(item_div); | |||
|
73 | }; | |||
|
74 | }; | |||
|
75 | ||||
|
76 | ||||
|
77 | var ClusterItem = function (element) { | |||
|
78 | this.element = $(element); | |||
|
79 | this.data = null; | |||
|
80 | }; | |||
|
81 | ||||
|
82 | ||||
|
83 | ClusterItem.prototype.update_state = function (data) { | |||
|
84 | this.data = data; | |||
|
85 | if (data.status === 'running') { | |||
|
86 | this.state_running(); | |||
|
87 | } else if (data.status === 'stopped') { | |||
|
88 | this.state_stopped(); | |||
|
89 | }; | |||
|
90 | ||||
|
91 | } | |||
|
92 | ||||
|
93 | ||||
|
94 | ClusterItem.prototype.state_stopped = function () { | |||
|
95 | var item_name = $('<span/>').addClass('item_name').text(this.data.profile); | |||
|
96 | var item_buttons = $('<span/>').addClass('item_buttons'); | |||
|
97 | var start_button = $('<button>Start</button>').button(); | |||
|
98 | item_buttons.append(start_button); | |||
|
99 | this.element.append(item_name).append(item_buttons); | |||
|
100 | start_button.click(function (e) { | |||
|
101 | console.log('start'); | |||
|
102 | }); | |||
|
103 | } | |||
|
104 | ||||
|
105 | ||||
|
106 | ClusterItem.prototype.start_success = function () { | |||
|
107 | ||||
|
108 | }; | |||
|
109 | ||||
|
110 | ClusterItem.prototype.state_running = function () { | |||
|
111 | var item_name = $('<span/>').addClass('item_name').text(this.data.profile); | |||
|
112 | var item_buttons = $('<span/>').addClass('item_buttons'); | |||
|
113 | var stop_button = $('<button>Stop</button>').button(); | |||
|
114 | item_buttons.append(start_button); | |||
|
115 | this.element.append(item_name).append(item_buttons); | |||
|
116 | start_button.click(function (e) { | |||
|
117 | console.log('stop'); | |||
|
118 | }); | |||
|
119 | }; | |||
|
120 | ||||
|
121 | ||||
|
122 | IPython.ClusterList = ClusterList; | |||
|
123 | IPython.ClusterItem = ClusterItem; | |||
|
124 | ||||
|
125 | return IPython; | |||
|
126 | ||||
|
127 | }(IPython)); | |||
|
128 |
@@ -1,57 +1,57 b'' | |||||
1 |
|
1 | |||
2 | /** |
|
2 | /** | |
3 | * Primary styles |
|
3 | * Primary styles | |
4 | * |
|
4 | * | |
5 | * Author: IPython Development Team |
|
5 | * Author: IPython Development Team | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 | #main_app { |
|
8 | #main_app { | |
9 | width: 920px; |
|
9 | width: 920px; | |
10 | margin: 30px auto 0px auto; |
|
10 | margin: 30px auto 0px auto; | |
11 | } |
|
11 | } | |
12 |
|
12 | |||
13 |
|
|
13 | .list_toolbar { | |
14 | padding: 5px; |
|
14 | padding: 5px; | |
15 | height: 25px; |
|
15 | height: 25px; | |
16 | line-height: 25px; |
|
16 | line-height: 25px; | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | #drag_info { |
|
19 | .toolbar_info { | |
20 | float: left; |
|
20 | float: left; | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 |
|
|
23 | .toolbar_buttons { | |
24 | float: right; |
|
24 | float: right; | |
25 | } |
|
25 | } | |
26 |
|
26 | |||
27 | #project_name { |
|
27 | .list_header { | |
28 | height: 25px; |
|
28 | height: 25px; | |
29 | line-height: 25px; |
|
29 | line-height: 25px; | |
30 | padding: 3px; |
|
30 | padding: 3px 5px; | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 |
. |
|
33 | .list_item { | |
34 | height: 25px; |
|
34 | height: 25px; | |
35 | line-height: 25px; |
|
35 | line-height: 25px; | |
36 | padding: 3px; |
|
36 | padding: 3px 5px; | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | .notebook_item a { |
|
39 | .notebook_item a { | |
40 | text-decoration: none; |
|
40 | text-decoration: none; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | .item_buttons { |
|
43 | .item_buttons { | |
44 | float: right; |
|
44 | float: right; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | .item_buttons .upload_button { |
|
47 | .item_buttons .upload_button { | |
48 | color: darkred; |
|
48 | color: darkred; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | .highlight_text { |
|
51 | .highlight_text { | |
52 | color: blue; |
|
52 | color: blue; | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | .ui-tabs .ui-tabs-nav li a { |
|
55 | .ui-tabs .ui-tabs-nav li a { | |
56 | padding: .3em .5em; |
|
56 | padding: .3em .5em; | |
57 | } |
|
57 | } |
@@ -1,251 +1,267 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | //---------------------------------------------------------------------------- | |
2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
2 | // Copyright (C) 2008-2011 The IPython Development Team | |
3 | // |
|
3 | // | |
4 | // Distributed under the terms of the BSD License. The full license is in |
|
4 | // Distributed under the terms of the BSD License. The full license is in | |
5 | // the file COPYING, distributed as part of this software. |
|
5 | // the file COPYING, distributed as part of this software. | |
6 | //---------------------------------------------------------------------------- |
|
6 | //---------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | //============================================================================ |
|
8 | //============================================================================ | |
9 | // NotebookList |
|
9 | // NotebookList | |
10 | //============================================================================ |
|
10 | //============================================================================ | |
11 |
|
11 | |||
12 | var IPython = (function (IPython) { |
|
12 | var IPython = (function (IPython) { | |
13 |
|
13 | |||
14 | var NotebookList = function (selector) { |
|
14 | var NotebookList = function (selector) { | |
15 | this.selector = selector; |
|
15 | this.selector = selector; | |
16 | if (this.selector !== undefined) { |
|
16 | if (this.selector !== undefined) { | |
17 | this.element = $(selector); |
|
17 | this.element = $(selector); | |
18 | this.style(); |
|
18 | this.style(); | |
19 | this.bind_events(); |
|
19 | this.bind_events(); | |
20 | } |
|
20 | } | |
21 | }; |
|
21 | }; | |
22 |
|
22 | |||
23 | NotebookList.prototype.style = function () { |
|
23 | NotebookList.prototype.style = function () { | |
24 | $('div#project_name').addClass('ui-widget ui-widget-header'); |
|
24 | $('#notebook_toolbar').addClass('list_toolbar'); | |
|
25 | $('#drag_info').addClass('toolbar_info'); | |||
|
26 | $('#notebook_buttons').addClass('toolbar_buttons'); | |||
|
27 | $('div#project_name').addClass('list_header ui-widget ui-widget-header'); | |||
|
28 | $('#refresh_notebook_list').button({ | |||
|
29 | icons : {primary: 'ui-icon-arrowrefresh-1-s'}, | |||
|
30 | text : false | |||
|
31 | }); | |||
25 | }; |
|
32 | }; | |
26 |
|
33 | |||
27 |
|
34 | |||
28 | NotebookList.prototype.bind_events = function () { |
|
35 | NotebookList.prototype.bind_events = function () { | |
29 | if (IPython.read_only){ |
|
36 | if (IPython.read_only){ | |
30 | return; |
|
37 | return; | |
31 | } |
|
38 | } | |
32 | var that = this; |
|
39 | var that = this; | |
|
40 | $('#refresh_notebook_list').click(function () { | |||
|
41 | that.load_list(); | |||
|
42 | }); | |||
33 | this.element.bind('dragover', function () { |
|
43 | this.element.bind('dragover', function () { | |
34 | return false; |
|
44 | return false; | |
35 | }); |
|
45 | }); | |
36 | this.element.bind('drop', function (event) { |
|
46 | this.element.bind('drop', function (event) { | |
37 | var files = event.originalEvent.dataTransfer.files; |
|
47 | var files = event.originalEvent.dataTransfer.files; | |
38 | for (var i = 0, f; f = files[i]; i++) { |
|
48 | for (var i = 0, f; f = files[i]; i++) { | |
39 | var reader = new FileReader(); |
|
49 | var reader = new FileReader(); | |
40 | reader.readAsText(f); |
|
50 | reader.readAsText(f); | |
41 | var fname = f.name.split('.'); |
|
51 | var fname = f.name.split('.'); | |
42 | var nbname = fname.slice(0,-1).join('.'); |
|
52 | var nbname = fname.slice(0,-1).join('.'); | |
43 | var nbformat = fname.slice(-1)[0]; |
|
53 | var nbformat = fname.slice(-1)[0]; | |
44 | if (nbformat === 'ipynb') {nbformat = 'json';}; |
|
54 | if (nbformat === 'ipynb') {nbformat = 'json';}; | |
45 | if (nbformat === 'py' || nbformat === 'json') { |
|
55 | if (nbformat === 'py' || nbformat === 'json') { | |
46 | var item = that.new_notebook_item(0); |
|
56 | var item = that.new_notebook_item(0); | |
47 | that.add_name_input(nbname, item); |
|
57 | that.add_name_input(nbname, item); | |
48 | item.data('nbformat', nbformat); |
|
58 | item.data('nbformat', nbformat); | |
49 | // Store the notebook item in the reader so we can use it later |
|
59 | // Store the notebook item in the reader so we can use it later | |
50 | // to know which item it belongs to. |
|
60 | // to know which item it belongs to. | |
51 | $(reader).data('item', item); |
|
61 | $(reader).data('item', item); | |
52 | reader.onload = function (event) { |
|
62 | reader.onload = function (event) { | |
53 | var nbitem = $(event.target).data('item'); |
|
63 | var nbitem = $(event.target).data('item'); | |
54 | that.add_notebook_data(event.target.result, nbitem); |
|
64 | that.add_notebook_data(event.target.result, nbitem); | |
55 | that.add_upload_button(nbitem); |
|
65 | that.add_upload_button(nbitem); | |
56 | }; |
|
66 | }; | |
57 | }; |
|
67 | }; | |
58 | } |
|
68 | } | |
59 | return false; |
|
69 | return false; | |
60 | }); |
|
70 | }); | |
61 | }; |
|
71 | }; | |
62 |
|
72 | |||
63 |
|
73 | |||
|
74 | NotebookList.prototype.clear_list = function () { | |||
|
75 | this.element.children('.list_item').remove(); | |||
|
76 | } | |||
|
77 | ||||
|
78 | ||||
64 | NotebookList.prototype.load_list = function () { |
|
79 | NotebookList.prototype.load_list = function () { | |
|
80 | this.clear_list(); | |||
65 | var settings = { |
|
81 | var settings = { | |
66 | processData : false, |
|
82 | processData : false, | |
67 | cache : false, |
|
83 | cache : false, | |
68 | type : "GET", |
|
84 | type : "GET", | |
69 | dataType : "json", |
|
85 | dataType : "json", | |
70 | success : $.proxy(this.list_loaded, this) |
|
86 | success : $.proxy(this.list_loaded, this) | |
71 | }; |
|
87 | }; | |
72 | var url = $('body').data('baseProjectUrl') + 'notebooks'; |
|
88 | var url = $('body').data('baseProjectUrl') + 'notebooks'; | |
73 | $.ajax(url, settings); |
|
89 | $.ajax(url, settings); | |
74 | }; |
|
90 | }; | |
75 |
|
91 | |||
76 |
|
92 | |||
77 | NotebookList.prototype.list_loaded = function (data, status, xhr) { |
|
93 | NotebookList.prototype.list_loaded = function (data, status, xhr) { | |
78 | var len = data.length; |
|
94 | var len = data.length; | |
79 | // Todo: remove old children |
|
95 | // Todo: remove old children | |
80 | for (var i=0; i<len; i++) { |
|
96 | for (var i=0; i<len; i++) { | |
81 | var notebook_id = data[i].notebook_id; |
|
97 | var notebook_id = data[i].notebook_id; | |
82 | var nbname = data[i].name; |
|
98 | var nbname = data[i].name; | |
83 | var item = this.new_notebook_item(i); |
|
99 | var item = this.new_notebook_item(i); | |
84 | this.add_link(notebook_id, nbname, item); |
|
100 | this.add_link(notebook_id, nbname, item); | |
85 | if (!IPython.read_only){ |
|
101 | if (!IPython.read_only){ | |
86 | // hide delete buttons when readonly |
|
102 | // hide delete buttons when readonly | |
87 | this.add_delete_button(item); |
|
103 | this.add_delete_button(item); | |
88 | } |
|
104 | } | |
89 | }; |
|
105 | }; | |
90 | }; |
|
106 | }; | |
91 |
|
107 | |||
92 |
|
108 | |||
93 | NotebookList.prototype.new_notebook_item = function (index) { |
|
109 | NotebookList.prototype.new_notebook_item = function (index) { | |
94 | var item = $('<div/>'); |
|
110 | var item = $('<div/>'); | |
95 |
item.addClass(' |
|
111 | item.addClass('list_item ui-widget ui-widget-content ui-helper-clearfix'); | |
96 | item.css('border-top-style','none'); |
|
112 | item.css('border-top-style','none'); | |
97 | var item_name = $('<span/>').addClass('item_name'); |
|
113 | var item_name = $('<span/>').addClass('item_name'); | |
98 |
|
114 | |||
99 | item.append(item_name); |
|
115 | item.append(item_name); | |
100 | if (index === -1) { |
|
116 | if (index === -1) { | |
101 | this.element.append(item); |
|
117 | this.element.append(item); | |
102 | } else { |
|
118 | } else { | |
103 | this.element.children().eq(index).after(item); |
|
119 | this.element.children().eq(index).after(item); | |
104 | } |
|
120 | } | |
105 | return item; |
|
121 | return item; | |
106 | }; |
|
122 | }; | |
107 |
|
123 | |||
108 |
|
124 | |||
109 | NotebookList.prototype.add_link = function (notebook_id, nbname, item) { |
|
125 | NotebookList.prototype.add_link = function (notebook_id, nbname, item) { | |
110 | item.data('nbname', nbname); |
|
126 | item.data('nbname', nbname); | |
111 | item.data('notebook_id', notebook_id); |
|
127 | item.data('notebook_id', notebook_id); | |
112 | var new_item_name = $('<span/>').addClass('item_name'); |
|
128 | var new_item_name = $('<span/>').addClass('item_name'); | |
113 | new_item_name.append( |
|
129 | new_item_name.append( | |
114 | $('<a/>'). |
|
130 | $('<a/>'). | |
115 | attr('href', $('body').data('baseProjectUrl')+notebook_id). |
|
131 | attr('href', $('body').data('baseProjectUrl')+notebook_id). | |
116 | attr('target','_blank'). |
|
132 | attr('target','_blank'). | |
117 | text(nbname) |
|
133 | text(nbname) | |
118 | ); |
|
134 | ); | |
119 | var e = item.find('.item_name'); |
|
135 | var e = item.find('.item_name'); | |
120 | if (e.length === 0) { |
|
136 | if (e.length === 0) { | |
121 | item.append(new_item_name); |
|
137 | item.append(new_item_name); | |
122 | } else { |
|
138 | } else { | |
123 | e.replaceWith(new_item_name); |
|
139 | e.replaceWith(new_item_name); | |
124 | }; |
|
140 | }; | |
125 | }; |
|
141 | }; | |
126 |
|
142 | |||
127 |
|
143 | |||
128 | NotebookList.prototype.add_name_input = function (nbname, item) { |
|
144 | NotebookList.prototype.add_name_input = function (nbname, item) { | |
129 | item.data('nbname', nbname); |
|
145 | item.data('nbname', nbname); | |
130 | var new_item_name = $('<span/>').addClass('item_name'); |
|
146 | var new_item_name = $('<span/>').addClass('item_name'); | |
131 | new_item_name.append( |
|
147 | new_item_name.append( | |
132 | $('<input/>').addClass('ui-widget ui-widget-content'). |
|
148 | $('<input/>').addClass('ui-widget ui-widget-content'). | |
133 | attr('value', nbname). |
|
149 | attr('value', nbname). | |
134 | attr('size', '30'). |
|
150 | attr('size', '30'). | |
135 | attr('type', 'text') |
|
151 | attr('type', 'text') | |
136 | ); |
|
152 | ); | |
137 | var e = item.find('.item_name'); |
|
153 | var e = item.find('.item_name'); | |
138 | if (e.length === 0) { |
|
154 | if (e.length === 0) { | |
139 | item.append(new_item_name); |
|
155 | item.append(new_item_name); | |
140 | } else { |
|
156 | } else { | |
141 | e.replaceWith(new_item_name); |
|
157 | e.replaceWith(new_item_name); | |
142 | }; |
|
158 | }; | |
143 | }; |
|
159 | }; | |
144 |
|
160 | |||
145 |
|
161 | |||
146 | NotebookList.prototype.add_notebook_data = function (data, item) { |
|
162 | NotebookList.prototype.add_notebook_data = function (data, item) { | |
147 | item.data('nbdata',data); |
|
163 | item.data('nbdata',data); | |
148 | }; |
|
164 | }; | |
149 |
|
165 | |||
150 |
|
166 | |||
151 | NotebookList.prototype.add_delete_button = function (item) { |
|
167 | NotebookList.prototype.add_delete_button = function (item) { | |
152 | var new_buttons = $('<span/>').addClass('item_buttons'); |
|
168 | var new_buttons = $('<span/>').addClass('item_buttons'); | |
153 | var delete_button = $('<button>Delete</button>').button(). |
|
169 | var delete_button = $('<button>Delete</button>').button(). | |
154 | click(function (e) { |
|
170 | click(function (e) { | |
155 | // $(this) is the button that was clicked. |
|
171 | // $(this) is the button that was clicked. | |
156 | var that = $(this); |
|
172 | var that = $(this); | |
157 | // We use the nbname and notebook_id from the parent notebook_item element's |
|
173 | // We use the nbname and notebook_id from the parent notebook_item element's | |
158 | // data because the outer scopes values change as we iterate through the loop. |
|
174 | // data because the outer scopes values change as we iterate through the loop. | |
159 |
var parent_item = that.parents('div. |
|
175 | var parent_item = that.parents('div.list_item'); | |
160 | var nbname = parent_item.data('nbname'); |
|
176 | var nbname = parent_item.data('nbname'); | |
161 | var notebook_id = parent_item.data('notebook_id'); |
|
177 | var notebook_id = parent_item.data('notebook_id'); | |
162 | var dialog = $('<div/>'); |
|
178 | var dialog = $('<div/>'); | |
163 | dialog.html('Are you sure you want to permanently delete the notebook: ' + nbname + '?'); |
|
179 | dialog.html('Are you sure you want to permanently delete the notebook: ' + nbname + '?'); | |
164 | parent_item.append(dialog); |
|
180 | parent_item.append(dialog); | |
165 | dialog.dialog({ |
|
181 | dialog.dialog({ | |
166 | resizable: false, |
|
182 | resizable: false, | |
167 | modal: true, |
|
183 | modal: true, | |
168 | title: "Delete notebook", |
|
184 | title: "Delete notebook", | |
169 | buttons : { |
|
185 | buttons : { | |
170 | "Delete": function () { |
|
186 | "Delete": function () { | |
171 | var settings = { |
|
187 | var settings = { | |
172 | processData : false, |
|
188 | processData : false, | |
173 | cache : false, |
|
189 | cache : false, | |
174 | type : "DELETE", |
|
190 | type : "DELETE", | |
175 | dataType : "json", |
|
191 | dataType : "json", | |
176 | success : function (data, status, xhr) { |
|
192 | success : function (data, status, xhr) { | |
177 | parent_item.remove(); |
|
193 | parent_item.remove(); | |
178 | } |
|
194 | } | |
179 | }; |
|
195 | }; | |
180 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; |
|
196 | var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id; | |
181 | $.ajax(url, settings); |
|
197 | $.ajax(url, settings); | |
182 | $(this).dialog('close'); |
|
198 | $(this).dialog('close'); | |
183 | }, |
|
199 | }, | |
184 | "Cancel": function () { |
|
200 | "Cancel": function () { | |
185 | $(this).dialog('close'); |
|
201 | $(this).dialog('close'); | |
186 | } |
|
202 | } | |
187 | } |
|
203 | } | |
188 | }); |
|
204 | }); | |
189 | }); |
|
205 | }); | |
190 | new_buttons.append(delete_button); |
|
206 | new_buttons.append(delete_button); | |
191 | var e = item.find('.item_buttons'); |
|
207 | var e = item.find('.item_buttons'); | |
192 | if (e.length === 0) { |
|
208 | if (e.length === 0) { | |
193 | item.append(new_buttons); |
|
209 | item.append(new_buttons); | |
194 | } else { |
|
210 | } else { | |
195 | e.replaceWith(new_buttons); |
|
211 | e.replaceWith(new_buttons); | |
196 | }; |
|
212 | }; | |
197 | }; |
|
213 | }; | |
198 |
|
214 | |||
199 |
|
215 | |||
200 | NotebookList.prototype.add_upload_button = function (item) { |
|
216 | NotebookList.prototype.add_upload_button = function (item) { | |
201 | var that = this; |
|
217 | var that = this; | |
202 | var new_buttons = $('<span/>').addClass('item_buttons'); |
|
218 | var new_buttons = $('<span/>').addClass('item_buttons'); | |
203 | var upload_button = $('<button>Upload</button>').button(). |
|
219 | var upload_button = $('<button>Upload</button>').button(). | |
204 | click(function (e) { |
|
220 | click(function (e) { | |
205 | var nbname = item.find('.item_name > input').attr('value'); |
|
221 | var nbname = item.find('.item_name > input').attr('value'); | |
206 | var nbformat = item.data('nbformat'); |
|
222 | var nbformat = item.data('nbformat'); | |
207 | var nbdata = item.data('nbdata'); |
|
223 | var nbdata = item.data('nbdata'); | |
208 | var content_type = 'text/plain'; |
|
224 | var content_type = 'text/plain'; | |
209 | if (nbformat === 'json') { |
|
225 | if (nbformat === 'json') { | |
210 | content_type = 'application/json'; |
|
226 | content_type = 'application/json'; | |
211 | } else if (nbformat === 'py') { |
|
227 | } else if (nbformat === 'py') { | |
212 | content_type = 'application/x-python'; |
|
228 | content_type = 'application/x-python'; | |
213 | }; |
|
229 | }; | |
214 | var settings = { |
|
230 | var settings = { | |
215 | processData : false, |
|
231 | processData : false, | |
216 | cache : false, |
|
232 | cache : false, | |
217 | type : 'POST', |
|
233 | type : 'POST', | |
218 | dataType : 'json', |
|
234 | dataType : 'json', | |
219 | data : nbdata, |
|
235 | data : nbdata, | |
220 | headers : {'Content-Type': content_type}, |
|
236 | headers : {'Content-Type': content_type}, | |
221 | success : function (data, status, xhr) { |
|
237 | success : function (data, status, xhr) { | |
222 | that.add_link(data, nbname, item); |
|
238 | that.add_link(data, nbname, item); | |
223 | that.add_delete_button(item); |
|
239 | that.add_delete_button(item); | |
224 | } |
|
240 | } | |
225 | }; |
|
241 | }; | |
226 |
|
242 | |||
227 | var qs = $.param({name:nbname, format:nbformat}); |
|
243 | var qs = $.param({name:nbname, format:nbformat}); | |
228 | var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs; |
|
244 | var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs; | |
229 | $.ajax(url, settings); |
|
245 | $.ajax(url, settings); | |
230 | }); |
|
246 | }); | |
231 | var cancel_button = $('<button>Cancel</button>').button(). |
|
247 | var cancel_button = $('<button>Cancel</button>').button(). | |
232 | click(function (e) { |
|
248 | click(function (e) { | |
233 | item.remove(); |
|
249 | item.remove(); | |
234 | }); |
|
250 | }); | |
235 | upload_button.addClass('upload_button'); |
|
251 | upload_button.addClass('upload_button'); | |
236 | new_buttons.append(upload_button).append(cancel_button); |
|
252 | new_buttons.append(upload_button).append(cancel_button); | |
237 | var e = item.find('.item_buttons'); |
|
253 | var e = item.find('.item_buttons'); | |
238 | if (e.length === 0) { |
|
254 | if (e.length === 0) { | |
239 | item.append(new_buttons); |
|
255 | item.append(new_buttons); | |
240 | } else { |
|
256 | } else { | |
241 | e.replaceWith(new_buttons); |
|
257 | e.replaceWith(new_buttons); | |
242 | }; |
|
258 | }; | |
243 | }; |
|
259 | }; | |
244 |
|
260 | |||
245 |
|
261 | |||
246 | IPython.NotebookList = NotebookList; |
|
262 | IPython.NotebookList = NotebookList; | |
247 |
|
263 | |||
248 | return IPython; |
|
264 | return IPython; | |
249 |
|
265 | |||
250 | }(IPython)); |
|
266 | }(IPython)); | |
251 |
|
267 |
@@ -1,33 +1,35 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | //---------------------------------------------------------------------------- | |
2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
2 | // Copyright (C) 2008-2011 The IPython Development Team | |
3 | // |
|
3 | // | |
4 | // Distributed under the terms of the BSD License. The full license is in |
|
4 | // Distributed under the terms of the BSD License. The full license is in | |
5 | // the file COPYING, distributed as part of this software. |
|
5 | // the file COPYING, distributed as part of this software. | |
6 | //---------------------------------------------------------------------------- |
|
6 | //---------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | //============================================================================ |
|
8 | //============================================================================ | |
9 | // On document ready |
|
9 | // On document ready | |
10 | //============================================================================ |
|
10 | //============================================================================ | |
11 |
|
11 | |||
12 |
|
12 | |||
13 | $(document).ready(function () { |
|
13 | $(document).ready(function () { | |
14 |
|
14 | |||
15 | IPython.page = new IPython.Page(); |
|
15 | IPython.page = new IPython.Page(); | |
16 |
|
16 | |||
17 | $('div#tabs').tabs(); |
|
17 | $('div#tabs').tabs(); | |
18 | $('div#main_app').addClass('border-box-sizing ui-widget'); |
|
18 | $('div#main_app').addClass('border-box-sizing ui-widget'); | |
19 | $('div#notebooks_toolbar').addClass('ui-widget ui-helper-clearfix'); |
|
19 | $('div#notebooks_toolbar').addClass('ui-widget ui-helper-clearfix'); | |
20 | $('#new_notebook').button().click(function (e) { |
|
20 | $('#new_notebook').button().click(function (e) { | |
21 | window.open($('body').data('baseProjectUrl')+'new'); |
|
21 | window.open($('body').data('baseProjectUrl')+'new'); | |
22 | }); |
|
22 | }); | |
23 |
|
23 | |||
24 | IPython.read_only = $('body').data('readOnly') === 'True'; |
|
24 | IPython.read_only = $('body').data('readOnly') === 'True'; | |
25 | IPython.notebook_list = new IPython.NotebookList('div#notebook_list'); |
|
25 | IPython.notebook_list = new IPython.NotebookList('div#notebook_list'); | |
|
26 | IPython.cluster_list = new IPython.ClusterList('div#cluster_list'); | |||
26 | IPython.login_widget = new IPython.LoginWidget('span#login_widget'); |
|
27 | IPython.login_widget = new IPython.LoginWidget('span#login_widget'); | |
27 |
|
28 | |||
28 | IPython.notebook_list.load_list(); |
|
29 | IPython.notebook_list.load_list(); | |
|
30 | IPython.cluster_list.load_list(); | |||
29 |
|
31 | |||
30 | IPython.page.show(); |
|
32 | IPython.page.show(); | |
31 |
|
33 | |||
32 | }); |
|
34 | }); | |
33 |
|
35 |
@@ -1,57 +1,72 b'' | |||||
1 | {% extends page.html %} |
|
1 | {% extends page.html %} | |
2 |
|
2 | |||
3 | {% block title %}IPython Dashboard{% end %} |
|
3 | {% block title %}IPython Dashboard{% end %} | |
4 |
|
4 | |||
5 | {% block stylesheet %} |
|
5 | {% block stylesheet %} | |
6 | <link rel="stylesheet" href="{{static_url("css/projectdashboard.css") }}" type="text/css" /> |
|
6 | <link rel="stylesheet" href="{{static_url("css/projectdashboard.css") }}" type="text/css" /> | |
7 | {% end %} |
|
7 | {% end %} | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | {% block params %} |
|
10 | {% block params %} | |
11 |
|
11 | |||
12 | data-project={{project}} |
|
12 | data-project={{project}} | |
13 | data-base-project-url={{base_project_url}} |
|
13 | data-base-project-url={{base_project_url}} | |
14 | data-base-kernel-url={{base_kernel_url}} |
|
14 | data-base-kernel-url={{base_kernel_url}} | |
15 | data-read-only={{read_only}} |
|
15 | data-read-only={{read_only}} | |
16 |
|
16 | |||
17 | {% end %} |
|
17 | {% end %} | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | {% block site %} |
|
20 | {% block site %} | |
21 |
|
21 | |||
22 | <div id="main_app"> |
|
22 | <div id="main_app"> | |
23 |
|
23 | |||
24 | <div id="tabs"> |
|
24 | <div id="tabs"> | |
25 | <ul> |
|
25 | <ul> | |
26 | <li><a href="#tab1">Notebooks</a></li> |
|
26 | <li><a href="#tab1">Notebooks</a></li> | |
27 | <li><a href="#tab2">Clusters</a></li> |
|
27 | <li><a href="#tab2">Clusters</a></li> | |
28 | </ul> |
|
28 | </ul> | |
29 |
|
29 | |||
30 | <div id="tab1"> |
|
30 | <div id="tab1"> | |
31 | {% if logged_in or not read_only %} |
|
31 | {% if logged_in or not read_only %} | |
32 |
<div id="notebook |
|
32 | <div id="notebook_toolbar"> | |
33 | <span id="drag_info">Drag files onto the list to import |
|
33 | <span id="drag_info">Drag files onto the list to import | |
34 | notebooks.</span> |
|
34 | notebooks.</span> | |
35 |
|
35 | |||
36 |
<span id="notebook |
|
36 | <span id="notebook_buttons"> | |
37 |
<button id=" |
|
37 | <button id="refresh_notebook_list" title="Refresh notebook list">Refresh</button> | |
|
38 | <button id="new_notebook" title="Create new notebook">New Notebook</button> | |||
38 | </span> |
|
39 | </span> | |
39 | </div> |
|
40 | </div> | |
40 | {% end %} |
|
41 | {% end %} | |
41 |
|
42 | |||
42 | <div id="notebook_list"> |
|
43 | <div id="notebook_list"> | |
43 | <div id="project_name"><h2>{{project}}</h2></div> |
|
44 | <div id="project_name"><h2>{{project}}</h2></div> | |
44 | </div> |
|
45 | </div> | |
45 | </div> |
|
46 | </div> | |
46 | <div id="tab2"> |
|
47 | <div id="tab2"> | |
|
48 | ||||
|
49 | <div id="cluster_toolbar"> | |||
|
50 | <span id="cluster_list_info">IPython parallel computing clusters</span> | |||
|
51 | ||||
|
52 | <span id="cluster_buttons"> | |||
|
53 | <button id="refresh_cluster_list" title="Refresh cluster list">Refresh</button> | |||
|
54 | </span> | |||
|
55 | </div> | |||
|
56 | ||||
|
57 | <div id="cluster_list"> | |||
|
58 | <div id="cluster_header"><h2>Clusters</h2></div> | |||
|
59 | </div> | |||
|
60 | ||||
47 | </div> |
|
61 | </div> | |
48 | </div> |
|
62 | </div> | |
49 |
|
63 | |||
50 | </div> |
|
64 | </div> | |
51 |
|
65 | |||
52 | {% end %} |
|
66 | {% end %} | |
53 |
|
67 | |||
54 | {% block script %} |
|
68 | {% block script %} | |
55 | <script src="{{static_url("js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
69 | <script src="{{static_url("js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script> | |
|
70 | <script src="{{static_url("js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script> | |||
56 | <script src="{{static_url("js/projectdashboardmain.js") }}" type="text/javascript" charset="utf-8"></script> |
|
71 | <script src="{{static_url("js/projectdashboardmain.js") }}" type="text/javascript" charset="utf-8"></script> | |
57 | {% end %} |
|
72 | {% end %} |
General Comments 0
You need to be logged in to leave comments.
Login now