-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
88 lines (73 loc) · 2.51 KB
/
index.html
File metadata and controls
88 lines (73 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Embedded Dashboard</title>
<!-- Add required dependencies -->
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
fetchpriority="high"
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block"
/>
<link
rel="stylesheet"
href="https://cdn.last9.io/dashboard-assets/embedded/public/css/inter.css"
/>
<link
rel="stylesheet"
href="https://cdn.last9.io/dashboard-assets/embedded/public/css/commit.css"
/>
<link
rel="stylesheet"
href="https://cdn.last9.io/dashboard-assets/embedded/style.css"
/>
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
</head>
<body>
<!-- Container for your app -->
<div id="embedded-app-container" style="height: 100vh"></div>
<!-- Embedded dashboard script -->
<script src="https://cdn.last9.io/dashboard-assets/embedded/last9-embedded-dashboard.umd-v1.1.js"></script>
<script>
// Function to fetch access token
const getToken = async () => {
const apiUrl = 'http://localhost:8080/embed-token';
const data = {
datasource_id: '',
dashboard_id: '',
variables: {},
};
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
};
console.info('Fetching token from server...');
const response = await fetch(apiUrl, requestOptions);
if (!response.ok) {
console.error('Error:', response.error);
throw new Error('Error occurred while fetching access token.');
}
console.info('Token fetched successfully!');
return response.json();
};
// Callback function to handle error
const onError = (error) => {
console.error(error);
};
// Initialize the embedded dashboard app
EmbeddedDashboardApp.initialize({
containerId: 'embedded-app-container',
org: 'last9',
getToken,
onError,
});
</script>
</body>
</html>