- {getSlice(currentPage).map((indexedEntry, n) =>
-
showLightboxEntry(indexedEntry.index)}>
- {indexedEntry.plot}
-
- )}
+ };
+
+ const getSlice = (currentPage) => {
+ return getFilteredEntries().slice(
+ (currentPage - 1) * plotsPerPage,
+ currentPage * plotsPerPage,
+ );
+ };
+
+ return (
+
+
+
+
+
+ {currentPage > 1 ? (
+
+ ) : (
+
Prev
+ )}
+
+
+ Page
+ setCurrentPage(e.target.value)}
+ />
+ /{totalPages()}
+
+
+ {currentPage < totalPages() ? (
+
+ ) : (
+
Next
+ )}
+
+
+
+ {displayBandSelector() ? (
+
+ ) : (
+ ""
+ )}
+
+
+
+ {currentPage >= 1 && currentPage <= totalPages()
+ ? ""
+ : "Invalid page number"}
+ {getSlice(currentPage).map((indexedEntry, n) => (
+
showLightboxEntry(indexedEntry.index)}
+ >
+ {indexedEntry.plot}
+
+ ))}
+
+ {inLightbox ? (
+
+
+
+ {displayedEntry > 0 ? (
+
+ ) : (
+ ""
+ )}
+
+
+
+ {getFilteredEntries()[displayedEntry].plot}
- { inLightbox ?
-
-
-
- {displayedEntry > 0 ?
-
- : "" }
-
-
-
- {plotEntries[displayedEntry].plot}
-
-
-
- {displayedEntry < (plotEntries.length - 1) ?
-
- : "" }
-
-
- : ""}
+
+
+ {displayedEntry < plotEntries.length - 1 ? (
+
+ ) : (
+ ""
+ )}
+
- )
-
+ ) : (
+ ""
+ )}
+
+ );
}
diff --git a/app/_components/selectionDropdown.js b/app/_components/selectionDropdown.js
index b77350a..2a512d8 100644
--- a/app/_components/selectionDropdown.js
+++ b/app/_components/selectionDropdown.js
@@ -1,30 +1,25 @@
-'use client'
-
-
-import React from 'react'
-import {useState} from 'react'
-
-
-export default function SelectionDropdown({contents, title, initiallyOpen = false}) {
-
- const [showContents, setShowContents] = useState(initiallyOpen)
-
-
- const toggle = () => {
- setShowContents(!showContents)
- }
-
-
- return (
-
-
- {showContents ?
- contents
- : ""}
-
- )
-
+"use client";
+
+import React from "react";
+import { useState } from "react";
+
+export default function SelectionDropdown({
+ contents,
+ title,
+ initiallyOpen = false,
+}) {
+ const [showContents, setShowContents] = useState(initiallyOpen);
+
+ const toggle = () => {
+ setShowContents(!showContents);
+ };
+
+ return (
+
+
+ {showContents ? contents : ""}
+
+ );
}
-
diff --git a/app/_lib/dataIdFuncs.js b/app/_lib/dataIdFuncs.js
index 5f25101..49c1cb0 100644
--- a/app/_lib/dataIdFuncs.js
+++ b/app/_lib/dataIdFuncs.js
@@ -1,38 +1,39 @@
-
export default function DataIdSortFunc(dataIdA, dataIdB) {
+ const bandsOrder = ["u", "g", "r", "i", "z", "y"];
- const bandsOrder = ['u', 'g', 'r', 'i', 'z', 'y']
-
- if('tract' in dataIdA && 'tract' in dataIdB) {
- const tract_comparison = dataIdA.tract - dataIdB.tract
- if(tract_comparison != 0) {
- return tract_comparison
- }
+ if ("tract" in dataIdA && "tract" in dataIdB) {
+ const tract_comparison = dataIdA.tract - dataIdB.tract;
+ if (tract_comparison != 0) {
+ return tract_comparison;
}
+ }
- if('visit' in dataIdA && 'visit' in dataIdB) {
- const visit_comparison = dataIdA.visit - dataIdB.visit
- if(visit_comparison != 0) {
- return visit_comparison
- }
+ if ("visit" in dataIdA && "visit" in dataIdB) {
+ const visit_comparison = dataIdA.visit - dataIdB.visit;
+ if (visit_comparison != 0) {
+ return visit_comparison;
}
+ }
- if('band' in dataIdA && 'band' in dataIdB) {
- const band_comparison = bandsOrder.indexOf(dataIdA.band) - bandsOrder.indexOf(dataIdB.band)
- if(band_comparison != 0) {
- return band_comparison
- }
+ if ("band" in dataIdA && "band" in dataIdB) {
+ const band_comparison =
+ bandsOrder.indexOf(dataIdA.band) - bandsOrder.indexOf(dataIdB.band);
+ if (band_comparison != 0) {
+ return band_comparison;
}
-
- if('physical_filter' in dataIdA && 'physical_filter' in dataIdB) {
- const physical_filter_comparison = bandsOrder.indexOf(dataIdA.physical_filter[0]) - bandsOrder.indexOf(dataIdB.physical_filter[0])
- if(physical_filter_comparison != 0) {
- return physical_filter_comparison
- }
+ }
+
+ if ("physical_filter" in dataIdA && "physical_filter" in dataIdB) {
+ const physical_filter_comparison =
+ bandsOrder.indexOf(dataIdA.physical_filter[0]) -
+ bandsOrder.indexOf(dataIdB.physical_filter[0]);
+ if (physical_filter_comparison != 0) {
+ return physical_filter_comparison;
}
+ }
- /* if none of these dimensions are available */
- return 0
+ /* if none of these dimensions are available */
+ return 0;
}
-export { DataIdSortFunc }
+export { DataIdSortFunc };
diff --git a/app/_lib/summaries.js b/app/_lib/summaries.js
index 01e34a3..4502ba4 100644
--- a/app/_lib/summaries.js
+++ b/app/_lib/summaries.js
@@ -1,12 +1,13 @@
+import {
+ S3Client,
+ ListObjectsV2Command,
+ GetObjectCommand,
+} from "@aws-sdk/client-s3";
+const fs = require("fs");
+const zlib = require("zlib");
-import { S3Client, ListObjectsV2Command, GetObjectCommand} from "@aws-sdk/client-s3"
-
-const fs = require('fs');
-const zlib = require('zlib');
-
-const { readFile } = require("fs/promises")
-
+const { readFile } = require("fs/promises");
/*
* This function defines which repo names are "special" such that users should be sent to the "More
@@ -15,206 +16,212 @@ const { readFile } = require("fs/promises")
*
*/
function GetCollectionListURLFromRepo(repoName) {
+ const moreRepos = ["decasu"];
- const moreRepos = ['decasu']
-
- return moreRepos.includes(repoName) ? '/more' : ''
-
+ return moreRepos.includes(repoName) ? "/more" : "";
}
function GetButlerURL(repoName) {
+ const repoUrls = (() => {
+ try {
+ return JSON.parse(process.env.REPO_URLS);
+ } catch (err) {
+ console.error(`Could not parse REPO_URLS env var, ${err}`);
+ console.error(`REPO_URLS='${process.env.REPO_URLS}'`);
+ return {};
+ }
+ })();
- const repoUrls = (() => {
- try {
- return JSON.parse(process.env.REPO_URLS)
- } catch (err) {
- console.error(`Could not parse REPO_URLS env var, ${err}`)
- console.error(`REPO_URLS='${process.env.REPO_URLS}'`)
- return {}
- }
- })()
-
- return repoUrls[repoName]
-
+ return repoUrls[repoName];
}
function GetClient() {
-
- const client = new S3Client({
- endpoint: process.env.BUCKET_URL,
- region: "s3dfrgw",
- forcePathStyle: true,
- credentials: {
- accessKeyId: process.env.S3_KEY,
- secretAccessKey: process.env.S3_SECRET,
- },
- })
-
- return client
+ const client = new S3Client({
+ endpoint: process.env.BUCKET_URL,
+ region: "s3dfrgw",
+ forcePathStyle: true,
+ credentials: {
+ accessKeyId: process.env.S3_KEY,
+ secretAccessKey: process.env.S3_SECRET,
+ },
+ });
+
+ return client;
}
async function _GetSummaryS3(repoName, collectionName) {
-
- const client = GetClient()
- const command = new GetObjectCommand({
- Bucket: process.env.BUCKET_NAME,
- Key: `${encodeURIComponent(repoName)}/collection_${encodeURIComponent(collectionName)}.json.gz`
- })
-
- try {
- const response = await client.send(command)
- const gzData = await response.Body.transformToByteArray()
- const collectionData = JSON.parse(zlib.gunzipSync(gzData))
- return collectionData
-
- } catch (err) {
- console.error(err)
- return {}
- }
-
+ const client = GetClient();
+ const command = new GetObjectCommand({
+ Bucket: process.env.BUCKET_NAME,
+ Key: `${encodeURIComponent(repoName)}/collection_${encodeURIComponent(collectionName)}.json.gz`,
+ });
+
+ try {
+ const response = await client.send(command);
+ const gzData = await response.Body.transformToByteArray();
+ const collectionData = JSON.parse(zlib.gunzipSync(gzData));
+ return collectionData;
+ } catch (err) {
+ console.error(err);
+ return {};
+ }
}
async function GetSummary(repoName, collectionName) {
-
- if(!process.env.ENABLE_TEST_IMAGES) {
- return await _GetSummaryS3(repoName, collectionName)
-
- } else {
- const gzData = await readFile(`test_assets/summaries/${encodeURIComponent(repoName)}/collection_${encodeURIComponent(collectionName)}.json.gz`)
- const collectionData = JSON.parse(zlib.gunzipSync(gzData))
- return collectionData
- }
-
+ if (!process.env.ENABLE_TEST_IMAGES) {
+ return await _GetSummaryS3(repoName, collectionName);
+ } else {
+ const gzData = await readFile(
+ `test_assets/summaries/${encodeURIComponent(repoName)}/collection_${encodeURIComponent(collectionName)}.json.gz`,
+ );
+ const collectionData = JSON.parse(zlib.gunzipSync(gzData));
+ return collectionData;
+ }
}
async function _ListSummariesS3(repoName) {
-
- const client = GetClient()
- const command = new ListObjectsV2Command({
- Bucket: process.env.BUCKET_NAME,
- Prefix: `${encodeURIComponent(repoName)}/`,
- });
-
- try {
- let isTruncated = true;
-
- let filenameArrays = []
-
- while (isTruncated) {
- const { Contents, IsTruncated, NextContinuationToken } =
- await client.send(command)
- if(Contents) {
- filenameArrays.push(Contents)
- }
- isTruncated = IsTruncated
- command.input.ContinuationToken = NextContinuationToken
- }
- return filenameArrays.flat()
- } catch (err) {
- console.log(err)
- return []
+ const client = GetClient();
+ const command = new ListObjectsV2Command({
+ Bucket: process.env.BUCKET_NAME,
+ Prefix: `${encodeURIComponent(repoName)}/`,
+ });
+
+ try {
+ let isTruncated = true;
+
+ let filenameArrays = [];
+
+ while (isTruncated) {
+ const { Contents, IsTruncated, NextContinuationToken } =
+ await client.send(command);
+ if (Contents) {
+ filenameArrays.push(Contents);
+ }
+ isTruncated = IsTruncated;
+ command.input.ContinuationToken = NextContinuationToken;
}
-
+ return filenameArrays.flat();
+ } catch (err) {
+ console.log(err);
+ return [];
+ }
}
async function _ListSummariesFilesystem(repoName) {
- const repoDir = `test_assets/summaries/${encodeURIComponent(repoName)}`
- try {
- console.log(fs.readdirSync(repoDir))
- return fs.readdirSync(repoDir).filter(
- (filename) => filename.match("^collection_(.*).json.gz$"));
- } catch (error) {
- return []
- }
+ const repoDir = `test_assets/summaries/${encodeURIComponent(repoName)}`;
+ try {
+ return fs
+ .readdirSync(repoDir)
+ .filter((filename) => filename.match("^collection_(.*).json.gz$"));
+ } catch (error) {
+ return [];
+ }
}
async function ListSummaries(repo) {
+ const decodeFilename = (filename) => {
+ const uriEncodedCollection = filename.match("collection_(.*).json.gz")[1];
+ return decodeURIComponent(uriEncodedCollection);
+ };
- const decodeFilename = (filename) => {
- const uriEncodedCollection = filename.match("collection_(.*).json.gz")[1]
- return decodeURIComponent(uriEncodedCollection)
- }
-
- const repoUrls = (() => {
- try {
- return JSON.parse(process.env.REPO_URLS)
- } catch (err) {
- console.error(`Could not parse REPO_URLS env var, ${err}`)
- console.error(`REPO_URLS='${process.env.REPO_URLS}'`)
- return {}
- }
- })()
-
- const repos = repo ? [repo] : Object.keys(repoUrls)
-
- if(!process.env.ENABLE_TEST_IMAGES) {
- const res = await Promise.all(repos.map(repo =>
- {
- return _ListSummariesS3(repo).then((entries) => entries.map(entry => ({repo: repo, collection: decodeFilename(entry.Key), filename: entry.Key, lastModified: entry.LastModified})))
- }))
- return res.flat()
- } else {
- const res = await Promise.all(
- repos.map(repo => _ListSummariesFilesystem(repo)
- .then((filenames) => filenames.map(filename => ({repo: repo, collection: decodeFilename(filename), filename: filename,
- lastModified: new Date(2025, 2, 10, 2, 30)}))))
- )
- return res.flat()
+ const repoUrls = (() => {
+ try {
+ return JSON.parse(process.env.REPO_URLS);
+ } catch (err) {
+ console.error(`Could not parse REPO_URLS env var, ${err}`);
+ console.error(`REPO_URLS='${process.env.REPO_URLS}'`);
+ return {};
}
-
+ })();
+
+ const repos = repo ? [repo] : Object.keys(repoUrls);
+
+ if (!process.env.ENABLE_TEST_IMAGES) {
+ const res = await Promise.all(
+ repos.map((repo) => {
+ return _ListSummariesS3(repo).then((entries) =>
+ entries.map((entry) => ({
+ repo: repo,
+ collection: decodeFilename(entry.Key),
+ filename: entry.Key,
+ lastModified: entry.LastModified,
+ })),
+ );
+ }),
+ );
+ return res.flat();
+ } else {
+ const res = await Promise.all(
+ repos.map((repo) =>
+ _ListSummariesFilesystem(repo).then((filenames) =>
+ filenames.map((filename) => ({
+ repo: repo,
+ collection: decodeFilename(filename),
+ filename: filename,
+ lastModified: new Date(2025, 2, 10, 2, 30),
+ })),
+ ),
+ ),
+ );
+ return res.flat();
+ }
}
async function ListReports() {
- return []
+ return [];
- const client = GetClient()
+ const client = GetClient();
- const command = new ListObjectsV2Command({
- Bucket: process.env.BUCKET_NAME,
- Prefix: `reports/`
- });
+ const command = new ListObjectsV2Command({
+ Bucket: process.env.BUCKET_NAME,
+ Prefix: `reports/`,
+ });
- try {
- let isTruncated = true;
-
- let filenameArrays = []
-
- while (isTruncated) {
- const { Contents, IsTruncated, NextContinuationToken } =
- await client.send(command)
- if(Contents) {
- filenameArrays.push(Contents.map((entry) => entry.Key))
- }
- isTruncated = IsTruncated
- command.input.ContinuationToken = NextContinuationToken
- }
- return filenameArrays.flat()
- } catch (err) {
- console.log(err)
- return []
- }
-
-}
-
-async function GetReport(filename) {
+ try {
+ let isTruncated = true;
- const client = GetClient()
- const command = new GetObjectCommand({
- Bucket: process.env.BUCKET_NAME,
- Key: `reports/${filename}`
- })
+ let filenameArrays = [];
- try {
- const response = await client.send(command)
- const gzData = await response.Body.transformToByteArray()
- const collectionData = JSON.parse(zlib.gunzipSync(gzData))
- return collectionData
-
- } catch (err) {
- console.error(err)
- return {}
+ while (isTruncated) {
+ const { Contents, IsTruncated, NextContinuationToken } =
+ await client.send(command);
+ if (Contents) {
+ filenameArrays.push(Contents.map((entry) => entry.Key));
+ }
+ isTruncated = IsTruncated;
+ command.input.ContinuationToken = NextContinuationToken;
}
+ return filenameArrays.flat();
+ } catch (err) {
+ console.log(err);
+ return [];
+ }
+}
+async function GetReport(filename) {
+ const client = GetClient();
+ const command = new GetObjectCommand({
+ Bucket: process.env.BUCKET_NAME,
+ Key: `reports/${filename}`,
+ });
+
+ try {
+ const response = await client.send(command);
+ const gzData = await response.Body.transformToByteArray();
+ const collectionData = JSON.parse(zlib.gunzipSync(gzData));
+ return collectionData;
+ } catch (err) {
+ console.error(err);
+ return {};
+ }
}
-export {GetCollectionListURLFromRepo, ListSummaries, GetSummary, ListReports, GetReport, GetButlerURL, GetClient}
+export {
+ GetCollectionListURLFromRepo,
+ ListSummaries,
+ GetSummary,
+ ListReports,
+ GetReport,
+ GetButlerURL,
+ GetClient,
+};