JSFiddle - React, Tailwind, and code Playground

by Flexmonster Pivot Table

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<div id="pivotContainer"></div>

JavaScript

let pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      filename: "data/data.csv"
    }
  },
  beforetoolbarcreated: customizeToolbar
});

const login = "admin";
const password = "admin";

function generateToken(login, password) {
  return "Base " + btoa(login + ":" + password);
}

function customizeToolbar(toolbar) {
  toolbar.showConnectToElasticDialog = function(requestHeaders) {
    var self = this;
    var Labels = this.Labels;
    var onConnectBtnClick = function() {
      if (hostUrlInput.value.length == 0) return;
      $.ajax({
        url: hostUrlInput.value + "/_cat/indices?format=json",
        beforeSend: function(xhr) {
          xhr.setRequestHeader('Authorization', requestHeaders.Authorization);
        },
        type: "GET",
        success: function(data) {
          indicesHandler("success", data.reduce((acc, index) => {
            acc.push(index.index)
            return acc;
          }, []));
        }
      });
    };
    var indicesHandler = function(status, indices) {
      if (status != "success") {
        self.popupManager.removePopup();
        return;
      }
      indicesList.setDataProvider(indices);
      indicesList.setEnabled(true);
    };
    var okHandler = function() {
      self.pivot.connectTo({
        type: "elasticsearch",
        host: hostUrlInput.value,
        index: indicesList.getValue(),
        requestHeaders
      });
    };
    var onIndicesListChange = function() {
      self.setEnabled(self.getElementById("fm-btn-open"), true);
    };

    var dialog = this.popupManager.createPopup();
    dialog.content.classList.add("fm-popup-olap");
    dialog.content.classList.add("fm-popup-w570");
    dialog.setTitle(Labels.connect_elastic_title);
    dialog.setToolbar([{
        id: "fm-btn-open",
        label: Labels.ok,
        handler: okHandler,
        disabled: true,
        isPositive: true
      },
    ...