Skip to content

Commit

Permalink
HPCC-30327 ECL Watch v9 spray multiple files open multiple tabs to WUs
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Clements <[email protected]>
  • Loading branch information
jeclrsg committed Sep 26, 2023
1 parent 582dc1a commit f179f9c
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 38 deletions.
33 changes: 27 additions & 6 deletions esp/src/src-react/components/forms/landing-zone/BlobImportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export const BlobImportForm: React.FunctionComponent<BlobImportFormProps> = ({

delete data.selectedFiles;

const requests = [];

files.forEach(file => {
request = data;
if (!isContainer) {
Expand All @@ -88,23 +90,42 @@ export const BlobImportForm: React.FunctionComponent<BlobImportFormProps> = ({
}
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export const DelimitedImportForm: React.FunctionComponent<DelimitedImportFormPro

delete data.selectedFiles;

const requests = [];

files.forEach(file => {
request = data;
if (!isContainer) {
Expand All @@ -109,23 +111,42 @@ export const DelimitedImportForm: React.FunctionComponent<DelimitedImportFormPro
file.TargetName && file.TargetName.substring(0, 2) !== "::"
) ? "::" : "") + file.TargetName;
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export const FixedImportForm: React.FunctionComponent<FixedImportFormProps> = ({

delete data.selectedFiles;

const requests = [];

files.forEach(file => {
request = data;
if (!isContainer) {
Expand All @@ -93,23 +95,42 @@ export const FixedImportForm: React.FunctionComponent<FixedImportFormProps> = ({
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,
Expand Down
33 changes: 27 additions & 6 deletions esp/src/src-react/components/forms/landing-zone/JsonImportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export const JsonImportForm: React.FunctionComponent<JsonImportFormProps> = ({

delete data.selectedFiles;

const requests = [];

files.forEach(file => {
request = data;
if (!isContainer) {
Expand All @@ -97,23 +99,42 @@ export const JsonImportForm: React.FunctionComponent<JsonImportFormProps> = ({
) ? "::" : "") + 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const VariableImportForm: React.FunctionComponent<VariableImportFormProps

delete data.selectedFiles;

const requests = [];

files.forEach(file => {
request = data;
if (!isContainer) {
Expand All @@ -87,26 +89,45 @@ export const VariableImportForm: React.FunctionComponent<VariableImportFormProps
}
request["sourcePath"] = file.SourceFile;
request["destLogicalName"] = data.namePrefix + ((
data.namePrefix && data.namePrefix.substr(-2) !== "::" &&
file.TargetName && file.TargetName.substr(0, 2) !== "::"
data.namePrefix && data.namePrefix.substring(-2) !== "::" &&
file.TargetName && file.TargetName.substring(0, 2) !== "::"
) ? "::" : "") + file.TargetName;
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,
Expand Down
33 changes: 27 additions & 6 deletions esp/src/src-react/components/forms/landing-zone/XmlImportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export const XmlImportForm: React.FunctionComponent<XmlImportFormProps> = ({

delete data.selectedFiles;

const requests = [];

files.forEach(file => {
request = data;
if (!isContainer) {
Expand All @@ -96,23 +98,42 @@ export const XmlImportForm: React.FunctionComponent<XmlImportFormProps> = ({
) ? "::" : "") + 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,
Expand Down

0 comments on commit f179f9c

Please sign in to comment.