You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /* @var $this \yii\web\View */
  3. /* @var $manifest array */
  4. /* @var $searchModel \yii\debug\models\search\Debug */
  5. /* @var $dataProvider ArrayDataProvider */
  6. /* @var $panels \yii\debug\Panel[] */
  7. use yii\helpers\Html;
  8. use yii\grid\GridView;
  9. use yii\data\ArrayDataProvider;
  10. $this->title = 'Yii Debugger';
  11. ?>
  12. <div class="default-index">
  13. <div id="yii-debug-toolbar" class="yii-debug-toolbar-top">
  14. <div class="yii-debug-toolbar-block title">
  15. <a href="#">
  16. <img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
  17. Yii Debugger
  18. </a>
  19. </div>
  20. <?php foreach ($panels as $panel): ?>
  21. <?= $panel->getSummary() ?>
  22. <?php endforeach; ?>
  23. </div>
  24. <div class="container">
  25. <div class="row">
  26. <?php
  27. if (isset($this->context->module->panels['db']) && isset($this->context->module->panels['request'])) {
  28. echo " <h1>Available Debug Data</h1>";
  29. $codes = [];
  30. foreach ($manifest as $tag => $vals) {
  31. if (!empty($vals['statusCode'])) {
  32. $codes[] = $vals['statusCode'];
  33. }
  34. }
  35. $codes = array_unique($codes, SORT_NUMERIC);
  36. $statusCodes = !empty($codes) ? array_combine($codes, $codes) : null;
  37. echo GridView::widget([
  38. 'dataProvider' => $dataProvider,
  39. 'filterModel' => $searchModel,
  40. 'rowOptions' => function ($model, $key, $index, $grid) use ($searchModel) {
  41. $dbPanel = $this->context->module->panels['db'];
  42. if ($searchModel->isCodeCritical($model['statusCode']) || $dbPanel->isQueryCountCritical($model['sqlCount'])) {
  43. return ['class'=>'danger'];
  44. } else {
  45. return [];
  46. }
  47. },
  48. 'columns' => [
  49. ['class' => 'yii\grid\SerialColumn'],
  50. [
  51. 'attribute' => 'tag',
  52. 'value' => function ($data) {
  53. return Html::a($data['tag'], ['view', 'tag' => $data['tag']]);
  54. },
  55. 'format' => 'html',
  56. ],
  57. [
  58. 'attribute' => 'time',
  59. 'value' => function ($data) {
  60. return '<span class="nowrap">' . Yii::$app->formatter->asDatetime($data['time'], 'short') . '</span>';
  61. },
  62. 'format' => 'html',
  63. ],
  64. 'ip',
  65. [
  66. 'attribute' => 'sqlCount',
  67. 'label' => 'Query Count',
  68. 'value' => function ($data) {
  69. $dbPanel = $this->context->module->panels['db'];
  70. if ($dbPanel->isQueryCountCritical($data['sqlCount'])) {
  71. $content = Html::tag('b', $data['sqlCount']) . ' ' . Html::tag('span', '', ['class' => 'glyphicon glyphicon-exclamation-sign']);
  72. return Html::a($content, ['view', 'panel' => 'db', 'tag' => $data['tag']], [
  73. 'title' => 'Too many queries. Allowed count is ' . $dbPanel->criticalQueryThreshold,
  74. ]);
  75. } else {
  76. return $data['sqlCount'];
  77. }
  78. },
  79. 'format' => 'html',
  80. ],
  81. [
  82. 'attribute' => 'mailCount',
  83. 'visible' => isset($this->context->module->panels['mail']),
  84. ],
  85. [
  86. 'attribute' => 'method',
  87. 'filter' => ['get' => 'GET', 'post' => 'POST', 'delete' => 'DELETE', 'put' => 'PUT', 'head' => 'HEAD']
  88. ],
  89. [
  90. 'attribute'=>'ajax',
  91. 'value' => function ($data) {
  92. return $data['ajax'] ? 'Yes' : 'No';
  93. },
  94. 'filter' => ['No', 'Yes'],
  95. ],
  96. [
  97. 'attribute' => 'url',
  98. 'label' => 'URL',
  99. ],
  100. [
  101. 'attribute' => 'statusCode',
  102. 'filter' => $statusCodes,
  103. 'label' => 'Status code'
  104. ],
  105. ],
  106. ]);
  107. } else {
  108. echo "<div class='alert alert-warning'>No data available. Panel <code>db</code> or <code>request</code> not found.</div>";
  109. }
  110. ?>
  111. </div>
  112. </div>
  113. </div>