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 |
@@ -10,30 +10,30 b'' | |||||
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 { |
@@ -21,7 +21,14 b' var IPython = (function (IPython) {' | |||||
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 | |||
@@ -30,6 +37,9 b' var IPython = (function (IPython) {' | |||||
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 | }); | |
@@ -61,7 +71,13 b' var IPython = (function (IPython) {' | |||||
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, | |
@@ -92,7 +108,7 b' var IPython = (function (IPython) {' | |||||
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 | |||
@@ -156,7 +172,7 b' var IPython = (function (IPython) {' | |||||
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/>'); |
@@ -23,9 +23,11 b' $(document).ready(function () {' | |||||
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 |
@@ -29,12 +29,13 b' data-read-only={{read_only}}' | |||||
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 %} | |
@@ -44,6 +45,19 b' data-read-only={{read_only}}' | |||||
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 | |||
@@ -53,5 +67,6 b' data-read-only={{read_only}}' | |||||
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