从 Alteryx API 查询获取输出



我一直在尝试设置一个能够运行和显示托管在我的服务器上的 Alteryx 分析应用程序的输出的 javascrip 应用程序。然后的想法是将其嵌入到 Tableau 服务器中。

我已经设置了一些东西,能够从用户输入运行应用程序并显示其状态。 但是获取作业的输出有点棘手,我无法理解它。 似乎我应该使用 getOutputFileURL(( 函数来获取我想要的东西,但我真的不确定我应该如何设置它。 我尝试构建一个函数 getOutputs(( 第 54 行,但它没有给我任何东西。

有类似经历的人会介意在这里帮我一把吗? 谢谢

'''`// Importing the modules & the keys
// polyfilling the extensions browser
import "babel-polyfill";
import keys from "./keys";
import Gallery from "alteryx-subscription-api";
import tableauJS from "./tableau";
// Grab the Run Button
const btn = document.getElementById("btn");
// Grab the input box
const input = document.getElementById("peopleSearch");
// Grab the message box
const inputValue = document.getElementById("message");
// Grab the spinner gif
const loading = document.getElementById("spinner");
// Grab the status paragraph
const statusInfo = document.getElementById("status");
// Grab the output div
const dataPrint = document.getElementById("dataOutput");
// load into the gallery based on the values specified in the keys file
const createGallery = () => {
const gallery = new Gallery(keys.apilocation, keys.apikey, keys.apisecret);
return gallery;
};
async function jobs(jobId) {
const response = await createGallery().getJob(jobId);
const data = await response.json();
if (data.status !== "Completed") {
// if workflow hasn't been completed, keep checking the jobID for its status
jobs(jobId);
if (inputValue.style.display == "block") {
inputValue.style.display = "none";
}
loading.style.display = "inline";
// if error please report
} else if (data.status === "Error") {
console.error(data.status);
const status = data.status;
statusInfo.innerHTML = status;
} else {
// if finished display completed message
loading.style.display = "none";
const status = data.status;
statusInfo.innerHTML = status;
statusInfo.style.display = "inline";
// after 4 seconds remove the input and refresh the DS
removeElement();
}
}
// gets output from the job
async function getOutputs(jobId) {
const response = await createGallery().getJob(jobId);
const data = await response.json();
console.log(data);
for (var i = 0; i < data.length; i++) {
var url = galleryOutput.getOutputFileURL(jobId, data.id, "Raw");
dataPrint.innerHTML == url;
dataPrint.style.display = "inline";
}
}
// on click of buton run the workflow/app specified in the keys file
async function runWorkflow(appId, dataArray) {
const response = await createGallery().executeWorkflow(appId, dataArray);
const data = await response.json();
console.log(data);
// check if the job is running and if finished
jobs(data.id);
getOutputs(data.id);
}

// If you click run, first check if search input has been specified, then it grabs the appID from the keys file
btn.addEventListener("click", () => {
const peopleSearch = input.value;
const appId = keys.appId;
if (!peopleSearch) {
inputValue.style.display = "block";
} else {
inputValue.style.display = "none";
statusInfo.style.display = "none";
const dataArray = [
{
name: "Text Box (414)",
value: peopleSearch
}
];
runWorkflow(appId, dataArray);
}
});
//removes the messages and the search input after 4 seconds and refresh the data source
function removeElement() {
setTimeout(() => {
if ((statusInfo.style.display = "inline")) {
statusInfo.style.display = "none";
input.value = "";
tableauJS.refreshDS();
}
}, 6000);
}
`

更有效的过程是使用 Alteryx 中的输出工具写入数据库或 .TDE tableau 数据文件,然后正确摄取到 Tableau 中。

相关内容

  • 没有找到相关文章

最新更新