从Alteryx API查询中获取输出

问题描述 投票:0回答:1

我一直在尝试设置一个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);
}
`
javascript api alteryx
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.