Skip to content

Commit

Permalink
changes based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ayobi committed Oct 28, 2024
1 parent 15c020c commit 8a1d7c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
25 changes: 12 additions & 13 deletions microsetta_admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ def per_sample_summary():
**build_login_variables())
else:
search_field = request.form.get('search_field')
search_value = request.form.get('text_input')
uploaded_file = request.files.get('file')
search_value = request.form.get('single_search')
uploaded_file = request.files.get('upload_list')

search_values = []

Expand All @@ -420,16 +420,7 @@ def per_sample_summary():
search_values = [search_value] if search_value else []

payload = {}
if search_field == 'sample_barcode':
payload['sample_barcodes'] = search_values
elif search_field == 'kit_id':
payload['kit_ids'] = search_values
elif search_field == 'email':
payload['emails'] = search_values
elif search_field == 'outbound_tracking':
payload['outbound_tracking_numbers'] = search_values
elif search_field == 'inbound_tracking':
payload['inbound_tracking_numbers'] = search_values
payload[search_field] = search_values

# perform the main query.
status, result = APIRequest.post('/api/admin/account_barcode_summary?'
Expand All @@ -447,7 +438,15 @@ def per_sample_summary():
order = ['sampleid', 'project', 'account-email',
'source-type', 'site-sampled', 'sample-date',
'sample-time', 'sample-status', 'sample-received',
'ffq-taken', 'ffq-complete', 'vioscreen_username']
'first-scan-status', 'first-scan-timestamp',
'latest-scan-status', 'latest-scan-timestamp',
'sample-has-inconsistencies', 'sample-is-valid',
'no-associated-source', 'no-collection-info',
'no-registered-account', 'received-unknown-validity',
'ffq-taken', 'ffq-complete', 'vioscreen_username',
'kit-id', 'outbound-tracking',
'inbound-tracking'
]
order.extend(sorted(set(resource.columns) - set(order)))
resource = resource[order]
else:
Expand Down
34 changes: 18 additions & 16 deletions microsetta_admin/templates/per_sample_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
};

function handleFormSubmit(event) {
var fileInput = document.getElementById('file');
var textInput = document.getElementById('text_input');
var fileInput = document.getElementById('upload_list');
var textInput = document.getElementById('single_search');

if (fileInput.files.length > 0 || textInput.value.trim() !== "") {
remove_error_messages();
return true;
} else {
alert('Please provide either a file or text input.');
if (fileInput.files.length > 0 && textInput.value.trim() !== "") {
alert("Please provide either a text input or a file, not both.");
event.preventDefault();
return false;
} else if (fileInput.files.length === 0 && textInput.value.trim() === "") {
alert("Please provide either a text input or a file.");
event.preventDefault();
return false;
} else {
remove_error_messages();
return true;
}
}

Expand Down Expand Up @@ -55,22 +59,22 @@ <h5>Retrieve summary for a sample</h5>
<td colspan=3 style="text-align:left;padding:4px">
<label for="search_field">Select search field:</label>
<select id="search_field" name="search_field">
<option value="sample_barcode">Barcode</option>
<option value="kit_id">Kit ID</option>
<option value="email">Email</option>
<option value="outbound_tracking">Outbound Tracking Number</option>
<option value="inbound_tracking">Inbound Tracking Number</option>
<option value="sample_barcodes">Barcode</option>
<option value="kit_ids">Kit ID</option>
<option value="emails">Email</option>
<option value="outbound_tracking_numbers">Outbound Tracking Number</option>
<option value="inbound_tracking_numbers">Inbound Tracking Number</option>
</select>
</td>
</tr>
<tr>
<td colspan=3 style="text-align:left;padding:4px">
<input type="text" name="text_input" placeholder="Enter value here" id="text_input">
<input type="text" name="single_search" placeholder="Enter value here" id="single_search">
</td>
</tr>
<tr>
<td colspan=3 style="text-align:left;padding:4px">
<input type="file" name="file" id="file">
<input type="file" name="upload_list" id="upload_list">
</td>
</tr>
<tr>
Expand All @@ -79,8 +83,6 @@ <h5>Retrieve summary for a sample</h5>
</td>
</tr>
<tr><td colspan=4></td></tr>
<tr><td colspan=4 style="text-align:center;padding:4px"><i>The selected search field must be in column "<span id="csv_column_name">sample_name</span>"<br>(max: 1000)</i> </td></tr>
<tr><td colspan=4></td></tr>
<tr>
<td colspan=3><label for="strip_sampleid">Check to remove sample IDs from summary</label></td>
<td colspan=1 style="text-align:center;padding:4px">
Expand Down

0 comments on commit 8a1d7c3

Please sign in to comment.