-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lsst-dm/tickets/DM-44957
DM-44957: Initial development of v3
- Loading branch information
Showing
21 changed files
with
656 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
import { useState } from 'react' | ||
import Link from "next/link"; | ||
import { useSearchParams } from "next/navigation"; | ||
|
||
|
||
export default function TabNav({panes}) { | ||
const searchParams = useSearchParams(); | ||
|
||
const [currentPane, setCurrentPane] = useState(searchParams.get("t") || 0) | ||
|
||
|
||
const buttonClass = "p-2 border-t-2 border-x-2 float-left w-48 text-center hover:underline hover:cursor-pointer mx-2" | ||
const buttons = panes.map((pane, n) => ( | ||
<Link replace scroll={false} key={n} href={`?t=${n}`} onClick={() => setCurrentPane(n)}> | ||
<div className={currentPane == n ? buttonClass + " font-bold" : buttonClass} > | ||
{pane.title} | ||
</div> | ||
</Link> | ||
)) | ||
|
||
return ( | ||
<div className="p-4"> | ||
<div className="flow-root"> | ||
{buttons} | ||
</div> | ||
<div className="border-2 p-2 inline-block"> | ||
{panes[currentPane].content} | ||
</div> | ||
</div> | ||
|
||
) | ||
|
||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
import React from 'react'; | ||
|
||
export default async function PlotDisplay({plotEntry, showDataId = true, showDatasetType = false, showPermalink = false}) { | ||
|
||
const {instrument, skymap, ...dataId} = JSON.parse(plotEntry.dataId) | ||
const uuid = plotEntry.id | ||
const repo = plotEntry.repo | ||
const permalink = plotEntry.permalink ?? '' | ||
const datasetType = plotEntry.datasetType ?? '' | ||
|
||
const splitType = [...datasetType.matchAll(/[a-zA-Z0-9]*(_|$)/g)].map((x) => x[0]) | ||
const typeWithWbr = splitType.join('\u00ad') | ||
/* | ||
const typeWithWbr = splitType.map((x) => [x, <wbr/>]).flat() | ||
console.log(typeWithWbr) | ||
*/ | ||
|
||
const dataIdString = Object.entries(dataId).map(([k,v]) => `${k}: ${v}`).join(', ') | ||
|
||
return ( | ||
<div className="m-2"> | ||
<div className="text-1xl my-5 text-wrap float-left"> | ||
{ showDataId ? dataIdString : "" } | ||
{ showDatasetType ? typeWithWbr : "" } | ||
</div> | ||
{ showPermalink ? <div className="text-1xl float-right"><a href={`${process.env.BASE_URL ?? ''}/${permalink}`}>Plot link</a></div> : "" } | ||
<img src={`${process.env.BASE_URL ?? '' }/image/${encodeURIComponent(repo)}/${uuid}`} /> | ||
</div> | ||
|
||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
'use client' | ||
|
||
import React from 'react'; | ||
import { useState } from 'react' | ||
|
||
export default function PlotPager({plotEntries, plotsPerPage = 10}) { | ||
|
||
|
||
const [currentPage, setCurrentPage] = useState(1) | ||
const [inLightbox, setInLightbox] = useState(false) | ||
const [displayedEntry, setDisplayedEntry] = useState(0) | ||
|
||
const totalPages = Math.ceil(plotEntries.length/plotsPerPage) | ||
|
||
|
||
const previousPage = () => { | ||
if(currentPage > 1) { | ||
setCurrentPage(currentPage - 1) | ||
} | ||
} | ||
|
||
const nextPage = () => { | ||
if(currentPage < totalPages) { | ||
setCurrentPage(currentPage + 1) | ||
} | ||
} | ||
|
||
const showLightboxEntry = (entry) => { | ||
setDisplayedEntry(entry) | ||
setInLightbox(true) | ||
} | ||
|
||
const exitLightbox = () => { | ||
setInLightbox(false) | ||
} | ||
const doNothing = (e) => { | ||
e.stopPropagation(); | ||
} | ||
|
||
const advanceLeft = (e) => { | ||
e.stopPropagation(); | ||
if(displayedEntry > 0) { | ||
setDisplayedEntry(displayedEntry - 1) | ||
} | ||
} | ||
|
||
const advanceRight = (e) => { | ||
e.stopPropagation(); | ||
if(displayedEntry < (plotEntries.length - 1)) { | ||
setDisplayedEntry(displayedEntry + 1) | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<div className="flex flex-row justify-center"> | ||
<div className="m-3"> | ||
{ currentPage > 1 ? <button className="p-2 rounded-md text-white bg-sky-600" onClick={previousPage}>Prev</button> : | ||
<div>Prev</div> } | ||
</div> | ||
<div className="m-3">Page {currentPage}/{totalPages}</div> | ||
<div className="m-3"> | ||
{ currentPage < totalPages ? <button className="p-2 rounded-md text-white bg-sky-600" onClick={nextPage}>Next</button> : | ||
<div>Next</div> } | ||
</div> | ||
</div> | ||
<div className="flex flex-row flex-wrap justify-center"> | ||
{plotEntries.slice((currentPage - 1) * plotsPerPage, currentPage * plotsPerPage).map((plotEntry, n) => | ||
<div key={n} className=" w-[28rem] p-1 m-0" onClick={() => showLightboxEntry(n + (currentPage - 1) * plotsPerPage)}> | ||
{plotEntry} | ||
</div> | ||
)} | ||
</div> | ||
{ inLightbox ? | ||
<div className="fixed top-0 left-0 w-screen h-screen bg-slate-500/75" onClick={exitLightbox}> | ||
<div className="h-32"></div> | ||
<div className="w-1/4 float-left h-1"> | ||
{displayedEntry > 0 ? | ||
<div className="float-right flex items-center justify-center m-8 h-64 w-16 bg-indigo-100 hover:bg-indigo-600 hover:cursor-pointer" onClick={advanceLeft}> | ||
<div><<</div> | ||
</div> | ||
: "" } | ||
</div> | ||
<div className="w-1/2 float-left bg-white" onClick={doNothing}> | ||
{plotEntries[displayedEntry]} | ||
</div> | ||
<div className="w-1/4 float-left"> | ||
{displayedEntry < (plotEntries.length - 1) ? | ||
<div className="flex items-center justify-center m-8 h-64 w-16 bg-indigo-100 hover:bg-indigo-600 hover:cursor-pointer" onClick={advanceRight}> | ||
<div>>></div> | ||
</div> | ||
: "" } | ||
</div> | ||
</div> | ||
: ""} | ||
</div> | ||
) | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.