index.htm 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <%+header%>
  2. <script type="text/javascript" src="<%=media%>/assets/js/highcharts.js"></script>
  3. <script type="text/javascript" src="<%=media%>/assets/js/dark-unica.js"></script>
  4. <style>
  5. .panel-body{padding:0px;}
  6. </style>
  7. <script>
  8. var _fan = 0;
  9. var _temp = 0;
  10. var _i = 50 ;
  11. var _ghsav = 0;
  12. var series = 0;
  13. var series1 = 0;
  14. function secondsToHms(d) {
  15. d = Number(d);
  16. var h = Math.floor(d / 3600);
  17. var m = Math.floor(d % 3600 / 60);
  18. var s = Math.floor(d % 3600 % 60);
  19. return ((h > 0 ? h + "h " : "") + ((m > 0 || h > 0) ? m + "m " : "") + s + "s");
  20. }
  21. function getstatus() {
  22. /**
  23. * Get Status
  24. * @author Wanggh
  25. */
  26. $.ajax({
  27. url:'<%=luci.dispatcher.build_url("avalon", "api", "getstatus")%>',
  28. type:'post',
  29. dataType: 'json',
  30. success: function(_data) {
  31. if (_data) {
  32. _fan = _data.fan !== undefined ? 100 * Math.floor(_data.fan/100) : 0;
  33. _temp = _data.temp !== undefined ? _data.temp : 0;
  34. _ghsav = _data.ghsav !== undefined ? _data.ghsav : 0;
  35. $('#ghsav').html(_data.ghsav !== undefined ? Math.round(_data.ghsav) + 'GHs' : '0GHs');
  36. $('#mac').html(_data.network.mac !== undefined ? _data.network.mac : '--');
  37. $('#ip4').html(_data.network.ip4 !== undefined ? _data.network.ip4 : '--');
  38. $('#ip6').html(_data.network.ip6 !== undefined ? _data.network.ip6 : '--');
  39. $('#ghsmm').html(_data.ghsmm !== undefined ? Math.round(_data.ghsmm) + 'GHs' : '0GHs');
  40. if (_data.pool[0]) {
  41. $('#pool').html(_data.pool[0].url !== undefined ? _data.pool[0].url : 'no-pool');
  42. $('#worker').html(_data.pool[0].user !== undefined ? _data.pool[0].user : '--');
  43. $('#accept').html(_data.pool[0].accept !== undefined ? _data.pool[0].accept : 'no-accept');
  44. }
  45. $("#modularcnt").html(_data.modularcnt !== undefined ? _data.modularcnt : 0);
  46. $("#voltage").html(_data.voltage !== undefined ? _data.voltage.toFixed(1) + 'V' : '--');
  47. $("#temp").html(_data.temp !== undefined ? _data.temp + '&deg;C' : '--');
  48. $("#fan").html(_data.fan !== undefined ? 100 * Math.floor(_data.fan/100) + 'RPM' : '--');
  49. $("#openwrtver").html(_data.openwrtver !== undefined ? _data.openwrtver : '--');
  50. $("#time").html(_data.systime !== undefined ? _data.systime : '--');
  51. $("#elapsed").html(_data.elapsed !== undefined ? secondsToHms(_data.elapsed) : '--');
  52. }
  53. },
  54. });
  55. var x = (new Date()).getTime(),
  56. y = _fan;
  57. y1 = _ghsav;
  58. series.addPoint([x, y], true, true);
  59. series1.addPoint([x, y1], true, true);
  60. }
  61. $(function () {
  62. var _intvalTime = 5000;
  63. Highcharts.setOptions({
  64. global: {
  65. useUTC: false
  66. }
  67. });
  68. var chart;
  69. chart = new Highcharts.Chart({
  70. chart: {
  71. renderTo: 'container-speed-fan',
  72. type: 'spline',
  73. animation: Highcharts.svg,
  74. events: {
  75. load: function() {
  76. // set up the updating of the chart each second
  77. series = this.series[0];
  78. series1 = this.series[1];
  79. getstatus();
  80. setInterval(function() {
  81. getstatus();
  82. }, _intvalTime);
  83. }
  84. }
  85. },
  86. title: {text: 'Active Charts'},
  87. subtitle: {text: 'Update every 5 seconds'},
  88. xAxis: {
  89. type: 'datetime',
  90. tickPixelInterval: 150
  91. },
  92. credits: {enabled: false},
  93. yAxis: [{
  94. labels: {
  95. formatter: function() {
  96. return this.value +'GHs';
  97. },
  98. style: {color: '#90ec7d'}
  99. },
  100. title: {
  101. text: 'GHS av',
  102. style: {color: '#90ec7d'}
  103. },
  104. opposite: true,
  105. }, {
  106. labels: {
  107. formatter: function() {
  108. return this.value +'RPM';
  109. },
  110. style: {color: '#7cb5ec'}
  111. },
  112. title: {
  113. text: 'Fan',
  114. style: {color: '#7cb5ec'}
  115. },
  116. }],
  117. tooltip: {
  118. shared: true,
  119. formatter : function() {
  120. var s = '';
  121. $.each(this.points, function() {
  122. switch(this.series.name) {
  123. case 'Fan':
  124. s +=this.series.name + ':' + this.y + 'RPM';
  125. break;
  126. case 'GHS av':
  127. s +=this.series.name + ':' + this.y + 'GHs';
  128. default :
  129. break;
  130. }
  131. s +='<br>';
  132. })
  133. return s;
  134. }
  135. },
  136. legend: {
  137. layout: 'vertical',
  138. align: 'left',
  139. x: 120,
  140. verticalAlign: 'top',
  141. floating: true,
  142. backgroundColor: '#2f2f31'
  143. },
  144. exporting: {enabled: false},
  145. series: [{
  146. yAxis:1,
  147. color: '#7cb5ec',
  148. name: 'Fan',
  149. data: (function() { // generate an array of random data
  150. var data = [],
  151. time = (new Date()).getTime(),
  152. i;
  153. for (i = -_i; i <= 0; i++) {
  154. data.push({
  155. x: time + i * 1000,
  156. y: null
  157. });
  158. }
  159. return data;
  160. })(),
  161. tooltip: {valueSuffix: ' RPM'},
  162. marker: {enabled: false},
  163. dashStyle: 'shortdot',
  164. }, {
  165. color: '#90ec7d',
  166. name: 'GHS av',
  167. data: (function() { // generate an array of random data
  168. var data = [],
  169. time = (new Date()).getTime(),
  170. i;
  171. for (i = -_i; i <= 0; i++) {
  172. data.push({
  173. x: time + i * 1000,
  174. y: null
  175. });
  176. }
  177. return data;
  178. })() ,
  179. tooltip: {valueSuffix: 'GHs'},
  180. marker: {enabled: false},
  181. }]
  182. });
  183. });
  184. </script>
  185. <h2><a id="content" name="content">Dashboard</a></h2>
  186. <div id="page-inner">
  187. <div class="row margin-left-right-0 margin-top-20 cginfo">
  188. <div class="col-md-6 col-sm-6">
  189. <div class="bg-color-333 height-148 cginfo-padding">
  190. <h2>Network Information <span><a href="#"> <a href="<%=luci.dispatcher.build_url("avalon", "page", "network")%>"> > Quick setting</a></a></span></h2>
  191. <p><strong>MAC Address: </strong> <span id='mac'>--</span></p>
  192. <p><strong>IPv4: </strong> <span id='ip4'>--</span></p>
  193. <p><strong>IPv6: </strong> <span id='ip6'>--</span></p>
  194. </div>
  195. </div>
  196. <div class="col-md-6 col-sm-6">
  197. <div class="bg-color-333 height-148 cginfo-padding">
  198. <h2>Overview</h2>
  199. <p>Controller Version: <span id="openwrtver">--</span></p>
  200. <p>Time: <span id="time">--</span></p>
  201. <p>CGMiner Elapsed: <span id="elapsed">0</span></p>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="row margin-left-right-0 margin-top-20 cginfo">
  206. <div class="col-md-2 col-sm-2">
  207. <div class="bg-color-333 height-148 cginfo-padding">
  208. <h2>Hash Rate</h2>
  209. <p>GHS av: <span id="ghsav">0GHs</span></p>
  210. <p>GHS: <span id="ghsmm">0GHs</span></p>
  211. </div>
  212. </div>
  213. <div class="col-md-4 col-sm-4">
  214. <div class="bg-color-333 height-148 cginfo-padding">
  215. <h2>Current Pool <span><a href="<%=luci.dispatcher.build_url("avalon", "page", "configure")%>"> > Quick setting</a></span></h2>
  216. <p id='pool'>--</p>
  217. <p>Worker: <span id='worker'>--</span> | Accepted: <span id='accept'>--</span></p>
  218. </div>
  219. </div>
  220. <div class="col-md-6 col-sm-6">
  221. <div class="bg-color-333 height-148 cginfo-padding">
  222. <h2>Modules Information </h2>
  223. <p>Alive Modules: <span id='modularcnt'>0</span> | Input Voltage: <span id='voltage'>0</span> | Smart Speed: <span>Enable</span></p>
  224. <p>Temperature: <span id='temp'>0</span> | Fan: <span id='fan'>0</span></p>
  225. </div>
  226. </div>
  227. </div>
  228. <!-- /. ROW -->
  229. <hr />
  230. <!--jackie start-->
  231. <div class="row margin-left-right-0" >
  232. <!--风扇转速start-->
  233. <div class="col-md-12 col-sm-12 col-xs-12">
  234. <div class="panel panel-default">
  235. <div class="panel-heading">
  236. <strong>Fan / GHS av</strong>
  237. </div>
  238. <div class="panel-body">
  239. <div class="table-responsive">
  240. <div id="container-speed-fan" style="height:400px"></div>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. <!--风扇转速end-->
  246. </div>
  247. <!-- jackie end-->
  248. <!-- /. ROW -->
  249. </div>
  250. <%+footer%>