index.php 2.65 KB
Newer Older
Qiang Xue committed
1 2 3
<?php

use yii\helpers\Html;
4 5
use yii\grid\GridView;
use yii\data\ArrayDataProvider;
Qiang Xue committed
6 7

/**
Alexander Makarov committed
8
 * @var \yii\web\View $this
Qiang Xue committed
9
 * @var array $manifest
Qiang Xue committed
10 11
 * @var \yii\debug\models\search\Debug $searchModel
 * @var ArrayDataProvider $dataProvider
Qiang Xue committed
12
 */
Qiang Xue committed
13

Qiang Xue committed
14
$this->title = 'Yii Debugger';
Qiang Xue committed
15
?>
Qiang Xue committed
16
<div class="default-index">
17
	<div id="yii-debug-toolbar" class="yii-debug-toolbar-top">
Tobias Munk committed
18 19 20 21 22
		<div class="yii-debug-toolbar-block title">
			<a href="<?= Yii::$app->homeUrl ?>">
				<span class="glyphicon glyphicon-home"></span>
			</a>
		</div>
23 24
		<div class="yii-debug-toolbar-block title">
			Yii Debugger
Qiang Xue committed
25 26
		</div>
	</div>
Qiang Xue committed
27

28 29
	<div class="container">
		<div class="row">
Qiang Xue committed
30
			<h1>Available Debug Data</h1>
31 32 33 34 35 36 37 38

<?php

$timeFormatter = extension_loaded('intl') ? Yii::createObject(['class' => 'yii\i18n\Formatter']) : Yii::$app->formatter;

echo GridView::widget([
	'dataProvider' => $dataProvider,
	'filterModel' => $searchModel,
Qiang Xue committed
39
	'rowOptions' => function ($model, $key, $index, $grid) use ($searchModel) {
Mark committed
40 41
		$dbPanel = $this->context->module->panels['db'];

42
		if ($searchModel->isCodeCritical($model['statusCode']) || $dbPanel->isQueryCountCritical($model['sqlCount'])) {
43
			return ['class'=>'danger'];
Qiang Xue committed
44 45 46
		} else {
			return [];
		}
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
	},
	'columns' => [
		['class' => 'yii\grid\SerialColumn'],
		[
			'attribute' => 'tag',
			'value' => function ($data)
			{
				return Html::a($data['tag'], ['view', 'tag' => $data['tag']]);
			},
			'format' => 'html',
		],
		[
			'attribute' => 'time',
			'value' => function ($data) use ($timeFormatter)
			{
				return $timeFormatter->asDateTime($data['time'], 'long');
			},
		],
		'ip',
		[
			'attribute' => 'sqlCount',
Qiang Xue committed
68
			'label' => 'Total queries',
Mark committed
69 70 71
			'value' => function ($data) {
				$dbPanel = $this->context->module->panels['db'];

72
				if ($dbPanel->isQueryCountCritical($data['sqlCount'])) {
Mark committed
73 74

					$content = Html::tag('b', $data['sqlCount']) . ' ' . Html::tag('span','',['class' => 'glyphicon glyphicon-exclamation-sign']);
Sergey Gonimar committed
75
					return Html::a($content, ['view', 'panel' => 'db', 'tag' => $data['tag']], [
76
						'title' => 'Too many queries. Allowed count is ' . $dbPanel->criticalQueryThreshold,
Mark committed
77 78 79 80 81 82 83
					]);

				} else {
					return $data['sqlCount'];
				}
			},
			'format' => 'html',
84 85 86 87 88 89 90 91 92 93 94 95 96
		],
		[
			'attribute' => 'method',
			'filter' => ['get' => 'GET', 'post' => 'POST', 'delete' => 'DELETE', 'put' => 'PUT', 'head' => 'HEAD']
		],
		[
			'attribute'=>'ajax',
			'value' => function ($data)
			{
				return $data['ajax'] ? 'Yes' : 'No';
			},
			'filter' => ['No', 'Yes'],
		],
Qiang Xue committed
97 98 99 100
		[
			'attribute' => 'url',
			'label' => 'URL',
		],
101 102
		[
			'attribute' => 'statusCode',
Qiang Xue committed
103
			'filter' => [200 => 200, 404 => 404, 403 => 403, 500 => 500],
104 105 106 107
			'label' => 'Status code'
		],
	],
]); ?>
Qiang Xue committed
108 109
		</div>
	</div>
Qiang Xue committed
110
</div>