Skip to content

Commit

Permalink
bug: fixed issue with high confidence toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlstarr committed Oct 17, 2023
1 parent 478f02d commit e0d60cc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
25 changes: 19 additions & 6 deletions src/js/components/sharedComponents/IntegratedAlertControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const IntegratedAlertControls = (props: GladControlsProps): JSX.Element => {
const highConfidenceConfirmed = useSelector((store: RootState) => store.appState.leftPanel.highConfidenceConfirmed);
const geographicCoverage = useSelector((store: RootState) => store.appState.leftPanel.geographicCoverage);
const gfwIntegratedEnd = useSelector((store: RootState) => store.appState.leftPanel.gfwIntegratedEnd);
const integratedAlertLayer = useSelector((store: RootState) => store.appState.leftPanel.integratedAlertLayer);
const allAvailableLayers = useSelector((store: RootState) => store.mapviewState.allAvailableLayers);

const [startDate, setStartDate] = React.useState(String(DATE_PICKER_START_DATES.GFW_INTEGRATED_ALERTS));
const [startDateUnformatted, setStartDateUnformatted] = React.useState(
Expand Down Expand Up @@ -65,16 +67,27 @@ const IntegratedAlertControls = (props: GladControlsProps): JSX.Element => {

setEndDate(dFormat);

onEndDateChange(date);
onEndDateChange(date, dFormat);
}

async function showOnlyHighConfidenceToggle() {
dispatch(setHighConfidenceConfirmed(!highConfidenceConfirmed));
const gfwIntegratedLayerOld: any = mapController._map!.findLayerById(LAYER_IDS.GFW_INTEGRATED_ALERTS);
mapController._map?.remove(gfwIntegratedLayerOld);
const gfwIntegratedLayerNew: any = LayerFactory(mapController._mapview, props.layerConfig);
gfwIntegratedLayerNew.highConfidenceConfirmed = !highConfidenceConfirmed;
mapController._map?.add(gfwIntegratedLayerNew);
if (integratedAlertLayer === 'GFW_INTEGRATED_ALERTS') {
const gfwIntegratedLayerOld: any = mapController._map!.findLayerById(LAYER_IDS.GFW_INTEGRATED_ALERTS);
mapController._map?.remove(gfwIntegratedLayerOld);
const gfwIntegratedLayerNew: any = LayerFactory(mapController._mapview, props.layerConfig);
gfwIntegratedLayerNew.highConfidenceConfirmed = !highConfidenceConfirmed;
mapController._map?.add(gfwIntegratedLayerNew);
} else {
const gladLayerOld: any = mapController._map!.findLayerById(integratedAlertLayer);
mapController._map?.remove(gladLayerOld);
const gladLayerConfig: any = allAvailableLayers.filter((layer: any) => layer.id === integratedAlertLayer);
const gladLayerNew: any = await LayerFactory(mapController._mapview, gladLayerConfig[0]);
gladLayerNew.confirmed = !highConfidenceConfirmed;
mapController._map?.add(gladLayerNew);
const selectedLayer = mapController._map!.findLayerById(integratedAlertLayer);
selectedLayer.visible = true;
}
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ import {
setRaddAlertStart,
} from '../../../store/appState/actions';

export const onStartDateChange = async (dFormat: any, endDate: any) => {
const integratedAlertLayer = store.getState().appState.leftPanel.integratedAlertLayer;
const gfwIntegratedStart = store.getState().appState.leftPanel.gfwIntegratedStart;
const gfwIntegratedEnd = store.getState().appState.leftPanel.gfwIntegratedEnd;
const glad2Start = store.getState().appState.leftPanel.glad2Start;
const glad2End = store.getState().appState.leftPanel.glad2End;
const gladStart = store.getState().appState.leftPanel.gladStart;
const gladEnd = store.getState().appState.leftPanel.gladEnd;
const raddAlertStart = store.getState().appState.leftPanel.raddAlertStart;
const raddAlertEnd = store.getState().appState.leftPanel.raddAlertEnd;
const geographicCoverage = store.getState().appState.leftPanel.geographicCoverage;
const highConfidenceConfirmed = store.getState().appState.leftPanel.highConfidenceConfirmed;
const allAvailableLayers = store.getState().mapviewState.allAvailableLayers;

export const onStartDateChange = async (dFormat: string, endDate: string) => {
const integratedAlertLayer = store.getState().appState.leftPanel.integratedAlertLayer;

//@ts-ignore
Expand Down Expand Up @@ -45,7 +58,7 @@ export const onStartDateChange = async (dFormat: any, endDate: any) => {
}
};

export const onEndDateChange = async (date) => {
export const onEndDateChange = async (date: string, dFormat: string) => {
let start;
const end = new Date(dFormat).getJulian();
const integratedAlertLayer = store.getState().appState.leftPanel.integratedAlertLayer;
Expand Down Expand Up @@ -82,8 +95,6 @@ export const onEndDateChange = async (date) => {

export const showGeographicCoverage = async () => {
const [VectorTileLayer] = await loadModules(['esri/layers/VectorTileLayer']);
const geographicCoverage = store.getState().appState.leftPanel.geographicCoverage;
const integratedAlertLayer = store.getState().appState.leftPanel.integratedAlertLayer;

let geographicCoverageLayer;
if (integratedAlertLayer === 'GFW_INTEGRATED_ALERTS' || integratedAlertLayer === 'GLAD_ALERTS') {
Expand Down Expand Up @@ -121,17 +132,7 @@ export const showGeographicCoverage = async () => {
}
};

export const handleDateToggle = (startDate, endDate) => {
const integratedAlertLayer = store.getState().appState.leftPanel.integratedAlertLayer;
const gfwIntegratedStart = store.getState().appState.leftPanel.gfwIntegratedStart;
const gfwIntegratedEnd = store.getState().appState.leftPanel.gfwIntegratedEnd;
const glad2Start = store.getState().appState.leftPanel.glad2Start;
const glad2End = store.getState().appState.leftPanel.glad2End;
const gladStart = store.getState().appState.leftPanel.gladStart;
const gladEnd = store.getState().appState.leftPanel.gladEnd;
const raddAlertStart = store.getState().appState.leftPanel.raddAlertStart;
const raddAlertEnd = store.getState().appState.leftPanel.raddAlertEnd;

export const handleDateToggle = (startDate: string, endDate: string) => {
if (integratedAlertLayer === LAYER_IDS.GFW_INTEGRATED_ALERTS) {
return { start: gfwIntegratedStart, end: gfwIntegratedEnd };
}
Expand Down

0 comments on commit e0d60cc

Please sign in to comment.