Skip to content

Commit

Permalink
Merge branch 'develop' into FLAG-343-fire-alert-widget-crashes-page-w…
Browse files Browse the repository at this point in the history
…hen-clicking-settings-button
  • Loading branch information
SARodrigues committed Nov 9, 2023
2 parents 3c76b45 + b8e4d93 commit 1a4e29e
Show file tree
Hide file tree
Showing 29 changed files with 440 additions and 701 deletions.
Binary file modified assets/logos/cargillhover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions components/widgets/fires/burned-area-cumulative/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const defaultConfig = {
fires: 3,
},
settings: {
dataset: 'modis_burned_area',
dataset: 'viirs',
firesThreshold: 0,
},
sentences: {
Expand Down Expand Up @@ -151,12 +151,10 @@ export default {
refetchKeys: ['dataset'],
getWidget: (widgetSettings) => {
// called when settings changes
if (!widgetSettings || !widgetSettings.dataset) {
return defaultConfig;
}
if (widgetSettings.dataset !== 'modis_burned_area') {
if (widgetSettings?.dataset !== 'modis_burned_area') {
return firesAlertsCumulative;
}

return defaultConfig;
},
};
8 changes: 3 additions & 5 deletions components/widgets/fires/burned-area-ranked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const defaultConfig = {
page: 0,
period: 'week',
weeks: 4,
dataset: 'modis_burned_area',
dataset: 'viirs',
layerStartDate: null,
layerEndDate: null,
firesThreshold: 0,
Expand Down Expand Up @@ -163,12 +163,10 @@ export default {
refetchKeys: ['dataset'],
getWidget: (widgetSettings) => {
// called when settings changes
if (!widgetSettings || !widgetSettings.dataset) {
return defaultConfig;
}
if (widgetSettings.dataset !== 'modis_burned_area') {
if (widgetSettings?.dataset !== 'modis_burned_area') {
return firesRanked;
}

return defaultConfig;
},
};
2 changes: 1 addition & 1 deletion components/widgets/fires/burned-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
fires: 1,
},
settings: {
dataset: 'modis_burned_area',
dataset: 'viirs',
firesThreshold: 0,
},
sentences: {
Expand Down
8 changes: 8 additions & 0 deletions components/widgets/fires/fires-alerts-cumulative/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { all, spread } from 'axios';
import uniq from 'lodash/uniq';
import moment from 'moment';
import { fetchVIIRSAlerts, fetchVIIRSLatest } from 'services/analysis-cached';
import { FIRES_VIIRS_DATASET } from 'data/datasets';
import { FIRES_ALERTS_VIIRS } from 'data/layers';

import getWidgetProps from './selectors';

Expand All @@ -10,6 +12,12 @@ export default {
title: 'Cumulative Fire Alerts in {location}',
large: true,
categories: ['summary', 'fires'],
datasets: [
{
dataset: FIRES_VIIRS_DATASET,
layers: [FIRES_ALERTS_VIIRS],
},
],
settingsConfig: [
{
key: 'forestType',
Expand Down
20 changes: 16 additions & 4 deletions components/widgets/fires/fires-alerts-cumulative/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const getSentences = (state) => state.sentences || null;
const getLocationName = (state) => state.locationLabel;
const getOptionsSelected = (state) => state.optionsSelected;
const getIndicator = (state) => state.indicator;
const getSettings = (state) => state.settings;

export const getCompareYears = createSelector(
[getCompareYear, getAllYears],
Expand Down Expand Up @@ -401,9 +402,9 @@ export const parseSentence = createSelector(
getDataset,
getLocationName,
getStartIndex,
// getEndIndex,
getOptionsSelected,
getIndicator,
getSettings,
],
(
raw_data,
Expand All @@ -413,18 +414,29 @@ export const parseSentence = createSelector(
dataset,
location,
startIndex,
// endIndex //broken?
options,
indicator
indicator,
settings
) => {
if (!data || isEmpty(data)) return null;

const {
highConfidence,
allAlerts,
highConfidenceWithInd,
allAlertsWithInd,
} = sentences;
const { confidence } = options;
const { confidenceToggle } = settings;
let { confidence } = options;

/*
Validation for the Analysis
*/
if (confidenceToggle) {
confidence =
confidenceToggle === 'true' ? { value: 'h' } : { value: 'all' };
}

const indicatorLabel =
indicator && indicator.label ? indicator.label : null;
const start = startIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const getAlerts = (state) => state.data;
const getColors = (state) => state.colors || null;
const getStartDate = (state) => state.settings.startDate;
const getEndDate = (state) => state.settings.endDate;
const getSettings = (state) => state.settings;
const getSentences = (state) => state.sentences || null;
const getLocationObject = (state) => state.location;
const getOptionsSelected = (state) => state.optionsSelected;
Expand Down Expand Up @@ -87,6 +88,7 @@ export const parseSentence = createSelector(
getEndDate,
getOptionsSelected,
getIndicator,
getSettings,
],
(
data,
Expand All @@ -96,11 +98,24 @@ export const parseSentence = createSelector(
startDate,
endDate,
options,
indicator
indicator,
settings
) => {
if (!data) return null;
const { initial, withInd, highConfidence } = sentences;
const { confidence, dataset } = options;
const { confidenceToggle } = settings;
const { dataset } = options;

let { confidence } = options;

/*
Validation for the Analysis
*/
if (confidenceToggle) {
confidence =
confidenceToggle === 'true' ? { value: 'h' } : { value: 'all' };
}

const indicatorLabel =
indicator && indicator.label ? indicator.label : null;
const total = sumBy(data, 'alert__count');
Expand Down
Loading

0 comments on commit 1a4e29e

Please sign in to comment.