From bff4b4af7014fbf325b36e5ee149debe8e5dfd47 Mon Sep 17 00:00:00 2001
From: lltommy
Date: Fri, 13 Nov 2020 18:41:08 +0100
Subject: Initial commit: SPARQL playground, which replaces the demo page. Some
queries have to be adjusted once changed metadata schema is live
---
bh20simplewebuploader/static/main.css | 18 ++++++++
bh20simplewebuploader/static/main.js | 84 +++++++++++++++++++++++++++++++++--
2 files changed, 99 insertions(+), 3 deletions(-)
(limited to 'bh20simplewebuploader/static')
diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css
index 76a1755..36c1a33 100644
--- a/bh20simplewebuploader/static/main.css
+++ b/bh20simplewebuploader/static/main.css
@@ -533,3 +533,21 @@ div.status {
border-bottom: 2px solid white;
padding-bottom: 20px;
}
+
+
+
+/* SPARQL playground CSS*/
+#playground {
+margin-left: 20px;
+}
+
+#playground table{
+border: 1px solid black;
+min-height: 400px;
+}
+
+#playground td{
+border: 1px solid black;
+padding-left:10px;
+padding-right:10px;
+}
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index 6cc0d9f..0e642c1 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -83,6 +83,48 @@ function fetchHTMLTable(apiEndPoint) {
});
}
+
+
+// changing access for Demo page
+function demofetchHTMLTable(apiEndPoint) {
+ fetch(scriptRoot + apiEndPoint)
+ .then(response => {
+ return response.json();
+ })
+ .then(data => {
+ htmlString="
Description
"+data[0][0]["description"]+"
"
+ prefix=data[0][1]["prefix"].replaceAll("<","<")
+ htmlString+="Namespace
"+prefix+"
"//prefix to construct correct query @data[0][1]["prefix"]
+ htmlString+="SPARQL query
"+data[0][2]["query"]+"
"
+ htmlString+="SPARQL results table
"
+
+ keys=Object.keys(data[1][0])
+ // Add keys as table headers
+ htmlString+=""
+ for (var j=0; j"+keys[j]+""
+ }
+
+ //Go through the results set given the keys and fill the tail of the table
+ for (var i=0; i"
+ for (var j=0; j"+data[1][i][keys[j]]+""
+ }
+ htmlString+="
"
+ }
+ htmlString=htmlString+"
"
+
+ //Something like this would be nice, hm
+ //htmlString+="Execute this query here"
+
+ document.getElementById("playground").innerHTML = htmlString
+ });
+}
+
+
+
+
/* Fetch record info using a 'global search'. Returns for example
[
@@ -122,14 +164,50 @@ let fetchCountDB = () => {
fetchAPI("/api/getCountDB");
}
-let fetchSEQCountBySpecimen = () => {
- fetchHTMLTable("/api/getSEQCountbySpecimenSource");
+
+//****** SPARQL playground functions // keep old functionality as comments for now, might be transfered elsewhere
+let fetchSEQCountBySpecimen = (toHTML) => {
+ //fetchHTMLTable("/api/getSEQCountbySpecimenSource");
+ demofetchHTMLTable("/api/demoGetSEQCountbySpecimenSource")
}
let fetchSEQCountByLocation = () => {
- fetchHTMLTable("/api/getSEQCountbyLocation");
+ //fetchHTMLTable("/api/getSEQCountbyLocation");
+ demofetchHTMLTable("/api/demoGetSEQCountbyLocation")
+}
+
+//Get authors and there country/contitent where they come from
+let fetchAuthors = () => {
+ demofetchHTMLTable("/api/demoGetAuthors")
+}
+
+// Fetch all institutes/originating labs and their associeted publications
+let fetchInstitutesPublications = () => {
+ demofetchHTMLTable("/api/demoInstitutesPublications")
+}
+
+//Fetch seqeenctechnologies used by continent
+let demoGetSEQCountbytechContinent = () => {
+ demofetchHTMLTable("/api/demoGetSEQCountbytechContinent")
+}
+
+let demoGetSEQCountbytech = () => {
+ demofetchHTMLTable("/api/demoGetSEQCountbytech")
+}
+
+let demoGetSequencePerDate = () => {
+ demofetchHTMLTable('/api/demoGetSequencePerDate')
+}
+
+let demoLocationGps = () => {
+ demofetchHTMLTable("/api/demoLocationGps")
+}
+
+let getNYsamples = () => {
+ demofetchHTMLTable("/api/getNYsamples")
}
+//old/unused functions
let fetchSEQCountByTech = () => {
fetchHTMLTable("/api/getSEQCountbytech");
}
--
cgit v1.2.3