-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
read list of palettes from Thredds server layer metadata service
- Loading branch information
1 parent
b1b8753
commit e09266a
Showing
8 changed files
with
128 additions
and
4 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
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
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,50 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import isDefined from "../../../Core/isDefined"; | ||
import WebMapServiceCapabilitiesStratum from "../../../Models/Catalog/Ows/WebMapServiceCapabilitiesStratum"; | ||
import Box from "../../../Styled/Box"; | ||
|
||
interface PalettesProps { | ||
item: WebMapServiceCapabilitiesStratum; | ||
} | ||
|
||
// @observable | ||
const Palettes: React.FC<PalettesProps> = ({ item }) => { | ||
const [palettes, setPalettes] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchPalettes = async (item: WebMapServiceCapabilitiesStratum) => { | ||
try { | ||
const paletteUrl = item.availablePalettes[0]?.url; | ||
if (isDefined(paletteUrl)) { | ||
const response = await fetch(paletteUrl); | ||
const data = await response.json(); | ||
setPalettes(data.palettes); | ||
} | ||
} catch (error) { | ||
console.error("Error fetching palettes:", error); | ||
} | ||
}; | ||
|
||
fetchPalettes(item); | ||
}, [item]); | ||
|
||
const handlePaletteChange = (event: React.ChangeEvent<HTMLSelectElement>) => { | ||
//get the value of the selected option | ||
const selectedPalette = event.target.value; | ||
item.setTrait("user", "selectedPalette", selectedPalette); | ||
Check failure on line 34 in lib/ReactViews/Workbench/Controls/Palettes.tsx
|
||
console.log("Selected palette:", selectedPalette); | ||
}; | ||
|
||
return ( | ||
<Box displayInlineBlock fullWidth> | ||
<p>Palettes: </p> | ||
<select onChange={handlePaletteChange}> | ||
{palettes.map((palette: any) => ( | ||
<option key={palette}>{palette}</option> | ||
))} | ||
</select> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Palettes; |
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
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