data.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!DOCTYPE html>
  2. <html lang="en" xml:lang="en">
  3. <head>
  4. <title>Data Viewer</title>
  5. <meta charset="UTF-8" />
  6. <style>
  7. h1 {font-size: 2em;}
  8. h2 {font-size: 1.5em; margin-block-start: 0.0em; margin-block-end: 0.2em;}
  9. h3 {font-size: 1.2em;}
  10. p {font-size: 1em;}
  11. html,
  12. body {
  13. height: 100%;
  14. margin: 1px;
  15. font-family: Arial, Helvetica, sans-serif;
  16. }
  17. .box {
  18. display: flex;
  19. flex-flow: column;
  20. height: 99.75%;
  21. }
  22. .box .row.header {
  23. flex: 0 1 auto;
  24. }
  25. .box .row.content {
  26. flex: 1 1 auto;
  27. }
  28. .box .row.footer {
  29. flex: 0 1 auto;
  30. }
  31. #data {
  32. font-family: 'Courier New', Courier, monospace;
  33. font-size: small;
  34. }
  35. .button {
  36. padding: 5px 10px;
  37. width: 160px;
  38. font-size: 16px;
  39. }
  40. </style>
  41. <script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script>
  42. </head>
  43. <body>
  44. <h2>Data Viewer</h2>
  45. <h4>Today's latest data</h4>
  46. <div class="box">
  47. <div class="row header">
  48. <button class="button" onClick="reload();">Refresh</button>
  49. <button class="button" onClick="window.open(getDomainname() + '/datafileact');">Show Full File</button>
  50. <button class="button" onClick="window.location.href = getDomainname() + '/fileserver/log/data/'">Show Data Files</button>
  51. <button class="button" onClick="window.location.href = 'graph.html?v=$COMMIT_HASH'">Show Graph</button>
  52. </div>
  53. <div class="row content" id="data"><br><br><br><b>Loading data file, please wait...</b></div>
  54. <div class="row footer">
  55. <button class="button" onClick="reload();">Refresh</button>
  56. <button class="button" onClick="window.open(getDomainname() + '/datafileact');">Show Full File</button>
  57. <button class="button" onClick="window.location.href = getDomainname() + '/fileserver/log/data/'">Show Data Files</button>
  58. <button class="button" onClick="window.location.href = 'graph.html?v=$COMMIT_HASH'">Show Graph</button>
  59. </div>
  60. </div>
  61. </body>
  62. <script>
  63. function reload() {
  64. document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>";
  65. window.scrollBy(0,document.body.scrollHeight);
  66. funcRequest(getDomainname() + '/data');
  67. }
  68. async function funcRequest(url){
  69. await fetch(url)
  70. .then((res) => {
  71. if (!res.ok) {
  72. document.getElementById("data").innerHTML = "HTTP error " + res.status;
  73. }
  74. return res.text();
  75. })
  76. .then((data) => {
  77. document.getElementById('data').innerHTML = "<br>" + data.split("\n").join("\n<br>") + "&nbsp;";
  78. window.scrollBy(0,document.body.scrollHeight);
  79. })
  80. .catch((err) => {
  81. document.getElementById("data").innerHTML = err;
  82. });
  83. }
  84. funcRequest(getDomainname() + '/data');
  85. </script>
  86. </html>