userMonitor.blade.php 3.2 KB

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