Skip to content

Commit

Permalink
Merge pull request #2109 from ELIXIR-Belgium/issue-2096-better-result…
Browse files Browse the repository at this point in the history
…-message-sample-query

Better message for querying samples
  • Loading branch information
kdp-cloud authored Jan 13, 2025
2 parents cd05bbf + 0579950 commit e930fde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
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>

0 comments on commit e930fde

Please sign in to comment.