index.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  5. <title>IBM AI Server Viewer 1.0</title>
  6. <style>
  7. table {
  8. border-collapse: collapse;
  9. }
  10. th, td {
  11. border: 1px solid gray;
  12. padding-left: 5px;
  13. padding-right: 10px;
  14. padding-top: 2px;
  15. padding-bottom: 2px;
  16. }
  17. th {
  18. text-align: left;
  19. }
  20. td {
  21. text-align: center;
  22. }
  23. </style>
  24. <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
  25. <script type="text/javascript">
  26. function refreshStatus() {
  27. $.get("/api/service/status",function(data, status){
  28. data = JSON.parse(data);
  29. var result = data.content;
  30. $("#datas tr:gt(1)").remove();
  31. $.each(result, function (i, n) {
  32. var ss = result[i];
  33. var row = $("#template").clone();
  34. row.find("#name").text(ss.name);
  35. row.id = "tr"+i;
  36. row.show();
  37. var st="";
  38. if (ss.status == 0) {
  39. st = "<font color='green'>Running</font>";
  40. } else {
  41. st = "<font color='green'>Stopped</font>";
  42. }
  43. row.find("#status").html(st);
  44. row.find("#connections").text(ss.connections);
  45. row.find("#times").text(ss.times);
  46. row.find("#timestamp").text(new Date(parseInt(ss.timestamp)*1000).toLocaleString());
  47. row.appendTo("#datas");
  48. });
  49. $('#template').hide();
  50. });
  51. }
  52. function refreshLog() {
  53. $.get("/api/service/log",function(data, status){
  54. $('#log').html(data);
  55. });
  56. }
  57. $(document).ready(function(){
  58. $("#btnStatus").click(function(){
  59. refreshStatus();
  60. });
  61. $("#btnLog").click(function(){
  62. // $.ajax({
  63. // url: '/api/pred',
  64. // method: 'POST',
  65. // // dataType: 'json',
  66. // data: "{ \"catagory\":\"SS\", \"type\":\"SS\", \"status\":\"SS\", \"magnification\":\"SS\", \"func\":\"SS\", \"src_img_path\":\"D:\\\\py-faster-rcnn\\\\data\\\\demo\\\\000456测试.jpg\" }",
  67. // success: function(json) {
  68. // console.log("post rsp: ", json);
  69. // $('#result1').html(json);
  70. // }
  71. // });
  72. refreshLog();
  73. });
  74. });
  75. $(window).load(function(){
  76. refreshStatus();
  77. refreshLog();
  78. });
  79. // websocket
  80. var websocket = new WebSocket('ws://' + location.host + '/ws');
  81. websocket.onopen = function (ev) {
  82. console.log(ev.data);
  83. };
  84. websocket.onerror = function (ev) {
  85. console.log(ev.data);
  86. };
  87. websocket.onclose = function (ev) {
  88. console.log(ev.data);
  89. };
  90. websocket.onmessage = function (ev) {
  91. console.log(ev.data);
  92. document.getElementById("ws_text").innerHTML = ev.data;
  93. };
  94. window.onload = function () {
  95. document.getElementById('send_button').onclick = function (ev) {
  96. var msg = document.getElementById('send_input').value;
  97. websocket.send(msg);
  98. };
  99. };
  100. </script>
  101. </head>
  102. <body>
  103. <h3>IBM AI Server Overview 1.0</h3>
  104. <label>Service Status:</label>
  105. <button id="btnStatus">Refresh</button>
  106. <table id="datas">
  107. <tr id="0">
  108. <th>Service Name</th>
  109. <th>Running Status</th>
  110. <th>Connection(s)</th>
  111. <th>Exec Times</th>
  112. <th>Starting Time</th>
  113. <!--<th>Action</th>-->
  114. </tr>
  115. <tr id="template">
  116. <th id="name"></th>
  117. <td id="status"></td>
  118. <td id="connections"></td>
  119. <td id="times"></td>
  120. <td id="timestamp"></td>
  121. <!--<td><a href="">Stop</a> <a href="">Restart</a></td>-->
  122. </tr>
  123. </table>
  124. <h4>AI Service:</h4>
  125. <label>Model Count:</label> <span id="result1">&nbsp;</span>
  126. <label>Running Model:</label> <span id="result2">&nbsp;</span>
  127. <div style="clear:both" />
  128. <label>Logs:</label>
  129. <button id="btnLog">Refresh</button>
  130. <div style="clear:both" />
  131. <textarea id="log" style="width:100%;" name="yj" rows="20"></textarea>
  132. </body>
  133. </html>