aboutsummaryrefslogtreecommitdiff
path: root/uploader/templates/phenotypes/add-phenotypes-base.html
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/templates/phenotypes/add-phenotypes-base.html')
-rw-r--r--uploader/templates/phenotypes/add-phenotypes-base.html129
1 files changed, 72 insertions, 57 deletions
diff --git a/uploader/templates/phenotypes/add-phenotypes-base.html b/uploader/templates/phenotypes/add-phenotypes-base.html
index b3a53b0..97b55f2 100644
--- a/uploader/templates/phenotypes/add-phenotypes-base.html
+++ b/uploader/templates/phenotypes/add-phenotypes-base.html
@@ -30,7 +30,9 @@
action="{{url_for('species.populations.phenotypes.add_phenotypes',
species_id=species.SpeciesId,
population_id=population.Id,
- dataset_id=dataset.Id)}}">
+ dataset_id=dataset.Id,
+ use_bundle=use_bundle)}}"
+ data-resumable-target="{{url_for('files.resumable_upload_post')}}">
<legend>Add New Phenotypes</legend>
<div class="form-text help-block">
@@ -57,6 +59,9 @@
<button id="btn-search-pubmed-id" class="btn btn-info">Search</button>
</span>
</div>
+ <span id="search-pubmed-id-error"
+ class="form-text text-muted text-danger hidden">
+ </span><br />
<span class="form-text text-muted">
Enter your publication's PubMed ID above and click "Search" to search
for some (or all) of the publication details requested below.
@@ -114,7 +119,7 @@
</div>
<div class="form-group">
- <label for="txt-publication-month" class="form-label">
+ <label for="select-publication-month" class="form-label">
Publication Month</label>
<select id="select-publication-month" name="publication-month"
class="form-control">
@@ -157,10 +162,6 @@
{%endblock%}
-{%block sidebarcontents%}
-{{display_pheno_dataset_card(species, population, dataset)}}
-{%endblock%}
-
{%block javascript%}
<script type="text/javascript">
@@ -219,13 +220,12 @@
"journal": details[pubmed_id].fulljournalname,
"volume": details[pubmed_id].volume,
"pages": details[pubmed_id].pages,
- "month": months[_date[1].toLowerCase()],
+ "month": _date.length > 1 ? months[_date[1].toLowerCase()] : "jan",
"year": _date[0],
};
};
var update_publication_details = (details) => {
- console.log("Updating with the following details:", details);
Object.entries(details).forEach((entry) => {;
switch(entry[0]) {
case "authors":
@@ -244,41 +244,7 @@
});
};
- var freds_variable = undefined;
- $("#btn-search-pubmed-id").on("click", (event) => {
- event.preventDefault();
- var search_button = event.target;
- var pubmed_id = $("#txt-pubmed-id").val().trim();
- remove_class($("#txt-pubmed-id").parent(), "has-error");
- if(pubmed_id == "") {
- add_class($("#txt-pubmed-id").parent(), "has-error");
- return false;
- }
-
- var flag_pub_details = false;
- var flag_pub_abstract = false;
- var enable_button = () => {
- search_button.disabled = !(flag_pub_details && flag_pub_abstract);
- };
- search_button.disabled = true;
- // Fetch publication details
- $.ajax("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi",
- {
- "method": "GET",
- "data": {"db": "pubmed", "id": pubmed_id, "format": "json"},
- "success": (data, textStatus, jqXHR) => {
- // process and update publication details
- update_publication_details(extract_details(
- pubmed_id, data.result));
- },
- "error": (jqXHR, textStatus, errorThrown) => {},
- "complete": () => {
- flag_pub_details = true;
- enable_button();
- },
- "dataType": "json"
- });
- // Fetch the abstract
+ var fetch_publication_abstract = (pubmed_id, pub_details) => {
$.ajax("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi",
{
"method": "GET",
@@ -289,25 +255,74 @@
"retmode": "xml"
},
"success": (data, textStatus, jqXHR) => {
- // process and update the abstract...
- freds_variable = data;
- console.log("ABSTRACT DETAILS:", data);
update_publication_details({
- "abstract": Array.from(data
- .getElementsByTagName(
- "Abstract")[0]
- .children)
- .map((elt) => {return elt.textContent.trim();})
- .join("\r\n")
- });
+ ...pub_details,
+ ...{
+ "abstract": Array.from(data
+ .getElementsByTagName(
+ "Abstract")[0]
+ .children)
+ .map((elt) => {return elt.textContent.trim();})
+ .join("\r\n")
+ }});
},
"error": (jqXHR, textStatus, errorThrown) => {},
- "complete": (jqXHR, textStatus) => {
- flag_pub_abstract = true;
- enable_button();
- },
+ "complete": (jqXHR, textStatus) => {},
"dataType": "xml"
});
+ };
+
+ var fetch_publication_details = (pubmed_id, complete_thunks) => {
+ error_display = $("#search-pubmed-id-error");
+ error_display.text("");
+ add_class(error_display, "hidden");
+ $.ajax("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi",
+ {
+ "method": "GET",
+ "data": {"db": "pubmed", "id": pubmed_id, "format": "json"},
+ "success": (data, textStatus, jqXHR) => {
+ // process and update publication details
+ hasError = (
+ Object.hasOwn(data, "error") ||
+ Object.hasOwn(data.result[pubmed_id], "error"));
+ if(hasError) {
+ error_display.text(
+ "There was an error fetching a publication with " +
+ "the given PubMed ID! The error received " +
+ "was: '" + (
+ data.error ||
+ data.result[pubmed_id].error) +
+ "'. Please check ID you provided and try " +
+ "again.");
+ remove_class(error_display, "hidden");
+ } else {
+ fetch_publication_abstract(
+ pubmed_id,
+ extract_details(pubmed_id, data.result));
+ }
+ },
+ "error": (jqXHR, textStatus, errorThrown) => {},
+ "complete": () => {
+ complete_thunks.forEach((thunk) => {thunk()});
+ },
+ "dataType": "json"
+ });
+ };
+
+ $("#btn-search-pubmed-id").on("click", (event) => {
+ event.preventDefault();
+ var search_button = event.target;
+ var pubmed_id = $("#txt-pubmed-id").val().trim();
+ remove_class($("#txt-pubmed-id").parent(), "has-error");
+ if(pubmed_id == "") {
+ add_class($("#txt-pubmed-id").parent(), "has-error");
+ return false;
+ }
+
+ search_button.disabled = true;
+ // Fetch publication details
+ fetch_publication_details(pubmed_id,
+ [() => {search_button.disabled = false;}]);
return false;
});
</script>