index.php 3.99 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
 * @var \yii\debug\Panel[] $panels
Qiang Xue committed
13
 */
Qiang Xue committed
14

Qiang Xue committed
15
$this->title = 'Yii Debugger';
Qiang Xue committed
16
?>
Qiang Xue committed
17
<div class="default-index">
18

19 20 21 22 23 24 25 26 27 28 29
    <div id="yii-debug-toolbar" class="yii-debug-toolbar-top">
        <div class="yii-debug-toolbar-block title">
            <a href="#">
                <img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
                Yii Debugger
            </a>
        </div>
        <?php foreach ($panels as $panel): ?>
            <?= $panel->getSummary() ?>
        <?php endforeach; ?>
    </div>
30

31 32
    <div class="container">
        <div class="row">
33 34
<?php

35
if (isset($this->context->module->panels['db']) && isset($this->context->module->panels['request'])) {
36

37 38 39 40 41 42 43 44
    echo "			<h1>Available Debug Data</h1>";
    $timeFormatter = extension_loaded('intl') ? Yii::createObject(['class' => 'yii\i18n\Formatter']) : Yii::$app->formatter;

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

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
            if ($searchModel->isCodeCritical($model['statusCode']) || $dbPanel->isQueryCountCritical($model['sqlCount'])) {
                return ['class'=>'danger'];
            } else {
                return [];
            }
        },
        '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'], 'short');
                },
            ],
            'ip',
            [
                'attribute' => 'sqlCount',
                'label' => 'Query Count',
                'value' => function ($data) {
                    $dbPanel = $this->context->module->panels['db'];
Mark committed
73

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

76
                        $content = Html::tag('b', $data['sqlCount']) . ' ' . Html::tag('span', '', ['class' => 'glyphicon glyphicon-exclamation-sign']);
Mark committed
77

78 79 80
                        return Html::a($content, ['view', 'panel' => 'db', 'tag' => $data['tag']], [
                            'title' => 'Too many queries. Allowed count is ' . $dbPanel->criticalQueryThreshold,
                        ]);
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
                    } else {
                        return $data['sqlCount'];
                    }
                },
                'format' => 'html',
            ],
            [
                'attribute' => 'mailCount',
                'visible' => isset($this->context->module->panels['mail']),
            ],
            [
                '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'],
            ],
            [
                'attribute' => 'url',
                'label' => 'URL',
            ],
            [
                'attribute' => 'statusCode',
                'filter' => [200 => 200, 404 => 404, 403 => 403, 500 => 500],
                'label' => 'Status code'
            ],
        ],
    ]);
114 115

} else {
116
    echo "<div class='alert alert-warning'>No data available. Panel <code>db</code> or <code>request</code> not found.</div>";
117 118 119
}

?>
120 121
        </div>
    </div>
Qiang Xue committed
122
</div>