rt_online.tpl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>欢迎页面-X-admin2.0</title>
  6. <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  7. <script src="http://code.highcharts.com/highcharts.js"></script>
  8. </head>
  9. <body>
  10. 指定服务器:
  11. <input id="server_id" type="text" name="服务器ID" value={{.Server_id}}>
  12. <br>
  13. <br>
  14. 时间颗粒度(分钟):
  15. <input id="minutes" type="text" name="时间颗粒度" value={{.Minutes}}>
  16. <br>
  17. <br>
  18. 过往天数:
  19. <input id="days" type="text" name="天数" value={{.Days}}>
  20. <br>
  21. <br>
  22. <input class="layui-btn" type="button" onclick="submitUpdate()" value=刷新>
  23. <input class="layui-btn" type="button" onclick="submitDownload()" value=下载>
  24. <br><br>
  25. <div class="layui-row layui-col-space20">
  26. <div class="layui-col-md4">
  27. <!-- 给具体的内容设置背景颜色 -->
  28. <div style="background-color: powderblue">
  29. <h1 id="today_regist" style = "text-align:center;" value = "">
  30. <span id ="cur_online" style="font-size:20px;"> 当前在线 : 0 </span>
  31. </h1>
  32. </div>
  33. </div>
  34. </div>
  35. <br><br>
  36. <div id="container" style="width: 1600px; height: 800px; margin: 0 auto"></div>
  37. <script language="JavaScript">
  38. $(document).ready(function() {
  39. var chart = {
  40. type: 'spline'
  41. };
  42. var title = {
  43. text: '在线人数分布'
  44. };
  45. var subtitle = {
  46. text: 'Source: '
  47. };
  48. var xAxis = {
  49. title: {
  50. text: '时间'
  51. },
  52. tickPixelInterval: 1,
  53. categories: {{.Categories}}
  54. };
  55. var yAxis = {
  56. title: {
  57. text: '人数'
  58. },
  59. plotLines: [{
  60. value: 0,
  61. width: 1,
  62. color: '#808080'
  63. }]
  64. };
  65. var tooltip = {
  66. valueSuffix: '人'
  67. }
  68. var legend = {
  69. layout: 'vertical',
  70. align: 'right',
  71. verticalAlign: 'middle',
  72. borderWidth: 0
  73. };
  74. var series = [
  75. ];
  76. var list = {{.Series}}
  77. var onlineCount = {{.Online_count}};
  78. for ( var i= 0; i < list.length; i++){
  79. series.push({"name":list[i].Name, "data":eval(list[i].Data)})
  80. }
  81. updateCurrentOnline(onlineCount);
  82. var json = {};
  83. json.title = title;
  84. json.subtitle = subtitle;
  85. json.xAxis = xAxis;
  86. json.yAxis = yAxis;
  87. json.tooltip = tooltip;
  88. json.legend = legend;
  89. json.series = series;
  90. json.chart = chart;
  91. $('#container').highcharts(json);
  92. });
  93. function submitUpdate () {
  94. var sid = document.getElementById("server_id").value;
  95. var min = document.getElementById("minutes").value;
  96. var days = document.getElementById("days").value;
  97. var text = "server_id=" + encodeURI(sid) + "&minutes=" + encodeURI(min) + "&days=" + encodeURI(days) ;
  98. $.ajax({
  99. type:"get",
  100. url:"/rtonline?" + text,
  101. success:function (data) {
  102. // alert(data.status);
  103. if (data.status){
  104. window.location.href="/rtonline?"+text;
  105. }else{
  106. if (data.info){
  107. alert(data.info);
  108. }else{
  109. window.location.href="/rtonline?"+text;
  110. }
  111. }
  112. }
  113. });
  114. }
  115. function submitDownload () {
  116. var sid = document.getElementById("server_id").value;
  117. var min = document.getElementById("minutes").value;
  118. var days = document.getElementById("days").value;
  119. var text = "server_id=" + encodeURI(sid) + "&minutes=" + encodeURI(min) + "&days=" + encodeURI(days)+ "&querydata=rtonline";
  120. $.ajax({
  121. type:"get",
  122. url:"/rtonline?" + text,
  123. success:function (data) {
  124. // alert(data.status);
  125. if (data.status){
  126. window.location.href="/rtonline?"+text;
  127. }else{
  128. if (data.info){
  129. alert(data.info);
  130. }else{
  131. window.location.href="/rtonline?"+text;
  132. }
  133. }
  134. }
  135. });
  136. }
  137. function updateCurrentOnline (count) {
  138. document.getElementById('cur_online').innerText="当前在线: "+count;
  139. }
  140. </script>
  141. </body>
  142. </html>