monitor.blade.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. @extends('admin.layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h2 class="panel-title">{{ trans('admin.monitor.node') }}</h2>
  7. </div>
  8. <div class="alert alert-info alert-dismissible">
  9. <button class="close" data-dismiss="alert" aria-label="{{ trans('common.close') }}">
  10. <span aria-hidden="true">&times;</span><span class="sr-only">{{trans('common.close')}}</span>
  11. </button>
  12. <h4 class="block">{{$nodeName}}
  13. <small class="pl-10">{{$nodeServer}}</small>
  14. </h4>
  15. {!! trans('admin.monitor.hint') !!}
  16. </div>
  17. <div class="panel-body">
  18. <div class="row">
  19. <div class="col-md-6">
  20. <canvas id="dailyChart" aria-label="{{ trans('admin.monitor.daily_chart') }}" role="img"></canvas>
  21. </div>
  22. <div class="col-md-6">
  23. <canvas id="monthlyChart" aria-label="{{ trans('admin.monitor.monthly_chart') }}" role="img"></canvas>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. @endsection
  30. @section('javascript')
  31. <script src="/assets/global/vendor/chart-js/chart.min.js"></script>
  32. <script>
  33. function common_options(tail) {
  34. return {
  35. responsive: true,
  36. scales: {
  37. x: {
  38. ticks: {
  39. callback: function(value) {
  40. return this.getLabelForValue(value) + ' ' + tail;
  41. },
  42. },
  43. grid: {
  44. display: false,
  45. },
  46. },
  47. y: {
  48. ticks: {
  49. callback: function(value) {
  50. return this.getLabelForValue(value) + ' GB';
  51. },
  52. },
  53. grid: {
  54. display: false,
  55. },
  56. min: 0,
  57. },
  58. },
  59. plugins: {
  60. legend: false,
  61. tooltip: {
  62. mode: 'index',
  63. intersect: false,
  64. callbacks: {
  65. title: function(context) {
  66. return context[0].label + ' ' + tail;
  67. },
  68. label: function(context) {
  69. return context.parsed.y + ' GB';
  70. },
  71. },
  72. },
  73. },
  74. };
  75. }
  76. function datasets(label, data) {
  77. return {
  78. labels: label,
  79. datasets: [
  80. {
  81. backgroundColor: 'rgba(184, 215, 255)',
  82. borderColor: 'rgba(184, 215, 255)',
  83. data: data,
  84. tension: 0.4,
  85. }],
  86. };
  87. }
  88. new Chart(document.getElementById('dailyChart'), {
  89. type: 'line',
  90. data: datasets(@json($dayHours), @json($trafficHourly)),
  91. options: common_options(@json(trans_choice('common.hour', 2))),
  92. });
  93. new Chart(document.getElementById('monthlyChart'), {
  94. type: 'line',
  95. data: datasets(@json($monthDays), @json($trafficDaily)),
  96. options: common_options(@json(trans_choice('common.days.attribute', 2))),
  97. });
  98. </script>
  99. @endsection