monitor.blade.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. @extends('admin.layouts')
  2. @section('css')
  3. @endsection
  4. @section('title', '控制面板')
  5. @section('content')
  6. <!-- BEGIN CONTENT BODY -->
  7. <div class="page-content">
  8. <!-- BEGIN PAGE BREADCRUMB -->
  9. <ul class="page-breadcrumb breadcrumb">
  10. <li>
  11. <a href="{{url('admin/userList')}}">账号管理</a>
  12. <i class="fa fa-circle"></i>
  13. </li>
  14. <li>
  15. <a href="{{url('admin/monitor')}}">流量监控</a>
  16. </li>
  17. </ul>
  18. <!-- END PAGE BREADCRUMB -->
  19. <!-- BEGIN PAGE BASE CONTENT -->
  20. <div class="row">
  21. <div class="col-md-12">
  22. <div class="portlet light portlet-fit bordered">
  23. <div class="portlet-title">
  24. <div class="caption">
  25. <i class="icon-settings font-dark"></i>
  26. <span class="caption-subject font-dark sbold uppercase">节点流量(近30天)</span>
  27. </div>
  28. </div>
  29. <div class="portlet-body">
  30. <div id="chart" class="chart"> </div>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <!-- END PAGE BASE CONTENT -->
  36. </div>
  37. <!-- END CONTENT BODY -->
  38. @endsection
  39. @section('script')
  40. <script src="/assets/global/plugins/flot/jquery.flot.min.js" type="text/javascript"></script>
  41. <script src="/assets/global/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
  42. <script src="/assets/global/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
  43. <script type="text/javascript">
  44. var ChartsFlotcharts = function() {
  45. return {
  46. init: function() {
  47. App.addResizeHandler(function() {
  48. Charts.initPieCharts();
  49. });
  50. },
  51. initCharts: function() {
  52. if (!jQuery.plot) {
  53. return;
  54. }
  55. function chart() {
  56. if ($('#chart').size() != 1) {
  57. return;
  58. }
  59. @if (!empty($traffic))
  60. @foreach ($traffic as $node_id => $node_traffic_list)
  61. {{ 'var node_' . $node_id}} = [
  62. @foreach ($node_traffic_list as $key => $vo)
  63. [{{$key + 1}}, {{$vo->total}}],
  64. @endforeach
  65. ];
  66. @endforeach
  67. @endif
  68. var plot = $.plot($("#chart"), [
  69. @if (!empty($traffic))
  70. @foreach($traffic as $node_id => $node_traffic_list)
  71. {data: {{'node_' . $node_id}}, label: "节点{{$node_id}}", lines: {lineWidth: 1}, shadowSize: 0},
  72. @endforeach
  73. @endif
  74. ], {
  75. series: {
  76. lines: {
  77. show: true,
  78. lineWidth: 2,
  79. fill: true,
  80. fillColor: {
  81. colors: [{
  82. opacity: 0.05
  83. }, {
  84. opacity: 0.01
  85. }]
  86. }
  87. },
  88. points: {
  89. show: true,
  90. radius: 3,
  91. lineWidth: 1
  92. },
  93. shadowSize: 2
  94. },
  95. grid: {
  96. hoverable: true,
  97. clickable: true,
  98. tickColor: "#eee",
  99. borderColor: "#eee",
  100. borderWidth: 1
  101. },
  102. colors: ["#d12610", "#37b7f3", "#52e136"],
  103. xaxis: {
  104. ticks: 11,
  105. tickDecimals: 0,
  106. tickColor: "#eee",
  107. },
  108. yaxis: {
  109. ticks: 11,
  110. tickDecimals: 0,
  111. tickColor: "#eee",
  112. }
  113. });
  114. function showTooltip(x, y, contents) {
  115. $('<div id="tooltip">' + contents + '</div>').css({
  116. position: 'absolute',
  117. display: 'none',
  118. top: y + 5,
  119. left: x + 15,
  120. border: '1px solid #333',
  121. padding: '4px',
  122. color: '#fff',
  123. 'border-radius': '3px',
  124. 'background-color': '#333',
  125. opacity: 0.80
  126. }).appendTo("body").fadeIn(200);
  127. }
  128. var previousPoint = null;
  129. $("#chart").bind("plothover", function(event, pos, item) {
  130. $("#x").text(pos.x.toFixed(2));
  131. $("#y").text(pos.y.toFixed(2));
  132. if (item) {
  133. if (previousPoint != item.dataIndex) {
  134. previousPoint = item.dataIndex;
  135. $("#tooltip").remove();
  136. var x = item.datapoint[0].toFixed(2),
  137. y = item.datapoint[1].toFixed(2);
  138. showTooltip(item.pageX, item.pageY, item.series.label + ": " + y + 'M');
  139. }
  140. } else {
  141. $("#tooltip").remove();
  142. previousPoint = null;
  143. }
  144. });
  145. }
  146. chart();
  147. }
  148. };
  149. }();
  150. jQuery(document).ready(function() {
  151. ChartsFlotcharts.init();
  152. ChartsFlotcharts.initCharts();
  153. });
  154. </script>
  155. @endsection