nhance/app/Views/apache_dashboard_demo_one.php
2026-06-02 14:26:20 +05:30

113 lines
3.3 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claims Overview</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: sans-serif; background: #f5f5f5; }
#dashboard-container {
width: 100%;
height: 100vh;
}
#dashboard-container iframe {
width: 100%;
height: 100%;
border: none;
}
#error-msg {
display: none;
padding: 2rem;
color: #c0392b;
font-size: 14px;
text-align: center;
}
</style>
</head>
<body>
<div id="dashboard-container"></div>
<iframe src="https://venbait.in/chartBoard/public/share/8e130e4faa821740183feaa805f3ba0c7935841a64c5461ba6ed255f5b419f93?embed=1" width="1200" height="800" style="border:0;" loading="lazy" title="Chart-Board"></iframe>
<div id="error-msg"></div>
<script src="https://unpkg.com/@superset-ui/embedded-sdk"></script>
<script>
const SUPERSET_DOMAIN = "https://demo.venbait.in";
const DASHBOARD_ID = "aaff42c8-1d7a-4e28-8beb-f6a7b9e08661";
const USERNAME = "admin";
const PASSWORD = "$tr0n9pa55w0rd ";
async function getGuestToken() {
// Step 1: Login to get access token
const loginRes = await fetch(SUPERSET_DOMAIN + "/api/v1/security/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username: USERNAME,
password: PASSWORD,
provider: "db",
refresh: true
})
});
if (!loginRes.ok) throw new Error("Login failed: " + loginRes.status);
const { access_token } = await loginRes.json();
// Step 2: Get CSRF token
const csrfRes = await fetch(SUPERSET_DOMAIN + "/api/v1/security/csrf_token/", {
method: "GET",
headers: { "Authorization": "Bearer " + access_token }
});
if (!csrfRes.ok) throw new Error("CSRF fetch failed: " + csrfRes.status);
const { result: csrf_token } = await csrfRes.json();
// Step 3: Get guest token
const guestRes = await fetch(SUPERSET_DOMAIN + "/api/v1/security/guest_token/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + access_token,
"X-CSRFToken": csrf_token
},
body: JSON.stringify({
resources: [{ type: "dashboard", id: DASHBOARD_ID }],
rls: [],
user: { username: "guest", first_name: "Guest", last_name: "User" }
})
});
if (!guestRes.ok) throw new Error("Guest token failed: " + guestRes.status);
const { token } = await guestRes.json();
return token;
}
async function init() {
alert();
return true;
try {
await supersetEmbeddedSdk.embedDashboard({
id: DASHBOARD_ID,
supersetDomain: SUPERSET_DOMAIN,
mountPoint: document.getElementById("dashboard-container"),
fetchGuestToken: () => getGuestToken(),
dashboardUiConfig: {
hideTitle: true,
filters: { expanded: true }
}
});
} catch (err) {
const el = document.getElementById("error-msg");
el.style.display = "block";
el.textContent = "Error loading dashboard: " + err.message;
console.error(err);
}
}
init();
</script>
</body>
</html>