From de97f4c0fc98bab484de6b7df4c61a3753d93ed8 Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:08:33 -0400 Subject: [PATCH 1/2] adding updates to the model run label, enforcing a model run sort order --- .../trays/compare-layers/CompareLayersTray.js | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/components/trays/compare-layers/CompareLayersTray.js b/src/components/trays/compare-layers/CompareLayersTray.js index f8793dc9..5abc82fa 100644 --- a/src/components/trays/compare-layers/CompareLayersTray.js +++ b/src/components/trays/compare-layers/CompareLayersTray.js @@ -32,6 +32,69 @@ const getModelRunGroupList = (layers) => { return groupList; }; +/** + * gets the summary header text for the layer groups. + * This takes into account the two types of runs (tropical, synoptic) + * + * @param layerProps + * @returns {string} + */ +const getHeaderSummary = (layerProps) => { + // get the full accordian summary text + return layerProps['run_date'] + ': ' + + ((getPropertyName(layerProps, 'stormOrModelEle') === undefined) ? 'Data error' : getPropertyName(layerProps, 'stormOrModelEle').toUpperCase()) + + ', ' + getPropertyName(layerProps, 'numberName') + getPropertyName(layerProps, 'numberEle') + + ', Type: ' + layerProps['event_type'] + + ', Grid: ' + layerProps['grid_type'] + + ((layerProps['meteorological_model'] === 'None') ? '' : ', ' + layerProps['meteorological_model']); +}; + +/** + * gets the header data property name index + * This takes into account the two types of runs (tropical, synoptic) + * + * @param layerProps + * @param type + * @returns {string} + */ +const getPropertyName = (layerProps, element_name) => { + // init the return + let ret_val = undefined; + + // capture the name of the element for tropical storms and advisory numbers + if (layerProps['met_class'] === 'tropical') { + // by the element name + switch (element_name) { + case 'stormOrModelEle': + ret_val = layerProps['storm_name']; + break; + case 'numberName': + ret_val = ' Adv: '; + break; + case 'numberEle': + ret_val = layerProps['advisory_number']; + break; + } + } + // capture the name of the synoptic ADCIRC models and cycle numbers + else { + switch (element_name) { + case 'stormOrModelEle': + ret_val = layerProps['model']; + break; + case 'numberName': + ret_val = ' Cycle: '; + break; + case 'numberEle': + ret_val = layerProps['cycle']; + break; + } + } + + // return to the caller + return ret_val; +}; + /** * This component renders the model selection tray * @@ -347,6 +410,8 @@ export const CompareLayersTray = () => { // filter by the group name .filter((groups, idx, self) => (idx === self.findIndex((t) => (t['group'] === groups['group'])))) + // sort by the group name + .sort((a, b) => a['group'] < b['group'] ? -1 : 1) // at this point we have the distinct runs .map((layer, idx) => ( @@ -355,7 +420,7 @@ export const CompareLayersTray = () => { onChange={ (event, expanded) => { setAccordionIndex(expanded ? idx : null); }} > - { layer['group'] } + { getHeaderSummary(layer['properties']) } From 8b37d276734116087c17f8200a5a728e15150fc5 Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:42:33 -0400 Subject: [PATCH 2/2] lowering the font size --- src/components/trays/compare-layers/CompareLayersTray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/trays/compare-layers/CompareLayersTray.js b/src/components/trays/compare-layers/CompareLayersTray.js index 5abc82fa..46cd6f14 100644 --- a/src/components/trays/compare-layers/CompareLayersTray.js +++ b/src/components/trays/compare-layers/CompareLayersTray.js @@ -420,7 +420,7 @@ export const CompareLayersTray = () => { onChange={ (event, expanded) => { setAccordionIndex(expanded ? idx : null); }} > - { getHeaderSummary(layer['properties']) } + { getHeaderSummary(layer['properties']) }