##// END OF EJS Templates
Add selector button to dashboard
Jonathan Frederic -
Show More
@@ -114,10 +114,20 b' define(['
114 that.load_sessions();
114 that.load_sessions();
115 });
115 });
116
116
117 // Bind events for action buttons.
117 $('.rename-button').click($.proxy(this.rename_selected, this));
118 $('.rename-button').click($.proxy(this.rename_selected, this));
118 $('.shutdown-button').click($.proxy(this.shutdown_selected, this));
119 $('.shutdown-button').click($.proxy(this.shutdown_selected, this));
119 $('.duplicate-button').click($.proxy(this.duplicate_selected, this));
120 $('.duplicate-button').click($.proxy(this.duplicate_selected, this));
120 $('.delete-button').click($.proxy(this.delete_selected, this));
121 $('.delete-button').click($.proxy(this.delete_selected, this));
122
123 // Bind events for selection menu buttons.
124 $('#tree-selector .select-all').click($.proxy(this.select_all, this));
125 $('#tree-selector .select-notebooks').click($.proxy(this.select_notebooks, this));
126 $('#tree-selector .select-running-notebooks').click($.proxy(this.select_running_notebooks, this));
127 $('#tree-selector .select-files').click($.proxy(this.select_files, this));
128 $('#tree-selector .select-directories').click($.proxy(this.select_directories, this));
129 $('#tree-selector .select-inverse').click($.proxy(this.select_inverse, this));
130 $('#tree-selector .unselect-all').click($.proxy(this.unselect_all, this));
121 }
131 }
122 };
132 };
123
133
@@ -356,10 +366,93 b' define(['
356 };
366 };
357
367
358 /**
368 /**
369 * Select all of the items in the tree.
370 */
371 NotebookList.prototype.select_all = function() {
372 $('.list_item input[type=checkbox]').each(function(index, item) {
373 $(item).prop('checked', true);
374 });
375 this._selection_changed();
376 };
377
378 /**
379 * Select all of the notebooks in the tree.
380 */
381 NotebookList.prototype.select_notebooks = function() {
382 this.unselect_all();
383 $('.list_item').each(function(index, item) {
384 if ($(item).data('type') === 'notebook') {
385 $(item).find('input[type=checkbox]').prop('checked', true);
386 }
387 });
388 this._selection_changed();
389 };
390
391 /**
392 * Select all of the running notebooks in the tree.
393 */
394 NotebookList.prototype.select_running_notebooks = function() {
395 this.unselect_all();
396 var that = this;
397 $('.list_item').each(function(index, item) {
398 if ($(item).data('type') === 'notebook' && that.sessions[$(item).data('path')] !== undefined) {
399 $(item).find('input[type=checkbox]').prop('checked', true);
400 }
401 });
402 this._selection_changed();
403 };
404
405 /**
406 * Select all of the files in the tree.
407 */
408 NotebookList.prototype.select_files = function() {
409 this.unselect_all();
410 $('.list_item').each(function(index, item) {
411 if ($(item).data('type') === 'file') {
412 $(item).find('input[type=checkbox]').prop('checked', true);
413 }
414 });
415 this._selection_changed();
416 };
417
418 /**
419 * Select all of the directories in the tree.
420 */
421 NotebookList.prototype.select_directories = function() {
422 this.unselect_all();
423 $('.list_item').each(function(index, item) {
424 if ($(item).data('type') === 'directory') {
425 $(item).find('input[type=checkbox]').prop('checked', true);
426 }
427 });
428 this._selection_changed();
429 };
430
431 /**
432 * Select the inverse of the current selection.
433 */
434 NotebookList.prototype.select_inverse = function() {
435 $('.list_item input[type=checkbox]').each(function(index, item) {
436 $(item).prop('checked', !$(item).prop('checked'));
437 });
438 this._selection_changed();
439 };
440
441 /**
442 * Unselect everything selected in the tree.
443 */
444 NotebookList.prototype.unselect_all = function() {
445 $('.list_item input[type=checkbox]').each(function(index, item) {
446 $(item).prop('checked', false);
447 });
448 this._selection_changed();
449 };
450
451
452 /**
359 * Handles when any row selector checkbox is toggled.
453 * Handles when any row selector checkbox is toggled.
360 */
454 */
361 NotebookList.prototype._selection_changed = function() {
455 NotebookList.prototype._selection_changed = function() {
362
363 // Use a JQuery selector to find each row with a checked checkbox. If
456 // Use a JQuery selector to find each row with a checked checkbox. If
364 // we decide to add more checkboxes in the future, this code will need
457 // we decide to add more checkboxes in the future, this code will need
365 // to be changed to distinguish which checkbox is the row selector.
458 // to be changed to distinguish which checkbox is the row selector.
@@ -368,11 +461,14 b' define(['
368 var has_directory = false;
461 var has_directory = false;
369 var has_file = false;
462 var has_file = false;
370 var that = this;
463 var that = this;
464 var checked = 0;
371 $('.list_item :checked').each(function(index, item) {
465 $('.list_item :checked').each(function(index, item) {
372 var parent = $(item).parent().parent();
466 var parent = $(item).parent().parent();
373
467
374 // If the item doesn't have an upload button, it can be selected.
468 // If the item doesn't have an upload button and it's not the
375 if (parent.find('.upload_button').length === 0) {
469 // breadcrumbs, it can be selected. Breadcrumbs path == ''.
470 if (parent.find('.upload_button').length === 0 && parent.data('path') !== '') {
471 checked++;
376 selected.push({
472 selected.push({
377 name: parent.data('name'),
473 name: parent.data('name'),
378 path: parent.data('path'),
474 path: parent.data('path'),
@@ -417,6 +513,15 b' define(['
417 } else {
513 } else {
418 $('.delete-button').css('display', 'none');
514 $('.delete-button').css('display', 'none');
419 }
515 }
516
517 // If all of the items are selected, show the selector as checked. If
518 // some of the items are selected, show it as checked. Otherwise,
519 // uncheck it.
520 if (checked === 0) {
521 $('#tree-selector input[type=checkbox]').prop('checked', false);
522 } else {
523 $('#tree-selector input[type=checkbox]').prop('checked', true);
524 }
420 };
525 };
421
526
422 NotebookList.prototype.add_link = function (model, item) {
527 NotebookList.prototype.add_link = function (model, item) {
@@ -14,6 +14,9 b''
14 @dark_dashboard_color: @breadcrumb-color;
14 @dark_dashboard_color: @breadcrumb-color;
15 @list_stripe_color: lighten(@page-backdrop-color,3%);
15 @list_stripe_color: lighten(@page-backdrop-color,3%);
16
16
17 // The left padding of the selector button's contents.
18 @dashboard-selectorbtn-lpad: 7px;
19
17 ul#tabs {
20 ul#tabs {
18 margin-bottom: @dashboard_tb_pad;
21 margin-bottom: @dashboard_tb_pad;
19 }
22 }
@@ -100,6 +103,11 b' ul.breadcrumb {'
100
103
101 input {
104 input {
102 margin-right: @dashboard_lr_pad;
105 margin-right: @dashboard_lr_pad;
106 margin-left: @dashboard_lr_pad + @dashboard-selectorbtn-lpad;
107 }
108
109 .item_link {
110 margin-left: 14px;
103 }
111 }
104 }
112 }
105
113
@@ -152,12 +160,23 b' input.engine_num_input {'
152 color: blue;
160 color: blue;
153 }
161 }
154
162
155 #project_name > .breadcrumb {
163 #project_name {
156 padding: 0px;
164 display: inline-block;
157 margin-bottom: 0px;
165
158 background-color: transparent;
166 > .breadcrumb {
159 font-weight: bold;
167 padding: 0px;
160
168 margin-bottom: 0px;
169 background-color: transparent;
170 font-weight: bold;
171 }
172 }
173
174 #tree-selector {
175 display: inline-block;
176
177 input[type=checkbox] {
178 margin-left: @dashboard_lr_pad;
179 }
161 }
180 }
162
181
163 .tab-content .row {
182 .tab-content .row {
@@ -76,6 +76,24 b' data-terminals-available="{{terminals_available}}"'
76 </div>
76 </div>
77 <div id="notebook_list">
77 <div id="notebook_list">
78 <div id="notebook_list_header" class="row list_header">
78 <div id="notebook_list_header" class="row list_header">
79
80 <div class="dropdown" id='tree-selector'>
81 <button class="btn btn-default btn-xs dropdown-toggle" type="button" id="tree-selector-btn" data-toggle="dropdown" aria-expanded="true">
82 <input type='checkbox'></input>
83 <i class='semicheck fa fa-minus'></i>
84 <span class="caret"></span>
85 </button>
86 <ul class="dropdown-menu" role="menu" aria-labelledby="tree-selector-btn">
87 <li role="presentation" class="select-all"><a role="menuitem" tabindex="-1" href="#">Select all</a></li>
88 <li role="presentation" class="select-notebooks"><a role="menuitem" tabindex="-1" href="#">Select notebooks</a></li>
89 <li role="presentation" class="select-running-notebooks"><a role="menuitem" tabindex="-1" href="#">Select running notebooks</a></li>
90 <li role="presentation" class="select-files"><a role="menuitem" tabindex="-1" href="#">Select files</a></li>
91 <li role="presentation" class="select-directories"><a role="menuitem" tabindex="-1" href="#">Select directories</a></li>
92 <li role="presentation" class="select-inverse"><a role="menuitem" tabindex="-1" href="#">Select inverse</a></li>
93 <li role="presentation" class="unselect-all"><a role="menuitem" tabindex="-1" href="#">Unselect all</a></li>
94 </ul>
95 </div>
96
79 <div id="project_name">
97 <div id="project_name">
80 <ul class="breadcrumb">
98 <ul class="breadcrumb">
81 <li><a href="{{breadcrumbs[0][0]}}"><i class="fa fa-home"></i></a></li>
99 <li><a href="{{breadcrumbs[0][0]}}"><i class="fa fa-home"></i></a></li>
General Comments 0
You need to be logged in to leave comments. Login now