monitor.blade.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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" role="img" aria-label="{{ trans('admin.monitor.daily_chart') }}"></canvas>
  21. </div>
  22. <div class="col-md-6">
  23. <canvas id="monthlyChart" role="img" aria-label="{{ trans('admin.monitor.monthly_chart') }}"></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. backgroundColor: 'rgba(184, 215, 255)',
  81. borderColor: 'rgba(184, 215, 255)',
  82. data: data,
  83. tension: 0.4,
  84. }],
  85. };
  86. }
  87. new Chart(document.getElementById('dailyChart'), {
  88. type: 'line',
  89. data: datasets(@json($dayHours), @json($trafficHourly)),
  90. options: common_options(@json(trans_choice('common.hour', 2))),
  91. });
  92. new Chart(document.getElementById('monthlyChart'), {
  93. type: 'line',
  94. data: datasets(@json($monthDays), @json($trafficDaily)),
  95. options: common_options(@json(trans_choice('common.days.attribute', 2))),
  96. });
  97. </script>
  98. @endsection