@databrainhq/plugin
Databrain app ui web component plugin.
npm: @databrainhq/plugin
v0.15.135-uat
Code Style: StandardJS
Enforced using StandardJS styleguide.
Databrain app ui web component plugin.
<script src="https://unpkg.com/@databrainhq/plugin@latest"></script>
<script src="https://unpkg.com/@databrainhq/plugin@0.15.49"></script>
<script>
window.process = { env: {} };
</script>
function initDashboard() {
const url = new URL(location.href);
const token = url.searchParams.get("token") || "";
const dashboardId = url.searchParams.get("dashboardId") || "";
// Create the dashboard element
const dashboardElement = document.createElement('dbn-dashboard');
// Set attributes
if (token) {
dashboardElement.setAttribute('token', token);
}
if (dashboardId) {
dashboardElement.setAttribute('dashboard-id', dashboardId);
}
// Append the dashboard to the body
document.body.appendChild(dashboardElement);
}
// Initialize the dashboard when the DOM is fully loaded
document.addEventListener('DOMContentLoaded', initDashboard);
function initMetric() {
const url = new URL(location.href);
const token = url.searchParams.get("token") || "";
const dashboardId = url.searchParams.get("metricId") || "";
// Create the metric element
const metricElement = document.createElement('dbn-metric');
// Set attributes
if (token) {
metricElement.setAttribute('token', token);
}
if (dashboardId) {
metricElement.setAttribute('metric-id', dashboardId);
}
// Append the metric to the body
document.body.appendChild(metricElement);
}
// Initialize the metric when the DOM is fully loaded
document.addEventListener('DOMContentLoaded', initMetric);
npm i @databrainhq/plugin
import "@databrainhq/plugin/web";