Skip to content

Commit b43291a

Browse files
committed
add clear button
1 parent a77a391 commit b43291a

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

qiita_pet/handlers/websocket_handlers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ def on_message(self, msg):
9191
elif 'remove_pd' in msginfo:
9292
data = msginfo['remove_pd']
9393
default.remove_samples([data['proc_data']])
94+
elif 'clear' in msginfo:
95+
data = msginfo['clear']
96+
default.remove_samples(data['pids'])
9497
self.write_message(msg)
9598

9699

qiita_pet/templates/analysis_selected.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
{% extends sitebase.html %}
22
{% block head %}
3+
{% from future.utils import viewitems %}
4+
{% from itertools import chain %}
35
<script src="/static/vendor/js/moi.js"></script>
46
<script type="text/javascript">
7+
58
function error(evt) { $('#ws-error').html("<b>Server communication error. Sample removal will not be recorded. Please try again later.</b>"); };
69
function check_color() {
710
if($('.row').length === 0) {
811
$('#dflt-sel-info').removeAttr('style');
912
$('#create-button').remove();
13+
$('#clear-button').remove();
14+
}
15+
}
16+
17+
function clear() {
18+
if(confirm('Are you sure you want to remove all samples?')) {
19+
moi.send('clear', {'pids': {% raw [int(p) for p in chain.from_iterable(pid.keys() for sid, pid in viewitems(sel_data))] %} });
1020
}
1121
}
1222

23+
function clear_from_html(data) {
24+
$.each($('.row'), function(index, value) { value.remove(); });
25+
check_color();
26+
}
27+
1328
function remove_proc_data(pid, sid) {
1429
if(confirm('Are you sure you want to remove all samples for this processed data?')) {
1530
moi.send('remove_pd', {'proc_data': pid, 'samples': [], 'sid': sid});
@@ -46,13 +61,14 @@
4661
moi.init(window.location.host + '/analysis/selected/socket/', null, function(){}, error, error);
4762
moi.add_callback('remove_pd', remove_pd_from_html);
4863
moi.add_callback('remove_sample', remove_sample_from_html);
64+
moi.add_callback('clear', clear_from_html);
65+
$('#clear-button').on('click', clear);
4966
});
5067
</script>
5168
{% end %}
5269

5370
{% block content %}
5471
{% from qiita_db.study import Study %}
55-
{% from future.utils import viewitems %}
5672
{% set static_info = {'data_type', 'processed_date', 'algorithm', 'reference_name', 'reference_version', 'sequence_filepath', 'taxonomy_filepath', 'tree_filepath'}%}
5773
<h1>Selected Samples</h1>
5874
<span id="ws-error" style="color:red"></span>
@@ -122,6 +138,9 @@ <h4 class="modal-title" id="myModalLabel">Processed Data {{pid}}</h4>
122138
<button type="button" class="btn btn-success btn-lg" id="create-button" name="create-button" data-toggle="modal" data-target="#create-analysis-modal-view">
123139
Create Analysis
124140
</button>
141+
<button type="button" class="btn btn-danger btn-lg" id="clear-button" name="clear-button">
142+
Clear Selected
143+
</button>
125144
{% end %}
126145

127146
<!-- modal view to enter analysis information -->

qiita_pet/templates/list_studies.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
function format ( d, row ) {
6161
// `d` is the original data object for the row
6262
// create formatted cell with proc data table
63-
var proc_data_table = '<h4>Processed Data</h4><table class="table" cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;"><tr><th></th><th>ID</th><th>Data type</th><th>Processed Date</th><th>Algorithm</th><th>Reference</th><th>Samples</th></tr>';
63+
var proc_data_table = '<h4>Processed Data</h4><table class="table" cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;width:80%"><tr><th></th><th>ID</th><th>Data type</th><th>Processed Date</th><th>Algorithm</th><th>Reference</th><th>Samples</th></tr>';
6464
for(i=0;i<d.proc_data_info.length;i++) {
6565
var proc_data = d.proc_data_info[i];
6666
proc_data_table += '<tr><td><input type="button" class="btn btn-sm" value="Add" onclick="sel_proc_data('+ row +','+ proc_data.pid +')"></td><td>' + proc_data.pid + '</td><td>' + proc_data.data_type + '</td><td>' + proc_data.processed_date + '</td><td>' + proc_data.algorithm + '</td><td>' + proc_data.reference_name + ' ' + proc_data.reference_version + '</td><td>' + proc_data.samples.length + '</td></tr>';

0 commit comments

Comments
 (0)