Skip to content

Commit

Permalink
Merge branch 'master' into btn-init-config
Browse files Browse the repository at this point in the history
  • Loading branch information
ericboucher authored May 7, 2024
2 parents 1e8e0c1 + 935efad commit 1a85c00
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ const out = {
Mild: {
'SPI DJF': {
probability: 28,
triggerExceeded: true,
showWarningSign: true,
},
},
Moderate: {
'SPI DJF': {
probability: 22,
triggerExceeded: false,
showWarningSign: false,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface ForecastTransformParams {

interface IndexData {
probability: number | null;
triggerExceeded: boolean;
showWarningSign: boolean;
}

interface CategoryData {
Expand Down Expand Up @@ -84,12 +84,11 @@ export function forecastTransform({
// eslint-disable-next-line fp/no-mutating-methods
indexData.sort((a, b) => b.date.localeCompare(a.date));
// Take the probability of the first element (latest date)
const max = Math.trunc(indexData[0].probability * 100);
const triggerExceeded =
indexData[0].probability > indexData[0].trigger;
return [index, { probability: max, triggerExceeded }];
const latest = Math.trunc(indexData[0].probability * 100);
const showWarningSign = Boolean(indexData[0].isValid);
return [index, { probability: latest, showWarningSign }];
}
return [index, { probability: null, triggerExceeded: false }];
return [index, { probability: null, showWarningSign: false }];
});
return [cat, Object.fromEntries(val)];
}),
Expand Down Expand Up @@ -156,7 +155,7 @@ export const getChartData = (
indexes: {
[key: string]: {
probability?: number | null;
triggerExceeded: boolean | null;
showWarningSign: boolean | null;
} | null;
},
backgroundColor: string,
Expand All @@ -167,7 +166,7 @@ export const getChartData = (
data: Object.entries(indexes).map(([index, val], i) => ({
x: i + 0.6,
y: val?.probability,
z: val?.triggerExceeded,
z: val?.showWarningSign,
})),
// Triangle pointer
pointStyle: 'triangle',
Expand Down
20 changes: 1 addition & 19 deletions frontend/src/components/MapView/Legends/LegendItemsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import useLayers from 'utils/layers-utils';
import { createGetLegendGraphicUrl } from 'prism-common';
import { useSafeTranslation } from 'i18n';
import { List } from '@material-ui/core';
import useResizeObserver from 'utils/useOnResizeObserver';
import { AALayerId } from 'config/utils';
import AALegend from '../LeftPanel/AnticipatoryActionPanel/AALegend';
import LegendItem from './LegendItem';
Expand All @@ -34,18 +33,10 @@ interface LegendItemsListProps {
forPrinting?: boolean;
listStyle?: string;
showDescription?: boolean;
resizeCallback?: ({
width,
height,
}: {
width: number;
height: number;
}) => void;
}

const LegendItemsList = ({
listStyle,
resizeCallback,
forPrinting = false,
showDescription = true,
}: LegendItemsListProps) => {
Expand All @@ -55,21 +46,12 @@ const LegendItemsList = ({
const invertedColorsForAnalysis = useSelector(invertedColorsSelector);
const analysisLayerOpacity = useSelector(analysisResultOpacitySelector);
const { selectedLayers, adminBoundariesExtent } = useLayers();
const [listRef, listSize] = useResizeObserver<HTMLUListElement>(
resizeCallback,
);

const AALayerInUrl = React.useMemo(
() => selectedLayers.find(x => x.id === AALayerId),
[selectedLayers],
);

React.useEffect(() => {
if (resizeCallback) {
resizeCallback(listSize);
}
}, [listSize, resizeCallback]);

// If legend array is empty, we fetch from remote server the legend as GetLegendGraphic request.
const getLayerLegendUrl = React.useCallback((layer: LayerType) => {
return layer.type === 'wms' && layer.legend.length === 0
Expand Down Expand Up @@ -200,7 +182,7 @@ const LegendItemsList = ({
]);

return (
<List disablePadding ref={listRef} className={listStyle}>
<List disablePadding className={listStyle}>
{legendItems}
</List>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ exports[`renders as expected 1`] = `
<div
style="padding: 8px;"
>
Publication date: 2024-05-07. Layer selection date: 2018-07-02.
Publication date: 2018-07-02. Layer selection date: 2018-07-02.
</div>
</div>
<div
style="position: absolute; z-index: 2; top: 0px; left: 8px; width: 20px; transform: scale(1);"
style="position: absolute; z-index: 2; top: 0px; left: 8px; display: flex; justify-content: flex-start; width: 20px; transform: scale(1);"
>
<mock-list
classname="DownloadImage-legendListStyle-15"
Expand Down Expand Up @@ -163,7 +163,141 @@ exports[`renders as expected 1`] = `
<mock-typography
variant="h4"
>
Admin area mask
Logo Position
</mock-typography>
<div
class="MuiToggleButtonGroup-root makeStyles-buttonGroup-20"
role="group"
>
<button
aria-pressed="true"
class="MuiButtonBase-root MuiToggleButton-root MuiToggleButtonGroup-grouped MuiToggleButtonGroup-groupedHorizontal makeStyles-button-21 Mui-selected"
tabindex="0"
type="button"
value="-1"
>
<span
class="MuiToggleButton-label"
>
<mock-visibilityoff />
</span>
<span
class="MuiTouchRipple-root"
/>
</button>
<button
aria-pressed="false"
class="MuiButtonBase-root MuiToggleButton-root MuiToggleButtonGroup-grouped MuiToggleButtonGroup-groupedHorizontal makeStyles-button-21"
tabindex="0"
type="button"
value="0"
>
<span
class="MuiToggleButton-label"
>
<mock-icon
style="color: black;"
>
switch_right
</mock-icon>
</span>
<span
class="MuiTouchRipple-root"
/>
</button>
</div>
</div>
<div
style="opacity: 0.5; pointer-events: none;"
>
<div
class="makeStyles-wrapper-19"
>
<mock-typography
style="text-align: end;"
variant="h4"
>
Logo Size
</mock-typography>
<div
class="MuiToggleButtonGroup-root makeStyles-buttonGroup-20"
role="group"
style="justify-content: end;"
>
<button
aria-pressed="false"
class="MuiButtonBase-root MuiToggleButton-root MuiToggleButtonGroup-grouped MuiToggleButtonGroup-groupedHorizontal makeStyles-button-21"
tabindex="0"
type="button"
value="0.5"
>
<span
class="MuiToggleButton-label"
>
<div
style="font-size: 0.75rem;"
>
S
</div>
</span>
<span
class="MuiTouchRipple-root"
/>
</button>
<button
aria-pressed="true"
class="MuiButtonBase-root MuiToggleButton-root MuiToggleButtonGroup-grouped MuiToggleButtonGroup-groupedHorizontal makeStyles-button-21 Mui-selected"
tabindex="0"
type="button"
value="1"
>
<span
class="MuiToggleButton-label"
>
<div
style="font-size: 1rem;"
>
M
</div>
</span>
<span
class="MuiTouchRipple-root"
/>
</button>
<button
aria-pressed="false"
class="MuiButtonBase-root MuiToggleButton-root MuiToggleButtonGroup-grouped MuiToggleButtonGroup-groupedHorizontal makeStyles-button-21"
tabindex="0"
type="button"
value="1.5"
>
<span
class="MuiToggleButton-label"
>
<div
style="font-size: 1.25rem;"
>
L
</div>
</span>
<span
class="MuiTouchRipple-root"
/>
</button>
</div>
</div>
</div>
</div>
<div
class="DownloadImage-sameRowToggles-16"
>
<div
class="makeStyles-wrapper-19"
>
<mock-typography
variant="h4"
>
Admin Area Mask
</mock-typography>
<div
class="MuiToggleButtonGroup-root makeStyles-buttonGroup-20"
Expand Down
Loading

0 comments on commit 1a85c00

Please sign in to comment.