Skip to content

Commit

Permalink
Add band selection to visit and tract plots.
Browse files Browse the repository at this point in the history
Also make the band selector not appear when band is not in the
dimensions.
  • Loading branch information
ctslater committed Dec 5, 2024
1 parent 16ffe8e commit bf02568
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/_components/plotPager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export default function PlotPager({plotEntries, plotsPerPage = 10}) {
}
}, [selectedBands])

const displayBandSelector = () => {
const dimensions = new Set(plotEntries.map((entry) => Object.keys(entry.dataId)).flat())
return (dimensions.has('band'))
}

const previousPage = () => {
if(currentPage > 1) {
Expand Down Expand Up @@ -99,7 +103,7 @@ export default function PlotPager({plotEntries, plotsPerPage = 10}) {
</div>
</div>
<div className="m-2">
<BandSelector selectedBands={selectedBands} onBandUpdated={onBandUpdated} />
{ displayBandSelector() ? <BandSelector selectedBands={selectedBands} onBandUpdated={onBandUpdated} /> : "" }
</div>
</div>
<div className="flex flex-row flex-wrap justify-center">
Expand Down
2 changes: 1 addition & 1 deletion app/tract/[repo]/[collection]/[tract]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default async function Collection({params, searchParams}) {
<div key={n}>
<div className="m-8 text-xl font-medium border-b-2 border-black">{plotGroup}_*</div>
<PlotPager plotsPerPage={6} plotEntries={findMatchingPlots(plotEntries, plotGroup).map((entry, n) =>
({dataId: {}, plot: <PlotDisplay key={n} plotEntry={ ({...entry, repo: repo}) } showDataId={false} showDatasetType={true} /> }))} />
({dataId: JSON.parse(entry.dataId), plot: <PlotDisplay key={n} plotEntry={ ({...entry, repo: repo}) } showDataId={false} showDatasetType={true} /> }))} />
<div className="clear-both"></div>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion app/visit/[repo]/[collection]/[visit]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default async function Collection({params, searchParams}) {
<div key={n}>
<div className="m-8 text-xl font-medium border-b-2 border-black">{plotGroup}_*</div>
<PlotPager plotsPerPage={6} plotEntries={findMatchingPlots(plotEntries, plotGroup).map((entry, n) =>
({dataId: {}, plot: <PlotDisplay key={n} plotEntry={ ({...entry, repo: repo}) } showDataId={false} showDatasetType={true} />})
({dataId: JSON.parse(entry.dataId), plot: <PlotDisplay key={n} plotEntry={ ({...entry, repo: repo}) } showDataId={false} showDatasetType={true} />})
)} />
<div className="clear-both"></div>
</div>
Expand Down

0 comments on commit bf02568

Please sign in to comment.