From 8af6712e90e6e6d1ff5c3db8a410f47211fb921c Mon Sep 17 00:00:00 2001
From: Gareth Hughes <gareth.hughes@cta-observatory.org>
Date: Mon, 10 Jan 2022 15:45:59 +0100
Subject: [PATCH] initial commit for CONCORDIA

---
 src/components/CONCORDIA.js                   | 13 ++++++
 src/components/query/QueryCatalogs.js         |  3 ++
 .../query_results/CONCORDIAResults.js         | 45 +++++++++++++++++++
 .../services/query_results/QueryResults.js    |  3 ++
 src/utils/form/parseCONCORDIAForm.js          | 21 +++++++++
 src/utils/form/parseQueryForm.js              |  3 ++
 6 files changed, 88 insertions(+)
 create mode 100644 src/components/CONCORDIA.js
 create mode 100644 src/components/services/query_results/CONCORDIAResults.js
 create mode 100644 src/utils/form/parseCONCORDIAForm.js

diff --git a/src/components/CONCORDIA.js b/src/components/CONCORDIA.js
new file mode 100644
index 0000000..a878354
--- /dev/null
+++ b/src/components/CONCORDIA.js
@@ -0,0 +1,13 @@
+import React from "react";
+
+export default function CONCORDIA() {
+  return (
+    <div className="embed-responsive embed-responsive-16by9">
+      <iframe
+        title="concordia"
+        className="embed-responsive-item"
+        allowFullScreen
+      ></iframe>
+    </div>
+  );
+}
diff --git a/src/components/query/QueryCatalogs.js b/src/components/query/QueryCatalogs.js
index 6bd0909..1a58339 100644
--- a/src/components/query/QueryCatalogs.js
+++ b/src/components/query/QueryCatalogs.js
@@ -48,6 +48,9 @@ export default function QueryCatalogs() {
       case "ivoa":
         setConfigName("esap_ivoa");
         break;
+      case "esap_concordia":
+        setConfigName("esap_concordia");
+        break;
 
       default:
         break;
diff --git a/src/components/services/query_results/CONCORDIAResults.js b/src/components/services/query_results/CONCORDIAResults.js
new file mode 100644
index 0000000..2bd3fe1
--- /dev/null
+++ b/src/components/services/query_results/CONCORDIAResults.js
@@ -0,0 +1,45 @@
+import React, { useContext } from "react";
+import { Table, Alert, Form } from "react-bootstrap";
+import { QueryContext } from "../../../contexts/QueryContext";
+import LoadingSpinner from "../../LoadingSpinner";
+import Paginate from "../../Paginate";
+import AddToBasket from "../../basket/AddToBasketCheckBox";
+
+export default function DIRACResults({ catalog }) {
+  const context = useContext(QueryContext);
+  const { queryMap, page, setPage } = context;
+  const regex = /(<([^>]+)>)/ig;
+
+  if (!context.queryMap) return null;
+
+  if (context.queryMap.get(catalog).status === "fetched") {
+    if (context.queryMap.get(catalog).length === 0)
+      return <Alert variant="warning">No matching results found!</Alert>;
+    else if (catalog === "concordia") {
+      const concordiaResults = queryMap.get("concordia").results.results.map((hits, counter) => (
+
+           <>
+           Job submitted:
+           <br/>
+           ID {hits.JobID}
+           <br/>
+           </>
+
+
+      ));
+
+      return (
+
+       <>
+         {concordiaResults}
+       </>
+
+      ); 
+
+    }
+  }
+  else {
+    return <LoadingSpinner />;
+  }
+}
+
diff --git a/src/components/services/query_results/QueryResults.js b/src/components/services/query_results/QueryResults.js
index 79c2e35..ed8c7ec 100644
--- a/src/components/services/query_results/QueryResults.js
+++ b/src/components/services/query_results/QueryResults.js
@@ -7,6 +7,7 @@ import LOFARResults from "./LOFARResults";
 import RucioResults from "./RucioResults";
 import ZenodoResults from "./ZenodoResults";
 import SampResults from "./SampResults";
+import CONCORDIAResults from "./CONCORDIAResults";
 
 export default function QueryResults({ catalog }) {
   switch (catalog) {
@@ -26,6 +27,8 @@ export default function QueryResults({ catalog }) {
       return <RucioResults catalog={catalog} />;
     case "zenodo":
       return <ZenodoResults catalog={catalog} />;
+    case "concordia":
+      return <CONCORDIAResults catalog={catalog} />;
     case "samp":
       return <SampResults catalog={catalog} />;
     default:
diff --git a/src/utils/form/parseCONCORDIAForm.js b/src/utils/form/parseCONCORDIAForm.js
new file mode 100644
index 0000000..4b860e7
--- /dev/null
+++ b/src/utils/form/parseCONCORDIAForm.js
@@ -0,0 +1,21 @@
+export default function parseCONCORDIAForm(formData) {
+  let formInput = Object.entries(formData);
+
+  let query = "";
+
+  for (let [key, value] of formInput) {
+    query += `${`${query}` ? "&" : ""}` + key + "=" + value;
+  }
+
+  let esapquery = [
+    query,
+    "archive_uri=esap_concordia",
+    `catalog=concordia`,
+  ].join("&");
+
+  console.log("CONCORDIA Job Submission (helloworld):", query);
+  return [{
+    catalog: "concordia",
+    esapquery: esapquery
+  }];
+}
diff --git a/src/utils/form/parseQueryForm.js b/src/utils/form/parseQueryForm.js
index 9a8b196..d2cf089 100644
--- a/src/utils/form/parseQueryForm.js
+++ b/src/utils/form/parseQueryForm.js
@@ -7,6 +7,7 @@ import parseASTRONVOForm from "./parseASTRONVOForm";
 import parseRucioForm from "./parseRucioForm";
 import parseZenodoForm from "./parseZenodoForm";
 import parseMultipleArchivesForm from "./parseMultipleArchivesForm";
+import parseCONCORDIAForm from "./parseCONCORDIAForm";
 
 export default function parseQueryForm(gui, formData) {
   switch (gui) {
@@ -28,6 +29,8 @@ export default function parseQueryForm(gui, formData) {
         return parseZenodoForm(formData);
     case "multiple_archives":
         return parseMultipleArchivesForm(formData);
+    case "concordia":
+        return parseCONCORDIAForm(formData);
     default:
       return null;
   }
-- 
GitLab