Skip to content

Commit f91febe

Browse files
authored
split nc option (#502)
* split nc option * nc badge
1 parent 0389fa6 commit f91febe

3 files changed

Lines changed: 39 additions & 27 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
[![][docs-dev-img]][docs-dev-url]
1212
[![Zarr](https://img.shields.io/badge/Zarr-Compatible-e34b75)](https://zarr.dev/)
13+
[![NetCDF4](https://img.shields.io/badge/NetCDF4-Compatible-008B8B)](https://www.unidata.ucar.edu/software/netcdf/)
1314
[![Zarrita.js](https://img.shields.io/badge/Zarrita.js-0.5.x-0A7EA4)](https://github.com/manzt/zarrita.js)
1415
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/EarthyScience/Browzarr/blob/1c8d05d1c9ec0f96e599db26808b119839ece749/LICENSE)<br>
1516
[![Next.js](https://img.shields.io/badge/Next.js->=15.5.7-black)](https://nextjs.org/)
@@ -46,7 +47,7 @@ Stay tuned - major updates and new visualization features are on the way! 🚀
4647
We are still in active development but plan to release a stable 1.0.0 when all of the desired features are in place and a final stability and bug pass has been completed
4748
- [x] Temporal and spatial slicing
4849
- [x] Larger texture support
49-
- [ ] NetCDF Support
50+
- [x] NetCDF Support
5051
- [ ] Customizable export
5152
- [x] Animation export
5253
- [ ] Stability pass

src/components/ui/MainPanel/Dataset.tsx

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
DialogContent,
2121
DialogTitle,
2222
} from "@/components/ui/dialog";
23-
import { Switcher } from '../Switcher';
2423

2524

2625
const ZARR_STORES = {
@@ -91,15 +90,13 @@ const DatasetOption = ({
9190

9291
const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch<React.SetStateAction<boolean>>}) => {
9392
const [showStoreInput, setShowStoreInput] = useState(false);
94-
const [showLocalInput, setShowLocalInput] = useState(false);
93+
const [showLocalZarrInput, setShowLocalZarrInput] = useState(false);
94+
const [showLocalNetCDFInput, setShowLocalNetCDFInput] = useState(false);
9595
const [popoverSide, setPopoverSide] = useState<"left" | "top">("left");
9696
const [activeOption, setActiveOption] = useState<string>('ESDC')
9797
const [showDescriptionDialog, setShowDescriptionDialog] = useState<boolean>(false)
9898
const [openDescriptionPopover, setOpenDescriptionPopover] = useState<boolean>(false)
9999
const [isSafari, setIsSafari] = useState<boolean>(false)
100-
const {useNC} = useZarrStore(useShallow(state => ({
101-
useNC:state.fetchNC
102-
})))
103100

104101
const { initStore, setInitStore } = useGlobalStore(
105102
useShallow((state) => ({
@@ -172,7 +169,8 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch<React.Se
172169
active={activeOption === 'ESDC'}
173170
onClick={() => {
174171
setShowStoreInput(false);
175-
setShowLocalInput(false);
172+
setShowLocalZarrInput(false);
173+
setShowLocalNetCDFInput(false);
176174
setActiveOption('ESDC');
177175
setInitStore(ZARR_STORES.ESDC);
178176
if (popoverSide === 'top') {
@@ -188,7 +186,8 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch<React.Se
188186
active={activeOption === 'seasfire'}
189187
onClick={() => {
190188
setShowStoreInput(false);
191-
setShowLocalInput(false);
189+
setShowLocalZarrInput(false);
190+
setShowLocalNetCDFInput(false);
192191
setActiveOption('seasfire');
193192
setInitStore(ZARR_STORES.SEASFIRE);
194193
if (popoverSide === 'top') {
@@ -202,16 +201,17 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch<React.Se
202201
</DatasetOption>
203202

204203
<div className="w-full h-px bg-gray-300 my-2" />
205-
<p className="px-2 text-sm text-muted-foreground">Personal</p>
206204
<div className="w-full">
207205
<DatasetOption
208206
active={activeOption === 'remote'}
209207
onClick={() => {
210208
setShowStoreInput((prev) => !prev);
209+
setShowLocalZarrInput(false);
210+
setShowLocalNetCDFInput(false);
211211
setActiveOption('remote');
212212
}}
213213
>
214-
Remote
214+
Remote Zarr
215215
</DatasetOption>
216216
{showStoreInput && (
217217
<form
@@ -245,35 +245,46 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch<React.Se
245245
</div>
246246
<div className="w-full">
247247
<DatasetOption
248-
active={activeOption === 'local'}
248+
active={activeOption === 'localZarr'}
249249
onClick={() => {
250-
setShowLocalInput((prev) => !prev);
250+
setShowLocalZarrInput((prev) => !prev);
251251
setShowStoreInput(false);
252-
setActiveOption('local');
252+
setShowLocalNetCDFInput(false);
253+
setActiveOption('localZarr');
253254
}}
254255
>
255-
Local
256+
Local Zarr
256257
</DatasetOption>
257-
{showLocalInput &&
258+
{showLocalZarrInput &&
258259
<div className="mt-2">
259260
{isSafari ?
260261
<div className="p-3 rounded-md border border-yellow-600 text-tiny max-w-[300px]">
261262
<strong>Local folder upload is not supported in Safari.</strong> Please use Chrome, Firefox, or Edge instead.
262263
</div>
263264
:
264-
<>
265-
<Switcher leftText='Zarr' rightText='NetCDF' state={!useNC} onClick={()=>useZarrStore.setState({fetchNC:!useNC})} />
266-
{
267-
useNC ?
268-
<LocalNetCDF setShowLocal={setShowLocalInput} setOpenVariables={popoverSide === 'top' ? setShowDescriptionDialog : setOpenDescriptionPopover} />
269-
:
270-
<LocalZarr setShowLocal={setShowLocalInput} setOpenVariables={popoverSide === 'top' ? setShowDescriptionDialog : setOpenDescriptionPopover} setInitStore={setInitStore} />
271-
}
272-
</>
265+
<LocalZarr setShowLocal={setShowLocalZarrInput} setOpenVariables={popoverSide === 'top' ? setShowDescriptionDialog : setOpenDescriptionPopover} setInitStore={setInitStore} />
273266
}
274267
</div>
275268
}
276269
</div>
270+
<div className="w-full">
271+
<DatasetOption
272+
active={activeOption === 'localNetCDF'}
273+
onClick={() => {
274+
setShowLocalNetCDFInput((prev) => !prev);
275+
setShowStoreInput(false);
276+
setShowLocalZarrInput(false);
277+
setActiveOption('localNetCDF');
278+
}}
279+
>
280+
Local NetCDF
281+
</DatasetOption>
282+
{showLocalNetCDFInput &&
283+
<div className="mt-2">
284+
<LocalNetCDF setShowLocal={setShowLocalNetCDFInput} setOpenVariables={popoverSide === 'top' ? setShowDescriptionDialog : setOpenDescriptionPopover} />
285+
</div>
286+
}
287+
</div>
277288
</div>
278289
</PopoverContent>
279290
</Popover>
@@ -284,7 +295,7 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch<React.Se
284295
<div
285296
className="absolute -top-8"
286297
style={{
287-
left: ['local', 'remote'].includes(activeOption) ? -215 : -100,
298+
left: ['localZarr', 'localNetCDF', 'remote'].includes(activeOption) ? -215 : -130,
288299
}}
289300
/>
290301
</PopoverTrigger>

src/components/ui/MainPanel/LocalNetCDF.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ const LocalNetCDF = ({setShowLocal, setOpenVariables}:LocalNCType) => {
3838
useGlobalStore.setState({titleDescription})
3939

4040
setOpenVariables(true)
41-
setShowLocal(false)
41+
// setShowLocal(false)
4242
setStatus(null)
4343
};
4444

4545
return (
4646
<div className='w-[100%]'>
4747
<Input type="file" id="filepicker"
48-
className='hover:drop-shadow-md hover:scale-[110%]'
48+
className='hover:drop-shadow-md hover:scale-[102%]'
4949
style={{width:'200px', cursor:'pointer'}}
5050
accept='.nc, .netcdf, .nc3, .nc4'
5151
onChange={handleFileSelect}

0 commit comments

Comments
 (0)