ApiStationMng.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Api站点管理</title>
  8. <script src="Scripts/vue/vue.js"></script>
  9. <script src="Scripts/jquery/jquery.min.js"></script>
  10. <script src="Scripts/Sers/sers.apiClient.js"></script>
  11. <style>
  12. .line {
  13. border: 1px solid #cccccc;
  14. border-collapse: collapse;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <h1>Api站点管理</h1>
  20. <a href="#" onclick="apiStationFilter=null;reloadStations();" title="显示所有的Api站点">显示所有</a>
  21. <a href="#" onclick="apiStationFilter=apiStationFilter_OnlyOnline;reloadStations();" title="仅显示在线的Api站点(apiNodeCount不为0)(默认为仅显示在线)">仅显示在线</a>
  22. <div id="stations">
  23. <div v-for="station in stations" style="width:300px;height:250px; float:left;margin:2px;padding:4px;word-wrap:break-word;" class="line">
  24. {{station.stationName}} <br />
  25. calledCount err/sum: {{(station.counter||{}).errorCount}}/ {{(station.counter||{}).sumCount}}<br />
  26. qps:{{station.qps}} <br />
  27. apiServiceCount:{{station.apiServiceCount}} <br />
  28. apiNodeCount:{{station.apiNodeCount}} <br />
  29. activeApiNodeCount:{{station.activeApiNodeCount}} <br />
  30. 状态:{{station.status}}(正常、暂停)<br />
  31. 操作: <a href="#" @click="start(station)">打开</a> <a href="#" @click="pause(station)">暂停</a><br />
  32. </div>
  33. </div>
  34. <script>
  35. var stations = new Vue({
  36. el: '#stations',
  37. data: {
  38. stations: []
  39. }, methods: {
  40. start: function (station) {
  41. sers.apiClient.apiStation_start(station.stationName, function (data) {
  42. rendStations();
  43. });
  44. }, pause: function (station) {
  45. sers.apiClient.apiStation_pause(station.stationName, function (data) {
  46. rendStations();
  47. });
  48. }
  49. }
  50. });
  51. function apiStationFilter_OnlyOnline(apiStations) {
  52. return apiStations.filter(function (item) { return item.apiNodeCount; });
  53. }
  54. var apiStationFilter = apiStationFilter_OnlyOnline;
  55. function reloadStations() {
  56. sers.apiClient.apiStation_getAll(function (apiRet) {
  57. var apiStations = apiRet.data;
  58. if (apiStationFilter) apiStations = apiStationFilter(apiStations);
  59. stations.stations = apiStations;
  60. });
  61. }
  62. reloadStations();
  63. var intervals = [];
  64. function startRefreshTask() {
  65. var interval = setInterval(reloadStations, 2000);
  66. intervals.push(interval);
  67. }
  68. function stopRefreshTask() {
  69. for (var t in intervals) {
  70. clearInterval(intervals[t]);
  71. }
  72. intervals = [];
  73. }
  74. startRefreshTask();
  75. </script>
  76. </body>
  77. </html>