Skip to main content

Report and Applet Javascript APIs

This document covers the Javascript libraries and APIs that ESP loads by default for use in any Dashboard Report.

Pre-loaded Libraries

ESP loads the following libraries and style sheets for all Dashboard Reports:

<link rel="stylesheet" type="text/css" href="/static/js/modules/ag-grid/ag-grid.min.css">
<link rel="stylesheet" type="text/css" href="/static/js/modules/ag-grid/ag-theme-balham.min.css">
<link rel="stylesheet" type="text/css" href="/report/static/css/general-reports.css">
<link rel="stylesheet" type="text/css" href="/static/js/modules/l7-common/base.css">
<script src="/static/js/jquery-2.1.0.min.js"></script>
<script src="/static/js/spin.js"></script>
<script src="/static/js/jquery.spin.js"></script>
<script src="/static/js/d3.v2.js"></script>
<script src="/static/js/fas-content.js"></script>
<script src="/static/js/invokables.js"></script>
<script src="/static/js/renderers.js"></script>
<script src="/static/js/modules/vue/vue.min.js"></script>
<script src="/static/js/modules/ag-grid/ag-grid-enterprise.min.js"></script>
<script src="/static/js/modules/ag-grid/ag-grid-vue.umd.min.js"></script>
<script src="/static/js/modules/l7-common/l7_common_ui.min.js"></script>

Ag-grid

Ag-grid is preloaded for reports and AgGrid is directly available in the main namespace. To instantiate Ag-grid with an enterprise license automatically, it is recommended that you use ReportApp.utils.makeAgGrid.

Vue

Vue is pre-loaded for reports and Vue is directly available in the main namespace.

AgGridVue (the vue component version of ag-grid) is not currently accessible in Reports.

ReportApp.utils

These functions reside in apps/src/shared/services/report/Repository.js and you may need to reference the source code in places where the documentation here is not clear or not defined.

ReportApp.utils.navigateTo(url)

ReportApp.utils.registerRefreshCallback(callback) - register a callback function to trigger when the user clicks the ‘refresh’ button

ReportApp.utils.registerPrintCallback(callback) - register a callback function to trigger when the user clicks the ‘print’ button (also see ReportApp.utils.print(elementId) below)

ReportApp.utils.isApps()

ReportApp.utils.startSpinner() - start ESP loading spinner overlay

ReportApp.utils.stopSpinner() - stop ESP loading spinner overlay

ReportApp.utils.tryJson(val) - attempt to parse val string as JSON, otherwise return false

ReportApp.utils.isUuid(val) - returns true if val is a UUID

ReportApp.utils.formatMeta(meta, vals)

ReportApp.utils.anchor(cls, node)

ReportApp.utils.anchorExplicit(cls, uuid, name)

ReportApp.utils.renderTreeView(results)

ReportApp.utils.append(node, htmlObj, depth)

ReportApp.utils.createCookie(name, value, days)

ReportApp.utils.readCookie(name)

ReportApp.utils.eraseCookie(name)

ReportApp.utils.listToTree(list)

ReportApp.utils.getApiQueryResults(queryName, data, onsuccess,onerror) - execute a custom named query and fetch the results

ReportApp.utils.get(url, data, onsuccess, onerror) - automatically authenticate and perform a GET request to an ESP endpoint

ReportApp.utils.post(url, data, onsuccess, onerror) - automatically authenticate and perform a POST request to an ESP endpoint

ReportApp.utils.checkResponseStatus(response) - check response status and attempt to resolve; used by ReportApp.utils.get and ReportApp.utils.post

ReportApp.utils.responseToJson(response) - resolve response to JSON; used by ReportApp.utils.get and ReportApp.utils.post

ReportApp.utils.print(elementId) - create a new window, populate it with the raw HTML contents of elementId and trigger a print model. This print view will NOT load the same JS libraries and style sheets as the standard report view, so the print view may not render as expected. We recommend creating a custom print callback and generating the print view yourself.

ReportApp.utils.generatePdf()

ReportApp.utils.makeGrid(elementSelector, gridOptions) - create a new AgGrid instance, pre-configured with an enterprise license key. This function is the recommended way of creating AgGrid instances in reports.

MainApp

MainApp is also defined in apps/src/shared/services/report/Repository.js.

MainApp.clsByIndex(index) - convert a fixed resource class index from the ESP DB (e.g. 550) to the class name and the URL for the corresponding app. Returns an object with properties clsIndex, displayName, and guiUrl.

MainApp.showError(message) - trigger a toast error notification

window.reportInteractionApi

Defined in apps/src/modules/dashboard/components/reports/ReportPreview.vue. Most of these functions are wrapped by functions defined in ReportApp.utils and you should use those rather than directly calling window.reportInteractionApi.

window.reportInteractionApi.registerRefreshCallback(callback)

window.reportInteractionApi.requestRefresh()

window.reportInteractionApi.registerPrintCallback(callback)

window.reportInteractionApi.requestPrint()

window.reportInteractionApi.navigateTo(url)

window.reportInteractionApi.toast(title, description, status) - trigger a toast notification

window.reportInteractionApi.generatePdf()