import React, {useState} from 'react'; import { useInterval } from 'react-powerhooks'; // nodejs library that concatenates classes import classNames from "classnames"; // react plugin used to create charts import { Line, Bar } from "react-chartjs-2"; import { useAlert } from "react-alert"; // https://demos.creative-tim.com/black-dashboard-react/?ref=appseed#/admin/dashboard // reactstrap components import { Button, ButtonGroup, Card, CardHeader, CardBody, CardTitle, DropdownToggle, DropdownMenu, DropdownItem, UncontrolledDropdown, Label, FormGroup, Input, Table, Row, Col, UncontrolledTooltip } from "reactstrap"; // core components import { chartExample1, chartExample2, chartExample3, chartExample4 } from "./charts.js"; // This is the start of a dashboard that can be used. // What data do we fill in here? Idk const Dashboard = (props) => { const { globalUrl } = props; const alert = useAlert() const [bigChartData, setBgChartData] = useState("data1"); const [firstRequest, setFirstRequest] = useState(true); const [stats, setStats] = useState({}) const [changeme, setChangeme] = useState("") document.title = "Shuffle - dashboard" const fetchdata = (stats_id) => { fetch(globalUrl+"/api/v1/stats/"+stats_id, { method: 'GET', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, credentials: "include", }) .then((response) => { if (response.status !== 200) { console.log("Status not 200 for stream results :O!") } return response.json() }) .then((responseJson) => { console.log("DATA: ", responseJson) stats[stats_id] = responseJson setStats(stats) // Used to force updates setChangeme(stats_id) }) .catch(error => { alert.error("ERROR: "+error.toString()) }); } // All these are currently tracked. const variables = [ "backend_executions", "workflow_executions", "workflow_executions_aborted", "workflow_executions_success", "total_apps_created", "total_apps_loaded", "openapi_apps_created", "total_apps_deleted", "total_webhooks_ran", "total_workflows", "total_workflow_actions", "total_workflow_triggers", ] const runUpdate = () => { for (var key in variables) { fetchdata(variables[key]) } } // Refresh every 60 seconds const autoUpdate = 60000 const { start, stop } = useInterval({ duration: autoUpdate, startImmediate: false, callback: () => { runUpdate() } }); if (firstRequest) { setFirstRequest(false) start() runUpdate() } const newdata = Object.getOwnPropertyNames(stats).length > 0 ?