Starting on downloading all gribs for reference date
This commit is contained in:
@@ -9,7 +9,6 @@ import { fetchHourPrecipitationData, isCalculatedHourPrecipitation } from './dra
|
|||||||
|
|
||||||
export const GribFile: Component<{
|
export const GribFile: Component<{
|
||||||
name: string,
|
name: string,
|
||||||
getCanvas: Accessor<HTMLCanvasElement | undefined>,
|
|
||||||
setIsLoading: Setter<boolean>,
|
setIsLoading: Setter<boolean>,
|
||||||
getFileGribList: Accessor<GribMessage[]>, // specific reference and forecast time (in one file)
|
getFileGribList: Accessor<GribMessage[]>, // specific reference and forecast time (in one file)
|
||||||
getAllGribLists: Accessor<GribMessage[]>,
|
getAllGribLists: Accessor<GribMessage[]>,
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import { Component, createSignal } from 'solid-js'
|
import { Component, createSignal } from 'solid-js'
|
||||||
|
|
||||||
import { apiHost } from '../consts'
|
import { apiHost } from '../consts'
|
||||||
import styles from './harmonie.module.css'
|
|
||||||
import { GribFile } from './GribFile'
|
import { GribFile } from './GribFile'
|
||||||
import { GribMessage } from './interfaces'
|
import { GribMessage } from './interfaces'
|
||||||
import { fetchJson } from '../helpers/fetch'
|
import { fetchJson } from '../helpers/fetch'
|
||||||
import { getFakeWindDirection, isWindSpeed } from './draw/windDirection'
|
import { getFakeWindDirection, isWindSpeed } from './draw/windDirection'
|
||||||
import { getFakeHourPrecipitation, isPrecipitation } from './draw/precipitation'
|
import { getFakeHourPrecipitation, isPrecipitation } from './draw/precipitation'
|
||||||
import { DrawView } from './DrawView'
|
import { DrawView } from './DrawView'
|
||||||
|
import { ReferenceTimes } from './ReferenceTimes'
|
||||||
|
|
||||||
|
import styles from './harmonie.module.css'
|
||||||
|
|
||||||
export const Harmonie: Component<{}> = () => {
|
export const Harmonie: Component<{}> = () => {
|
||||||
const [getFileList, setFileList] = createSignal<string[]>([])
|
const [getFileList, setFileList] = createSignal<string[]>([])
|
||||||
const [getCanvas, setCanvas] = createSignal<HTMLCanvasElement>()
|
|
||||||
const [getIsLoading, setIsLoading] = createSignal(true)
|
const [getIsLoading, setIsLoading] = createSignal(true)
|
||||||
const [getIsCrop, setIsCrop] = createSignal(true)
|
const [getIsCrop, setIsCrop] = createSignal(true)
|
||||||
const [getIsContour, setIsContour] = createSignal(true)
|
const [getIsContour, setIsContour] = createSignal(true)
|
||||||
@@ -32,7 +33,7 @@ export const Harmonie: Component<{}> = () => {
|
|||||||
})
|
})
|
||||||
.finally(() => setIsLoading(false))
|
.finally(() => setIsLoading(false))
|
||||||
|
|
||||||
function onGribMessageClick(fileName: string) {
|
function getAllGribStructure() {
|
||||||
if(!getGribList().length) {
|
if(!getGribList().length) {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
fetchJson(`${apiHost}/api/show/grib-all-structure`)
|
fetchJson(`${apiHost}/api/show/grib-all-structure`)
|
||||||
@@ -75,15 +76,19 @@ export const Harmonie: Component<{}> = () => {
|
|||||||
Interpolate
|
Interpolate
|
||||||
<input type='checkbox' checked={getIsInterpolated()} onChange={()=>setIsInterpolated(!getIsInterpolated())} />
|
<input type='checkbox' checked={getIsInterpolated()} onChange={()=>setIsInterpolated(!getIsInterpolated())} />
|
||||||
</label>
|
</label>
|
||||||
|
<ReferenceTimes
|
||||||
|
getFileList={getFileList}
|
||||||
|
getGribList={getGribList}
|
||||||
|
onClick={getAllGribStructure}
|
||||||
|
/>
|
||||||
<ul class={styles.fileList}>
|
<ul class={styles.fileList}>
|
||||||
{getFileList().map(fileName =>
|
{getFileList().map(fileName =>
|
||||||
<GribFile
|
<GribFile
|
||||||
name={fileName}
|
name={fileName}
|
||||||
getCanvas={getCanvas}
|
|
||||||
setIsLoading={setIsLoading}
|
setIsLoading={setIsLoading}
|
||||||
getFileGribList={() => getCurrentGribList(fileName)}
|
getFileGribList={() => getCurrentGribList(fileName)}
|
||||||
getAllGribLists={getGribList}
|
getAllGribLists={getGribList}
|
||||||
onClick={() => onGribMessageClick(fileName)}
|
onClick={getAllGribStructure}
|
||||||
cachedMessagesSignal={cachedMessagesSignal}
|
cachedMessagesSignal={cachedMessagesSignal}
|
||||||
cachedBuffersSignal={cachedBuffersSignal}
|
cachedBuffersSignal={cachedBuffersSignal}
|
||||||
cachedBitmasksSignal={cachedBitmasksSignal}
|
cachedBitmasksSignal={cachedBitmasksSignal}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { Accessor, Component, createSignal } from 'solid-js'
|
||||||
|
|
||||||
|
import styles from './harmonie.module.css'
|
||||||
|
import { GribMessage } from './interfaces'
|
||||||
|
|
||||||
|
export const ReferenceTimes: Component<{
|
||||||
|
getFileList: Accessor<string[]>,
|
||||||
|
getGribList: Accessor<GribMessage[]>,
|
||||||
|
onClick: () => void,
|
||||||
|
}> = ({
|
||||||
|
getFileList,
|
||||||
|
getGribList,
|
||||||
|
onClick,
|
||||||
|
}) => {
|
||||||
|
const [getActiveDate, setActiveDate] = createSignal('')
|
||||||
|
const dateList = () => {
|
||||||
|
const datesStr = getFileList().map(f => f.replace('harmonie_', '').split('_')[0])
|
||||||
|
return [...new Set(datesStr)]
|
||||||
|
}
|
||||||
|
|
||||||
|
function onActiveDate(date: string) {
|
||||||
|
onClick()
|
||||||
|
const newValue = getActiveDate() === date ? '' : date
|
||||||
|
setActiveDate(newValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
return <ul class={styles.dateList}>
|
||||||
|
{ dateList().map(dateStr =>
|
||||||
|
<li>
|
||||||
|
<div onClick={() => onActiveDate(dateStr)}>
|
||||||
|
{ dateStr }
|
||||||
|
</div>
|
||||||
|
<div class={styles.controls} style={{ display: getActiveDate() === dateStr ? 'block' : 'none'}}>
|
||||||
|
{
|
||||||
|
getGribList().some(g => g.time.referenceTime === dateStr)
|
||||||
|
&& <>TODO: download all forecasts</>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</li>)}
|
||||||
|
</ul>
|
||||||
|
}
|
||||||
@@ -54,3 +54,18 @@
|
|||||||
.meteoParams li:hover {
|
.meteoParams li:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.dateList {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dateList li {
|
||||||
|
color: #ddd;
|
||||||
|
background-color: #333;
|
||||||
|
padding: 5px 0 5px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dateList li .controls {
|
||||||
|
padding: 10px 3px;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user