您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

150 行
5.1KB

  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\data\ArrayDataProvider;
  8. use yii\grid\GridView;
  9. use yii\helpers\Html;
  10. $this->title = 'Yii Debugger';
  11. ?>
  12. <div class="default-index">
  13. <div id="yii-debug-toolbar" class="yii-debug-toolbar yii-debug-toolbar_position_top" style="display: none;">
  14. <div class="yii-debug-toolbar__bar">
  15. <div class="yii-debug-toolbar__block yii-debug-toolbar__title">
  16. <a href="#">
  17. <img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
  18. </a>
  19. </div>
  20. <?php foreach ($panels as $panel): ?>
  21. <?= $panel->getSummary() ?>
  22. <?php endforeach; ?>
  23. </div>
  24. </div>
  25. <div class="container">
  26. <div class="row">
  27. <?php
  28. if (isset($this->context->module->panels['db']) && isset($this->context->module->panels['request'])) {
  29. echo " <h1>Available Debug Data</h1>";
  30. $codes = [];
  31. foreach ($manifest as $tag => $vals) {
  32. if (!empty($vals['statusCode'])) {
  33. $codes[] = $vals['statusCode'];
  34. }
  35. }
  36. $codes = array_unique($codes, SORT_NUMERIC);
  37. $statusCodes = !empty($codes) ? array_combine($codes, $codes) : null;
  38. echo GridView::widget([
  39. 'dataProvider' => $dataProvider,
  40. 'filterModel' => $searchModel,
  41. 'rowOptions' => function ($model, $key, $index, $grid) use ($searchModel) {
  42. $dbPanel = $this->context->module->panels['db'];
  43. if ($searchModel->isCodeCritical($model['statusCode']) || $dbPanel->isQueryCountCritical($model['sqlCount'])) {
  44. return ['class'=>'danger'];
  45. } else {
  46. return [];
  47. }
  48. },
  49. 'columns' => [
  50. ['class' => 'yii\grid\SerialColumn'],
  51. [
  52. 'attribute' => 'tag',
  53. 'value' => function ($data) {
  54. return Html::a($data['tag'], ['view', 'tag' => $data['tag']]);
  55. },
  56. 'format' => 'html',
  57. ],
  58. [
  59. 'attribute' => 'time',
  60. 'value' => function ($data) {
  61. return '<span class="nowrap">' . Yii::$app->formatter->asDatetime($data['time'], 'yyyy-MM-dd HH:mm:ss') . '</span>';
  62. },
  63. 'format' => 'html',
  64. ],
  65. 'ip',
  66. [
  67. 'attribute' => 'sqlCount',
  68. 'label' => 'Query Count',
  69. 'value' => function ($data) {
  70. $dbPanel = $this->context->module->panels['db'];
  71. if ($dbPanel->isQueryCountCritical($data['sqlCount'])) {
  72. $content = Html::tag('b', $data['sqlCount']) . ' ' . Html::tag('span', '', ['class' => 'glyphicon glyphicon-exclamation-sign']);
  73. return Html::a($content, ['view', 'panel' => 'db', 'tag' => $data['tag']], [
  74. 'title' => 'Too many queries. Allowed count is ' . $dbPanel->criticalQueryThreshold,
  75. ]);
  76. } else {
  77. return $data['sqlCount'];
  78. }
  79. },
  80. 'format' => 'html',
  81. ],
  82. [
  83. 'attribute' => 'mailCount',
  84. 'visible' => isset($this->context->module->panels['mail']),
  85. ],
  86. [
  87. 'attribute' => 'method',
  88. 'filter' => ['get' => 'GET', 'post' => 'POST', 'delete' => 'DELETE', 'put' => 'PUT', 'head' => 'HEAD']
  89. ],
  90. [
  91. 'attribute'=>'ajax',
  92. 'value' => function ($data) {
  93. return $data['ajax'] ? 'Yes' : 'No';
  94. },
  95. 'filter' => ['No', 'Yes'],
  96. ],
  97. [
  98. 'attribute' => 'url',
  99. 'label' => 'URL',
  100. ],
  101. [
  102. 'attribute' => 'statusCode',
  103. 'value' => function ($data) {
  104. $statusCode = $data['statusCode'];
  105. if ($statusCode === null) {
  106. $statusCode = 200;
  107. }
  108. if ($statusCode >= 200 && $statusCode < 300) {
  109. $class = 'label-success';
  110. } elseif ($statusCode >= 300 && $statusCode < 400) {
  111. $class = 'label-info';
  112. } else {
  113. $class = 'label-danger';
  114. }
  115. return "<span class=\"label {$class}\">$statusCode</span>";
  116. },
  117. 'format' => 'raw',
  118. 'filter' => $statusCodes,
  119. 'label' => 'Status code'
  120. ],
  121. ],
  122. ]);
  123. } else {
  124. echo "<div class='alert alert-warning'>No data available. Panel <code>db</code> or <code>request</code> not found.</div>";
  125. }
  126. ?>
  127. </div>
  128. </div>
  129. </div>
  130. <script type="text/javascript">
  131. if (!window.frameElement) {
  132. document.querySelector('#yii-debug-toolbar').style.display = 'block';
  133. }
  134. </script>