data.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. <script>
  62. function reload() {
  63. document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>";
  64. window.scrollBy(0,document.body.scrollHeight);
  65. funcRequest(getDomainname() + '/data');
  66. }
  67. async function funcRequest(url){
  68. await fetch(url)
  69. .then((res) => {
  70. if (!res.ok) {
  71. document.getElementById("data").innerHTML = "HTTP error " + res.status;
  72. }
  73. return res.text();
  74. })
  75. .then((data) => {
  76. document.getElementById('data').innerHTML = "<br>" + data.split("\n").join("\n<br>") + "&nbsp;";
  77. window.scrollBy(0,document.body.scrollHeight);
  78. })
  79. .catch((err) => {
  80. document.getElementById("data").innerHTML = err;
  81. });
  82. }
  83. funcRequest(getDomainname() + '/data');
  84. </script>
  85. </body>
  86. <script>
  87. function reload() {
  88. document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>";
  89. window.scrollBy(0,document.body.scrollHeight);
  90. funcRequest(getDomainname() + '/data');
  91. }
  92. async function funcRequest(url){
  93. await fetch(url)
  94. .then((res) => {
  95. if (!res.ok) {
  96. document.getElementById("data").innerHTML = "HTTP error " + res.status;
  97. }
  98. return res.text();
  99. })
  100. .then((data) => {
  101. document.getElementById('data').innerHTML = "<br>" + data.split("\n").join("\n<br>") + "&nbsp;";
  102. window.scrollBy(0,document.body.scrollHeight);
  103. })
  104. .catch((err) => {
  105. document.getElementById("data").innerHTML = err;
  106. });
  107. }
  108. funcRequest(getDomainname() + '/data');
  109. </script>
  110. </html>