Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better message for querying samples #2109

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/samples_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def query
end
end

if params[:input_template_id].present? # linked
if params[:input_template_id].present? && params[:input_attribute_id].present? # linked
input_template_attribute =
TemplateAttribute.find(params[:input_attribute_id])
@result = filter_linked_samples(@result, :linked_samples,
Expand All @@ -256,7 +256,7 @@ def query
template_id: params[:input_template_id] }, input_template_attribute)
end

if params[:output_template_id].present? # linking
if params[:output_template_id].present? && params[:output_attribute_id].present? # linking
output_template_attribute =
TemplateAttribute.find(params[:output_attribute_id])
@result = filter_linked_samples(@result, :linking_samples,
Expand Down
2 changes: 1 addition & 1 deletion app/views/samples/query.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$j('#samples-table').html('<%= escape_javascript(render(partial: "table_view", locals: { samples: @result, link: true, show_extra_info: true })) -%>');
$j('#sample-count').html('<%= "#{@visible_samples} sample(s) visible to you" %>')
$j('#sample-count').html('<span><%= "#{@visible_samples}"%> sample(s) visible to you' + '</span> - <span class=\"text-success\"> Successful query @ <%= "#{Time.now.strftime("%d/%m/%Y %H:%M:%S")}" %></span>')
Samples.initTable($j('#samples-table'), false, { hideEmptyColumns: true });
17 changes: 16 additions & 1 deletion app/views/samples/query_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<div class="row">
<div class="col-md-4" style="margin-bottom:20px">
<button id="btn_submit" class="btn btn-primary" onclick="submit()">Query</button>
<div id= "sample-query-spinner">
<%= image("spinner") %>
</div>
<br>
<em id="sample-count"></em>
</div>
Expand All @@ -137,6 +140,7 @@
$j(document).ready(function () {
initSelect2($j('.select2'), $j('#query_samples'))
Samples.initTable($j('#samples-table'));
$j('#sample-query-spinner').hide();
});

$j("#template").on("change", function(){
Expand Down Expand Up @@ -187,7 +191,18 @@
$j.ajax({
url: "<%=query_samples_path%>",
method: "POST",
data
data,
beforeSend: function(){
$j('#sample-count').html("");
$j("#sample-query-spinner").show();
$j('#samples-table').html("");
},
error: function(err){
$j('#sample-count').html(`<b><p class="text-danger">Error [code ${err.status}]: Failed to fetch query results!</p></b>`)
},
complete: function(){
$j("#sample-query-spinner").hide()
}
})
}
</script>
Loading