Skip to content

Commit 1e5afea

Browse files
add test.html for testing the iframe api
1 parent 3da8eec commit 1e5afea

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/test.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!--
2+
This is a test page to test the datalake consumption of the external-api library, in a widget
3+
to test, run "python -m http.server" in the cockpit directory and create an iframe widget with the url
4+
http://localhost:8000/test/test.html
5+
This should be served independently of the cockpit app in order to test the "same-origin" policies
6+
-->
7+
<!DOCTYPE html>
8+
<html lang="en">
9+
<head>
10+
<meta charset="UTF-8">
11+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
12+
<style>
13+
body {
14+
background-color: white;
15+
}
16+
</style>
17+
</head>
18+
<body>
19+
<h1>Datalake consumption test</h1>
20+
<div id="pitchDisplay"></div>
21+
<div id="rollDisplay"></div>
22+
23+
<script src="../dist/lib/cockpit-external-api.browser.js"></script>
24+
<script>
25+
CockpitAPI.listenToDatalakeVariable('ATTITUDE/pitch', function(data) {
26+
document.getElementById('pitchDisplay').innerText = 'Pitch (1Hz): ' + data;
27+
}, 1);
28+
CockpitAPI.listenToDatalakeVariable('ATTITUDE/roll', function(data) {
29+
30+
document.getElementById('rollDisplay').innerText = 'Roll (10Hz): ' + data;
31+
}, 10);
32+
</script>
33+
</body>
34+
</html>

0 commit comments

Comments
 (0)