Skip to content

Commit

Permalink
Merge branch 'main' into rails-7-hacking-rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Jan 14, 2025
2 parents 17e05eb + 3f64613 commit 4dd6eb0
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 296 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/controllers/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def populate_template

begin
running!
PopulateTemplatesJob.new.queue_job
PopulateTemplatesJob.perform_later(@current_user)
rescue StandardError
done!
end
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/populate_templates_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
class PopulateTemplatesJob < ApplicationJob
queue_with_priority 1
queue_as QueueNames::TEMPLATES
def perform
def perform(user)
return unless Seek::Config.isa_json_compliance_enabled

Seek::ISATemplates::TemplateExtractor.extract_templates
Seek::ISATemplates::TemplateExtractor.extract_templates(user)
end
end
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>
248 changes: 138 additions & 110 deletions lib/seek/isa_templates/template_attributes_schema.json
Original file line number Diff line number Diff line change
@@ -1,112 +1,140 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "ISA tempalte attribute schema",
"description": "JSON-schema representing an ISA template attribute in DataHub",
"type": "object",
"properties": {
"iri": {
"anyOf": [
{
"type": "string",
"format": "uri"
},
{
"type": "null"
}
]
},
"name": { "type": "string" },
"description": { "type": "string" },
"required": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"ontology": {
"anyOf": [
{
"type": "object",
"properties": {
"name": { "type": "string" },
"version": {
"anyOf": [{ "type": "string" }, { "type": "number" }]
},
"description": { "type": "string" },
"rootTermURI": { "type": "string", "format": "uri" }
}
},
{
"type": "null"
}
]
},
"dataType": {
"type": "string",
"enum": [
"Date time",
"Date",
"Real number",
"Integer",
"Web link",
"Email address",
"Text",
"String",
"Boolean",
"Registered Sample",
"Registered Sample List",
"Controlled Vocabulary",
"URI",
"Registered Data file",
"ENA custom date"
]
},
"CVList": {
"anyOf": [
{
"type": "array"
},
{
"type": "null"
}
]
},
"isaTag": {
"anyOf": [
{
"type": "string",
"enum": [
"source",
"sample",
"protocol",
"source_characteristic",
"sample_characteristic",
"other_material",
"other_material_characteristic",
"data_file",
"data_file_comment",
"parameter_value"
]
},
{
"type": "null"
}
]
},
"title": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
"$schema": "http://json-schema.org/draft-04/schema",
"title": "ISA tempalte attribute schema",
"description": "JSON-schema representing an ISA template attribute in DataHub",
"type": "object",
"properties": {
"iri": {
"anyOf": [
{
"type": "string",
"format": "uri"
},
{
"type": "null"
}
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"ontology": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"version": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"description": {
"type": "string"
},
"rootTermURI": {
"type": "string",
"format": "uri"
}
}
},
{
"type": "null"
}
]
},
"dataType": {
"type": "string",
"enum": [
"Date time",
"Date",
"Real number",
"Integer",
"Web link",
"Email address",
"Text",
"String",
"Boolean",
"Registered Sample",
"Registered Sample List",
"Controlled Vocabulary",
"URI",
"Registered Data file",
"ENA custom date"
]
},
"allowCVFreeText": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"CVList": {
"anyOf": [
{
"type": "array"
},
{
"type": "null"
}
]
},
"isaTag": {
"anyOf": [
{
"type": "string",
"enum": [
"source",
"sample",
"protocol",
"source_characteristic",
"sample_characteristic",
"other_material",
"other_material_characteristic",
"data_file",
"data_file_comment",
"parameter_value"
]
},
{
"type": "null"
}
]
},
"title": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
}
Loading

0 comments on commit 4dd6eb0

Please sign in to comment.