index.php 4.06 KB
Newer Older
Qiang Xue committed
1 2
<?php
/**
Alexander Makarov committed
3
 * @var \yii\web\View $this
Qiang Xue committed
4
 * @var array $manifest
Qiang Xue committed
5 6
 * @var \yii\debug\models\search\Debug $searchModel
 * @var ArrayDataProvider $dataProvider
Qiang Xue committed
7
 * @var \yii\debug\Panel[] $panels
Qiang Xue committed
8
 */
Qiang Xue committed
9

10 11 12 13
use yii\helpers\Html;
use yii\grid\GridView;
use yii\data\ArrayDataProvider;

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

18 19 20 21 22 23 24 25 26 27 28
    <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>
29

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

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

36 37 38 39 40 41 42 43
    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
44

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
            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) {
63
                    return '<span class="nowrap">' . $timeFormatter->asDateTime($data['time'], 'short') . '</span>';
64
                },
65
                'format' => 'html',
66 67 68 69 70 71 72
            ],
            '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>