Javascript 从Alteryx API查询获取输出

Javascript 从Alteryx API查询获取输出,javascript,api,alteryx,Javascript,Api,Alteryx,我一直在尝试设置一个javascrip应用程序,它能够运行并显示托管在我服务器上的Alteryx分析应用程序的输出。然后将其嵌入到Tableau服务器中 我已经设置了一些东西,可以从用户输入运行应用程序并显示其状态。 但是获取工作的输出有点棘手,我无法集中注意力。 看起来我应该使用getOutputFileURL()函数来获得我想要的东西,但我真的不确定应该如何设置它。 我尝试构建一个函数getOutputs()第54行,但它没有给我任何东西 有类似经历的人会介意帮我一把吗? 多谢各位 '''`

我一直在尝试设置一个javascrip应用程序,它能够运行并显示托管在我服务器上的Alteryx分析应用程序的输出。然后将其嵌入到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);
}
`
''`//导入模块和密钥
//填充扩展浏览器
进口“巴别塔polyfill”;
从“/keys”导入密钥;
从“alteryx订阅api”导入库;
从“/tableau”导入tableauJS;
//抓住跑步按钮
const btn=document.getElementById(“btn”);
//抓住输入框
常量输入=document.getElementById(“peopleSearch”);
//抓住留言框
const inputValue=document.getElementById(“消息”);
//抓住旋转器
常量加载=document.getElementById(“微调器”);
//抓住状态段落
const statusInfo=document.getElementById(“状态”);
//抓取输出div
const dataPrint=document.getElementById(“数据输出”);
//根据密钥文件中指定的值加载到库中
const createGallery=()=>{
const gallery=新库(keys.apilocation、keys.apikey、keys.apisecret);
回程廊;
};
异步函数作业(作业ID){
const response=wait createGallery().getJob(jobId);
const data=wait response.json();
如果(data.status!=“已完成”){
//如果工作流尚未完成,请继续检查作业ID的状态
jobs(jobId);
如果(inputValue.style.display==“块”){
inputValue.style.display=“无”;
}
load.style.display=“inline”;
//如有错误,请报告
}else if(data.status==“Error”){
控制台错误(数据状态);
const status=data.status;
statusInfo.innerHTML=状态;
}否则{
//如果完成,则显示完成消息
load.style.display=“无”;
const status=data.status;
statusInfo.innerHTML=状态;
statusInfo.style.display=“inline”;
//4秒钟后,删除输入并刷新DS
removeElement();
}
}
//获取作业的输出
异步函数getOutputs(jobId){
const response=wait createGallery().getJob(jobId);
const data=wait response.json();
控制台日志(数据);
对于(变量i=0;i{
const peopleSearch=输入值;
const appId=keys.appId;
如果(!peopleSearch){
inputValue.style.display=“block”;
}否则{
inputValue.style.display=“无”;
statusInfo.style.display=“无”;
常量数据数组=[
{
名称:“文本框(414)”,
价值:人民搜索
}
];
运行工作流(appId、dataArray);
}
});
//4秒后删除消息和搜索输入,并刷新数据源
函数removeElement(){
设置超时(()=>{
如果((statusInfo.style.display=“inline”)){
statusInfo.style.display=“无”;
input.value=“”;
tableauJS.refreshDS();
}
}, 6000);
}
`

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

不确定您具体要求什么。请确保你的问题是正确的。