monitor.blade.php 3.4 KB

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