From 2adefca2b385451c544ef690b8d6ea0279685311 Mon Sep 17 00:00:00 2001 From: Muthukrishnanmatriot <76949556+muthukrishnanmatriot@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:14:47 +0530 Subject: [PATCH] TMSS-1074 - updated the code --- .../src/components/JSONEditor/JEditor.js | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js index dd017a19825..f7ce78a1f87 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js @@ -512,8 +512,9 @@ function Jeditor(props) { if(editor.editors[filterbankPath]?.formname) { document.getElementsByName(editor.editors[filterbankPath]?.formname)[0].addEventListener('change', (event) => { filterBankEnabled =event.currentTarget.value === '1'?true:false; + updatePipelineFrequencyResolution(channelPath, null, false); }); - filterBankEnabled = document.getElementsByName(editor.editors[filterbankPath]?.formname)[0].value === '1' ?true : false; + filterBankEnabled = document.getElementsByName(editor.editors[filterbankPath]?.formname)[0].value === '1' ?true : false; } channelsFilterbankElement.addEventListener('keyup', (event) => { @@ -554,6 +555,8 @@ function Jeditor(props) { if(intTimeElement) { intTimeElement.addEventListener('change', (event) => { singlePulseSearch =event.currentTarget.value === '1'?true:false; + updatePipelineFrequencyResolution(channelPath, null, true); + updatePipelineTimeResolution(channelPath, null, null); }); } } @@ -764,7 +767,7 @@ function Jeditor(props) { propertyOrder++; } }//<<<<<< - } else if (propertyKey.toLowerCase() === 'single_pulse_search') { + } else if (propertyKey.toLowerCase() === 'single_pulse_search' && props.observationType == 'pulsar pipeline' && properties['dspsr']) { // Add custom fields to the properties where property 'single_pulse_search' is one of the property. let freqResolution = { title: 'Frequency Resolution (kHz)',type: 'string',default: '' }; properties['dspsr']['properties']['digifil']['properties']['frequency_resolution'] = freqResolution; @@ -980,11 +983,16 @@ function Jeditor(props) { else { updateInput(inputValue); } - } else if (inputKey.toLowerCase() === 'channels_per_subband') { + } + else if (inputKey.toLowerCase() === 'channels_per_subband') { // Add calculated values for custom fields frequency_resolution and time_resolution editorInput['frequency_resolution'] = getFrequencyResolution(inputValue); const integrationTime = editorInput['integration_time'] || editorInput['time_integration_factor']; editorInput['time_resolution'] = getTimeResolution(inputValue, integrationTime); + } + else if (inputKey.toLowerCase() === 'duration') { + // } else if (durationProps.indexOf(inputKey)) { + editorInput[inputKey] = getTimeInput(inputValue); } else if (inputKey.toLowerCase() === 'channels_per_part') { let isDigifil = false; @@ -1000,10 +1008,6 @@ function Jeditor(props) { editorInput['frequency_resolution'] = getPipelineFrequencyResolution(inputValue, isDigifil); } } - else if (inputKey.toLowerCase() === 'duration') { - // } else if (durationProps.indexOf(inputKey)) { - editorInput[inputKey] = getTimeInput(inputValue); - } } return editorInput; } @@ -1228,15 +1232,21 @@ function Jeditor(props) { * Function to calculate and update the readonly field frequency_resolution when channels_per_part value is changed * @param {string} channelsPropPath - path of the channels_per_part preoperty to get the id or name of the field * @param {number} channelsPerPart - value selected in the dropdown - * @param {number} freqSteps - value entered in the frequency steps of average property in pipeline task spec. + * @param {boolean} isDigifil - ture if the it has digifil, false if it is filterbank */ - function updatePipelineFrequencyResolution(channelsPropPath, channelsPerPart, freqSteps, isDigifil) { + function updatePipelineFrequencyResolution(channelsPropPath, channelsPerPart, isDigifil) { + if (!channelsPerPart) { + let channelsPath = channelsPropPath.split("."); + channelsPath[channelsPath.length-1] = 'channels_per_part'; + channelsPerPart = document.getElementById(editor.editors[channelsPath.join('.')]?.formname)?.value; + } + let freqResPath = channelsPropPath.split("."); freqResPath[freqResPath.length-1] = "frequency_resolution"; freqResPath = freqResPath.join("."); if(editor.editors[freqResPath]?.formname) { // Set values for Frequency Resolution field. - document.getElementById(editor.editors[freqResPath]?.formname).value = getPipelineFrequencyResolution(channelsPerPart, freqSteps, isDigifil); + document.getElementById(editor.editors[freqResPath]?.formname).value = getPipelineFrequencyResolution(channelsPerPart, isDigifil); } } -- GitLab