status.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Status display</title>
  6. <meta name="description"
  7. content="Status display generated by BORA.">
  8. <link rel="stylesheet" href="{{ static_url("style.css") }}">
  9. <link rel="stylesheet" href="{{ static_url("jquery-ui.min.css") }}">
  10. <!--[if IE]>
  11. <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  12. <![endif]-->
  13. </head>
  14. <body>
  15. <div id="page_info">CPS data monitoring. Last refreshed</div>
  16. {% if data['style'] %}
  17. {% for key in data['style'] %}
  18. {% if data['style'][key]['type'] == "data" %}
  19. <div tooltip="{{ key }}" class="databox" style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;'
  20. {% if data['style'][key]['condition'] %}
  21. data-cond="{{ data['style'][key]['condition'] }}"
  22. {% else%}
  23. {% end%}
  24. data-type="{{ data['style'][key]['type'] }}" data-lesser="{{ data['style'][key]['lesser'] }}" data-larger="{{ data['style'][key]['larger'] }}" onclick="window.open('http://katrin.kit.edu/adei-katrin/#module=graph&{{ data['varname'][key]}}&experiment=-&window=0&module=graph&virtual=srctree&srctree=&infomod=legend', '_blank');" id="{{ key }}">
  25. <p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval"> XXX.XX </span><span class='unit_title'> {{ data['style'][key]['unit']['title'] }}</span></p>
  26. </div>
  27. {% else %}
  28. {% end %}
  29. {% if data['style'][key]['type'] == "ventil" %}
  30. <div tooltip="{{ key }}" style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;' data-type="{{ data['style'][key]['type'] }}" data-off="{{ data['style'][key]['off'] }}" data-on="{{ data['style'][key]['on'] }}" onclick="window.open('http://katrin.kit.edu/adei-katrin/#module=graph&{{ data['varname'][key]}}&experiment=-&window=0&module=graph&virtual=srctree&srctree=&infomod=legend', '_blank');" class='databox' id="{{ key }}">
  31. <img width='100%' height='100%' src='{{ static_url("ventil_inactive.png") }}'></img>
  32. </div>
  33. {% else %}
  34. {% end %}
  35. {% if data['style'][key]['type'] == "integer-to-string" %}
  36. <div tooltip="{{ key }}" style='position: absolute; top: {{
  37. data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }};
  38. width:{{ data['style'][key]['width'] }}px; height:{{
  39. data['style'][key]['height'] }}px;' data-cond="{{ data['style'][key]['cond'] }}" data-dict="{{ data['style'][key]['dict'] }}" data-type="{{ data['style'][key]['type'] }}" onclick="window.open('http://katrin.kit.edu/adei-katrin/#module=graph&{{ data['varname'][key]}}&experiment=-&window=0&module=graph&virtual=srctree&srctree=&infomod=legend', '_blank');" class='databox' id="{{ key }}">
  40. <p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span><br /><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval">??? </span></p>
  41. </div>
  42. {% else %}
  43. {% end %}
  44. {% if data['style'][key]['type'] == "header" %}
  45. <div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
  46. data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
  47. height:{{ data['style'][key]['height'] }}px;' data-type="{{
  48. data['style'][key]['type'] }}" class='databox' id="{{ key }}">
  49. <p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span></p>
  50. </div>
  51. {% else %}
  52. {% end %}
  53. {% end %}
  54. {% else %}
  55. {% end %}
  56. <img src="{{ static_url('background.png') }}"></img>
  57. <!-- java script -->
  58. <script src="{{ static_url("jquery-1.12.3.min.js") }}"></script>
  59. <script src="{{ static_url("jquery-ui.min.js") }}"></script>
  60. <script>
  61. jQuery(window).load(function () {
  62. myTimer();
  63. var myVar = setInterval(myTimer, 10000);
  64. function myTimer() {
  65. var dataToSend = {};
  66. $.ajax({
  67. url: '/getdata/',
  68. type: 'GET',
  69. data: dataToSend,
  70. success: function (response) {
  71. //var objresponse = JSON.parse(response);
  72. console.log(response);
  73. for (var key in response) {
  74. //console.log(key, response[key]);
  75. data_type = $("#" + key).attr('data-type');
  76. if($("#" + key).length > 0) {
  77. if (data_type == "data") {
  78. var datavalue, set_color;
  79. if (response[key]) {
  80. datavalue = parseFloat(response[key]).toFixed(2);
  81. set_color = "green";
  82. } else {
  83. datavalue = "???";
  84. set_color = "black";
  85. }
  86. $(".varval", "#" + key).text(datavalue);
  87. var condition_attr = $("#" + key).attr('data-cond');
  88. var lesser_attr = $("#" + key).attr('data-lesser');
  89. var larger_attr = $("#" + key).attr('data-larger');
  90. //console.log(condition_attr);
  91. if (typeof(condition_attr) !== 'undefined' && condition_attr !== false) {
  92. if (response[key] == condition_attr) {
  93. set_color = "red";
  94. }
  95. }
  96. if (typeof(lesser_attr) !== 'undefined' && lesser_attr !== false) {
  97. if (parseFloat(response[key]) < parseFloat(lesser_attr)) {
  98. set_color = "red";
  99. }
  100. }
  101. if (typeof(larger_attr) !== 'undefined' && larger_attr !== false) {
  102. if (parseFloat(response[key]) > parseFloat(larger_attr)) {
  103. set_color = "red";
  104. }
  105. }
  106. $(".varval", "#" + key).css("color", set_color);
  107. $(".unit_title", "#" + key).css("color", set_color);
  108. } else if (data_type == "ventil") {
  109. var on_attr = $("#" + key).attr('data-on');
  110. var off_attr = $("#" + key).attr('data-off');
  111. if (parseFloat(response[key]) == parseFloat(on_attr)) {
  112. $("img", "#" + key).attr("src", "{{ static_url('ventil_green.png') }}");
  113. }
  114. if (parseFloat(response[key]) == parseFloat(off_attr)) {
  115. $("img", "#" + key).attr("src", "{{ static_url('ventil_red.png') }}");
  116. }
  117. } else if (data_type == "integer-to-string") {
  118. var dict_attr = JSON.parse($("#" + key).attr('data-dict'));
  119. var dict_cond;
  120. if ($("#"+key).attr("data-cond")) {
  121. dict_cond = JSON.parse($("#" + key).attr('data-cond'));
  122. } else {
  123. dict_cond = {};
  124. }
  125. var dict_color = "";
  126. if (key in response) {
  127. var token = response[key];
  128. if (token in dict_cond) {
  129. dict_color = dict_cond[token];
  130. }
  131. }
  132. $(".varval", "#" + key).css("color", dict_color);
  133. $(".varval", "#" + key).text(dict_attr[response[key]]);
  134. }
  135. }
  136. }
  137. var datetime = "CPS data monitoring page. Last Sync: " + response["time"];
  138. /*
  139. var currentdate = new Date();
  140. var datetime = "CPS data monitoring page. Last Sync: " + ( (currentdate.getDate()<10?'0':'').toString() + (currentdate.getDate()).toString() ) + "/"
  141. + ( ((currentdate.getMonth()+1)<10?'0':'').toString() + (currentdate.getMonth()+1)).toString() + "/"
  142. + ( (currentdate.getFullYear()<10?'0':'').toString() + (currentdate.getFullYear()).toString() ) + " @ "
  143. + ( (currentdate.getHours()<10?'0':'').toString() + (currentdate.getHours()).toString() ) + ":"
  144. + ( (currentdate.getMinutes()<10?'0':'').toString() + (currentdate.getMinutes()).toString() ) + ":"
  145. + ( (currentdate.getSeconds()<10?'0':'').toString() + (currentdate.getSeconds()).toString() );
  146. */
  147. $("#page_info").text(datetime);
  148. console.log(datetime);
  149. },
  150. error: function () {
  151. console.log("Error.")
  152. }
  153. });
  154. }
  155. });
  156. </script>
  157. </body>
  158. </html>