mirror of
https://github.com/apache/superset.git
synced 2026-04-26 11:34:27 +00:00
[explore view] fix long query issue from Run in SQL LAB Button (#9345)
* [explore view] fix long query issue from Run in SQL LAB Button * SQL Lab page needs to take the post form data, too * fix variable names * updated payload dict, rename hidden form Co-authored-by: Jesse Yang <jesse.yang@airbnb.com>
This commit is contained in:
@@ -190,29 +190,36 @@ export function getExploreUrlAndPayload({
|
||||
};
|
||||
}
|
||||
|
||||
export function postForm(url, payload, target = '_blank') {
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hiddenForm = document.createElement('form');
|
||||
hiddenForm.action = url;
|
||||
hiddenForm.method = 'POST';
|
||||
hiddenForm.target = target;
|
||||
const token = document.createElement('input');
|
||||
token.type = 'hidden';
|
||||
token.name = 'csrf_token';
|
||||
token.value = (document.getElementById('csrf_token') || {}).value;
|
||||
hiddenForm.appendChild(token);
|
||||
const data = document.createElement('input');
|
||||
data.type = 'hidden';
|
||||
data.name = 'form_data';
|
||||
data.value = safeStringify(payload);
|
||||
hiddenForm.appendChild(data);
|
||||
|
||||
document.body.appendChild(hiddenForm);
|
||||
hiddenForm.submit();
|
||||
document.body.removeChild(hiddenForm);
|
||||
}
|
||||
|
||||
export function exportChart(formData, endpointType) {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType,
|
||||
allowDomainSharding: false,
|
||||
});
|
||||
|
||||
const exploreForm = document.createElement('form');
|
||||
exploreForm.action = url;
|
||||
exploreForm.method = 'POST';
|
||||
exploreForm.target = '_blank';
|
||||
const token = document.createElement('input');
|
||||
token.type = 'hidden';
|
||||
token.name = 'csrf_token';
|
||||
token.value = (document.getElementById('csrf_token') || {}).value;
|
||||
exploreForm.appendChild(token);
|
||||
const data = document.createElement('input');
|
||||
data.type = 'hidden';
|
||||
data.name = 'form_data';
|
||||
data.value = safeStringify(payload);
|
||||
exploreForm.appendChild(data);
|
||||
|
||||
document.body.appendChild(exploreForm);
|
||||
exploreForm.submit();
|
||||
document.body.removeChild(exploreForm);
|
||||
postForm(url, payload);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user