From 33364c8a23105baf6a138216082c5451424e71fb Mon Sep 17 00:00:00 2001
From: meyer <meyer@astron.nl>
Date: Tue, 14 Jul 2020 08:43:18 +0200
Subject: [PATCH] render VO results properly

---
 src/components/query/ASTRONVOResults.js | 15 ++++----
 src/components/query/QueryCatalogs.js   | 49 +------------------------
 2 files changed, 8 insertions(+), 56 deletions(-)

diff --git a/src/components/query/ASTRONVOResults.js b/src/components/query/ASTRONVOResults.js
index ce2c475..a16cbdf 100644
--- a/src/components/query/ASTRONVOResults.js
+++ b/src/components/query/ASTRONVOResults.js
@@ -17,17 +17,19 @@ export default function ASTRONVOResults({ catalog }) {
                 <InputGroup.Checkbox />
               </InputGroup>
             </th> */}
-            <th>Title</th>
+            <th>Collection</th>
             <th>RA</th>
             <th>Dec</th>
             <th>fov</th>
             <th>Data Product Type</th>
             <th>Calibration Level</th>
+            <th>Size</th>
             <th>Link to data</th>
           </tr>
         </thead>
         <tbody>
           {queryMap.get(catalog).results.query_results.map((result) => {
+            let size = Number((result.size / 1024).toFixed(1));
             return (
               <tr key={result.result}>
                 {/* <th>
@@ -35,19 +37,16 @@ export default function ASTRONVOResults({ catalog }) {
                     <InputGroup.Checkbox />
                   </InputGroup>
                 </th> */}
-                <td>{result.title}</td>
+                <td>{result.obs_collection}</td>
                 <td>{result.ra}</td>
                 <td>{result.dec}</td>
                 <td>{result.fov}</td>
                 <td>{result.dataproduct_type}</td>
                 <td>{result.calibration_level}</td>
+                <td>{size} MB</td>
                 <td>
-                  <a
-                    href={result.url}
-                    target="_blank"
-                    rel="noopener noreferrer"
-                  >
-                    View data
+                  <a href={result.url} rel="noopener noreferrer" download>
+                    Download
                   </a>
                 </td>
               </tr>
diff --git a/src/components/query/QueryCatalogs.js b/src/components/query/QueryCatalogs.js
index 50ea3d6..f88d6e0 100644
--- a/src/components/query/QueryCatalogs.js
+++ b/src/components/query/QueryCatalogs.js
@@ -25,54 +25,6 @@ export default function QueryCatalogs() {
     let gui = config.query_schema.name;
     const queries = parseQueryForm(gui, formData, catalogs);
 
-    // queries.forEach((query) => {
-    //   let url =
-    //     api_host + "query/create-query/?" + "archive_uri=" + query.catalog;
-    //   axios.get(url).then((response) => {
-    //     queryMap.set(query.catalog, {
-    //       catalog: query.catalog,
-    //       dataset_uri: response.data.query_input[0].dataset,
-    //       access_url: response.data.query_input[0].service_url,
-    //       catalogquery: response.data.query_input[0].query,
-    //       status: "fetching",
-    //       results: null,
-    //     });
-    //     console.log("CatalogQuery:", queryMap.get(query.catalog).catalogquery);
-    //     let queryUrl =
-    //       api_host +
-    //       "query/run-query/?" +
-    //       "dataset_uri=" +
-    //       queryMap.get(query.catalog).dataset_uri +
-    //       "&access_url=" +
-    //       queryMap.get(query.catalog).access_url +
-    //       "&query=" +
-    //       queryMap.get(query.catalog).catalogquery;
-
-    //     axios
-    //       .get(queryUrl)
-    //       .then((queryResponse) => {
-    //         queryMap.set(query.catalog, {
-    //           catalog: query.catalog,
-    //           dataset_uri: response.data.query_input[0].dataset,
-    //           access_url: response.data.query_input[0].service_url,
-    //           catalogquery: response.data.query_input[0].query,
-    //           status: "fetched",
-    //           results: queryResponse.data,
-    //         });
-    //       })
-    //       .catch(() => {
-    //         queryMap.set(query.catalog, {
-    //           catalog: query.catalog,
-    //           dataset_uri: response.data.query_input[0].dataset,
-    //           access_url: response.data.query_input[0].service_url,
-    //           catalogquery: response.data.query_input[0].query,
-    //           status: "error",
-    //           results: null,
-    //         });
-    //       });
-    //   });
-    // });
-
     // Ideally query for each catalog is sent to ESAP API Gateway, and query results is returned
     // This is under development in the backend at the moment
     queries.forEach((query) => {
@@ -135,6 +87,7 @@ export default function QueryCatalogs() {
       ></Form>
       {Array.from(queryMap.keys()).map((catalog) => {
         const details = queryMap.get(catalog);
+        console.log("Details:", details);
         console.log("Results:", details.results);
         return (
           <div key={catalog} className="mt-3">
-- 
GitLab