From f179f9c5f699dc7a657d8d6215a58dfaea7d9b35 Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:11:57 -0400 Subject: [PATCH] HPCC-30327 ECL Watch v9 spray multiple files open multiple tabs to WUs Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> --- .../forms/landing-zone/BlobImportForm.tsx | 33 ++++++++++++++--- .../landing-zone/DelimitedImportForm.tsx | 33 ++++++++++++++--- .../forms/landing-zone/FixedImportForm.tsx | 33 ++++++++++++++--- .../forms/landing-zone/JsonImportForm.tsx | 33 ++++++++++++++--- .../forms/landing-zone/VariableImportForm.tsx | 37 +++++++++++++++---- .../forms/landing-zone/XmlImportForm.tsx | 33 ++++++++++++++--- 6 files changed, 164 insertions(+), 38 deletions(-) diff --git a/esp/src/src-react/components/forms/landing-zone/BlobImportForm.tsx b/esp/src/src-react/components/forms/landing-zone/BlobImportForm.tsx index 737c658f563..8b0521c343c 100644 --- a/esp/src/src-react/components/forms/landing-zone/BlobImportForm.tsx +++ b/esp/src/src-react/components/forms/landing-zone/BlobImportForm.tsx @@ -79,6 +79,8 @@ export const BlobImportForm: React.FunctionComponent = ({ delete data.selectedFiles; + const requests = []; + files.forEach(file => { request = data; if (!isContainer) { @@ -88,23 +90,42 @@ export const BlobImportForm: React.FunctionComponent = ({ } request["sourcePath"] = file.SourceFile; request["fullPath"] = file.SourceFile; - FileSpray.SprayFixed({ + requests.push(FileSpray.SprayFixed({ request: request - }).then((response) => { + })); + }); + + Promise.all(requests).then(responses => { + if (responses.length === 1) { + const response = responses[0]; if (response?.Exceptions) { const err = response.Exceptions.Exception[0].Message; logger.error(err); } else if (response.SprayFixedResponse?.wuid) { - pushUrl(`/dfuworkunits/${response.SprayFixedResponse.wuid}`); + pushUrl(`#/dfuworkunits/${response.SprayFixedResponse.wuid}`); } - }); - }); + } else { + const errors = []; + responses.forEach(response => { + if (response?.Exceptions) { + const err = response.Exceptions.Exception[0].Message; + errors.push(err); + logger.error(err); + } else if (response.SprayFixedResponse?.wuid) { + window.open(`#/dfuworkunits/${response.SprayFixedResponse.wuid}`); + } + }); + if (errors.length === 0) { + closeForm(); + } + } + }).catch(err => logger.error(err)); }, err => { logger.error(err); } )(); - }, [handleSubmit, isContainer]); + }, [closeForm, handleSubmit, isContainer]); const componentStyles = mergeStyleSets( FormStyles.componentStyles, diff --git a/esp/src/src-react/components/forms/landing-zone/DelimitedImportForm.tsx b/esp/src/src-react/components/forms/landing-zone/DelimitedImportForm.tsx index e79cd11e528..b53e86ad5bf 100644 --- a/esp/src/src-react/components/forms/landing-zone/DelimitedImportForm.tsx +++ b/esp/src/src-react/components/forms/landing-zone/DelimitedImportForm.tsx @@ -96,6 +96,8 @@ export const DelimitedImportForm: React.FunctionComponent { request = data; if (!isContainer) { @@ -109,23 +111,42 @@ export const DelimitedImportForm: React.FunctionComponent { + })); + }); + + Promise.all(requests).then(responses => { + if (responses.length === 1) { + const response = responses[0]; if (response?.Exceptions) { const err = response.Exceptions.Exception[0].Message; logger.error(err); } else if (response.SprayResponse?.wuid) { - pushUrl(`/dfuworkunits/${response.SprayResponse.wuid}`); + pushUrl(`#/dfuworkunits/${response.SprayResponse.wuid}`); } - }); - }); + } else { + const errors = []; + responses.forEach(response => { + if (response?.Exceptions) { + const err = response.Exceptions.Exception[0].Message; + errors.push(err); + logger.error(err); + } else if (response.SprayResponse?.wuid) { + window.open(`#/dfuworkunits/${response.SprayResponse.wuid}`); + } + }); + if (errors.length === 0) { + closeForm(); + } + } + }).catch(err => logger.error(err)); }, err => { logger.error(err); } )(); - }, [handleSubmit, isContainer]); + }, [closeForm, handleSubmit, isContainer]); const componentStyles = mergeStyleSets( FormStyles.componentStyles, diff --git a/esp/src/src-react/components/forms/landing-zone/FixedImportForm.tsx b/esp/src/src-react/components/forms/landing-zone/FixedImportForm.tsx index 0e6b0783d48..05ac5d35dd8 100644 --- a/esp/src/src-react/components/forms/landing-zone/FixedImportForm.tsx +++ b/esp/src/src-react/components/forms/landing-zone/FixedImportForm.tsx @@ -79,6 +79,8 @@ export const FixedImportForm: React.FunctionComponent = ({ delete data.selectedFiles; + const requests = []; + files.forEach(file => { request = data; if (!isContainer) { @@ -93,23 +95,42 @@ export const FixedImportForm: React.FunctionComponent = ({ file.TargetName && file.TargetName.substring(0, 2) !== "::" ) ? "::" : "") + file.TargetName; request["destNumParts"] = file.NumParts; - FileSpray.SprayFixed({ + requests.push(FileSpray.SprayFixed({ request: request - }).then((response) => { + })); + }); + + Promise.all(requests).then(responses => { + if (responses.length === 1) { + const response = responses[0]; if (response?.Exceptions) { const err = response.Exceptions.Exception[0].Message; logger.error(err); } else if (response.SprayFixedResponse?.wuid) { - pushUrl(`/dfuworkunits/${response.SprayFixedResponse.wuid}`); + pushUrl(`#/dfuworkunits/${response.SprayFixedResponse.wuid}`); } - }); - }); + } else { + const errors = []; + responses.forEach(response => { + if (response?.Exceptions) { + const err = response.Exceptions.Exception[0].Message; + errors.push(err); + logger.error(err); + } else if (response.SprayFixedResponse?.wuid) { + window.open(`#/dfuworkunits/${response.SprayFixedResponse.wuid}`); + } + }); + if (errors.length === 0) { + closeForm(); + } + } + }).catch(err => logger.error(err)); }, err => { logger.error(err); } )(); - }, [handleSubmit, isContainer]); + }, [closeForm, handleSubmit, isContainer]); const componentStyles = mergeStyleSets( FormStyles.componentStyles, diff --git a/esp/src/src-react/components/forms/landing-zone/JsonImportForm.tsx b/esp/src/src-react/components/forms/landing-zone/JsonImportForm.tsx index 76f568bb5a2..c4909b52c22 100644 --- a/esp/src/src-react/components/forms/landing-zone/JsonImportForm.tsx +++ b/esp/src/src-react/components/forms/landing-zone/JsonImportForm.tsx @@ -82,6 +82,8 @@ export const JsonImportForm: React.FunctionComponent = ({ delete data.selectedFiles; + const requests = []; + files.forEach(file => { request = data; if (!isContainer) { @@ -97,23 +99,42 @@ export const JsonImportForm: React.FunctionComponent = ({ ) ? "::" : "") + file.TargetName; request["sourceRowTag"] = file.TargetRowPath; request["destNumParts"] = file.NumParts; - FileSpray.SprayVariable({ + requests.push(FileSpray.SprayVariable({ request: request - }).then((response) => { + })); + }); + + Promise.all(requests).then(responses => { + if (responses.length === 1) { + const response = responses[0]; if (response?.Exceptions) { const err = response.Exceptions.Exception[0].Message; logger.error(err); } else if (response.SprayResponse?.wuid) { - pushUrl(`/dfuworkunits/${response.SprayResponse.wuid}`); + pushUrl(`#/dfuworkunits/${response.SprayResponse.wuid}`); } - }); - }); + } else { + const errors = []; + responses.forEach(response => { + if (response?.Exceptions) { + const err = response.Exceptions.Exception[0].Message; + errors.push(err); + logger.error(err); + } else if (response.SprayResponse?.wuid) { + window.open(`#/dfuworkunits/${response.SprayResponse.wuid}`); + } + }); + if (errors.length === 0) { + closeForm(); + } + } + }).catch(err => logger.error(err)); }, err => { logger.error(err); } )(); - }, [handleSubmit, isContainer]); + }, [closeForm, handleSubmit, isContainer]); const componentStyles = mergeStyleSets( FormStyles.componentStyles, diff --git a/esp/src/src-react/components/forms/landing-zone/VariableImportForm.tsx b/esp/src/src-react/components/forms/landing-zone/VariableImportForm.tsx index 2ab5f2a8517..d6ba513c2ce 100644 --- a/esp/src/src-react/components/forms/landing-zone/VariableImportForm.tsx +++ b/esp/src/src-react/components/forms/landing-zone/VariableImportForm.tsx @@ -78,6 +78,8 @@ export const VariableImportForm: React.FunctionComponent { request = data; if (!isContainer) { @@ -87,26 +89,45 @@ export const VariableImportForm: React.FunctionComponent { + })); + }); + + Promise.all(requests).then(responses => { + if (responses.length === 1) { + const response = responses[0]; if (response?.Exceptions) { const err = response.Exceptions.Exception[0].Message; logger.error(err); } else if (response.SprayFixedResponse?.wuid) { - pushUrl(`/dfuworkunits/${response.SprayFixedResponse.wuid}`); + pushUrl(`#/dfuworkunits/${response.SprayFixedResponse.wuid}`); } - }); - }); + } else { + const errors = []; + responses.forEach(response => { + if (response?.Exceptions) { + const err = response.Exceptions.Exception[0].Message; + errors.push(err); + logger.error(err); + } else if (response.SprayFixedResponse?.wuid) { + window.open(`#/dfuworkunits/${response.SprayFixedResponse.wuid}`); + } + }); + if (errors.length === 0) { + closeForm(); + } + } + }).catch(err => logger.error(err)); }, err => { logger.error(err); } )(); - }, [handleSubmit, isContainer]); + }, [closeForm, handleSubmit, isContainer]); const componentStyles = mergeStyleSets( FormStyles.componentStyles, diff --git a/esp/src/src-react/components/forms/landing-zone/XmlImportForm.tsx b/esp/src/src-react/components/forms/landing-zone/XmlImportForm.tsx index 37d24b4363d..a5a52c74faf 100644 --- a/esp/src/src-react/components/forms/landing-zone/XmlImportForm.tsx +++ b/esp/src/src-react/components/forms/landing-zone/XmlImportForm.tsx @@ -82,6 +82,8 @@ export const XmlImportForm: React.FunctionComponent = ({ delete data.selectedFiles; + const requests = []; + files.forEach(file => { request = data; if (!isContainer) { @@ -96,23 +98,42 @@ export const XmlImportForm: React.FunctionComponent = ({ ) ? "::" : "") + file.TargetName; request["sourceRowTag"] = file.TargetRowTag; request["destNumParts"] = file.NumParts; - FileSpray.SprayVariable({ + requests.push(FileSpray.SprayVariable({ request: request - }).then((response) => { + })); + }); + + Promise.all(requests).then(responses => { + if (responses.length === 1) { + const response = responses[0]; if (response?.Exceptions) { const err = response.Exceptions.Exception[0].Message; logger.error(err); } else if (response.SprayResponse?.wuid) { - pushUrl(`/dfuworkunits/${response.SprayResponse.wuid}`); + pushUrl(`#/dfuworkunits/${response.SprayResponse.wuid}`); } - }); - }); + } else { + const errors = []; + responses.forEach(response => { + if (response?.Exceptions) { + const err = response.Exceptions.Exception[0].Message; + errors.push(err); + logger.error(err); + } else if (response.SprayResponse?.wuid) { + window.open(`#/dfuworkunits/${response.SprayResponse.wuid}`); + } + }); + if (errors.length === 0) { + closeForm(); + } + } + }).catch(err => logger.error(err)); }, err => { logger.error(err); } )(); - }, [handleSubmit, isContainer]); + }, [closeForm, handleSubmit, isContainer]); const componentStyles = mergeStyleSets( FormStyles.componentStyles,