Browse Source

Merge pull request #2350 from schmunk42/feature/toolbar-ui-2

Feature/toolbar ui 2
tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
20fdbc38aa
  1. 1
      extensions/debug/DebugAsset.php
  2. 1
      extensions/debug/LogTarget.php
  3. 12
      extensions/debug/Module.php
  4. 12
      extensions/debug/controllers/DefaultController.php
  5. 27
      extensions/debug/panels/ConfigPanel.php
  6. 5
      extensions/debug/panels/DbPanel.php
  7. 4
      extensions/debug/panels/LogPanel.php
  8. 2
      extensions/debug/panels/ProfilingPanel.php
  9. 35
      extensions/debug/views/default/index.php
  10. 4
      extensions/debug/views/default/panels/config/detail.php
  11. 9
      extensions/debug/views/default/panels/config/summary.php
  12. 2
      extensions/debug/views/default/panels/profile/summary.php
  13. 16
      extensions/debug/views/default/toolbar.php
  14. 20
      extensions/debug/views/default/view.php

1
extensions/debug/DebugAsset.php

@ -6,6 +6,7 @@
*/ */
namespace yii\debug; namespace yii\debug;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**

1
extensions/debug/LogTarget.php

@ -154,5 +154,4 @@ class LogTarget extends Target
# / 2 because messages are in couple (begin/end) # / 2 because messages are in couple (begin/end)
return count($profileLogs['messages']) / 2; return count($profileLogs['messages']) / 2;
} }
} }

12
extensions/debug/Module.php

File diff suppressed because one or more lines are too long

12
extensions/debug/controllers/DefaultController.php

@ -39,7 +39,7 @@ class DefaultController extends Controller
public function actions() public function actions()
{ {
$actions = []; $actions = [];
foreach($this->module->panels as $panel) { foreach ($this->module->panels as $panel) {
$actions = array_merge($actions, $panel->actions); $actions = array_merge($actions, $panel->actions);
} }
return $actions; return $actions;
@ -50,7 +50,13 @@ class DefaultController extends Controller
$searchModel = new Debug(); $searchModel = new Debug();
$dataProvider = $searchModel->search($_GET, $this->getManifest()); $dataProvider = $searchModel->search($_GET, $this->getManifest());
// load latest request
$tags = array_keys($this->getManifest());
$tag = reset($tags);
$this->loadData($tag);
return $this->render('index', [ return $this->render('index', [
'panels' => $this->module->panels,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
@ -87,10 +93,6 @@ class DefaultController extends Controller
]); ]);
} }
public function actionPhpinfo()
{
phpinfo();
}
private $_manifest; private $_manifest;

27
extensions/debug/panels/ConfigPanel.php

File diff suppressed because one or more lines are too long

5
extensions/debug/panels/DbPanel.php

@ -54,7 +54,7 @@ class DbPanel extends Panel
$queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms'; $queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms';
return Yii::$app->view->render('panels/db/summary', [ return Yii::$app->view->render('panels/db/summary', [
'timings' => $this->calculateTimings(), 'timings' => $this->calculateTimings(),
'panel' => $this, 'panel' => $this,
'queryCount' => $queryCount, 'queryCount' => $queryCount,
'queryTime' => $queryTime, 'queryTime' => $queryTime,
@ -127,7 +127,7 @@ class DbPanel extends Panel
$this->_models = []; $this->_models = [];
$timings = $this->calculateTimings(); $timings = $this->calculateTimings();
foreach($timings as $seq => $dbTiming) { foreach ($timings as $seq => $dbTiming) {
$this->_models[] = [ $this->_models[] = [
'type' => $this->getQueryType($dbTiming['info']), 'type' => $this->getQueryType($dbTiming['info']),
'query' => $dbTiming['info'], 'query' => $dbTiming['info'],
@ -164,5 +164,4 @@ class DbPanel extends Panel
{ {
return (($this->criticalQueryThreshold !== null) && ($count > $this->criticalQueryThreshold)); return (($this->criticalQueryThreshold !== null) && ($count > $this->criticalQueryThreshold));
} }
} }

4
extensions/debug/panels/LogPanel.php

@ -50,7 +50,7 @@ class LogPanel extends Panel
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this->getModels()); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this->getModels());
return Yii::$app->view->render('panels/log/detail', [ return Yii::$app->view->render('panels/log/detail', [
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'panel' => $this, 'panel' => $this,
'searchModel' => $searchModel, 'searchModel' => $searchModel,
]); ]);
@ -78,7 +78,7 @@ class LogPanel extends Panel
if ($this->_models === null || $refresh) { if ($this->_models === null || $refresh) {
$this->_models = []; $this->_models = [];
foreach($this->data['messages'] as $message) { foreach ($this->data['messages'] as $message) {
$this->_models[] = [ $this->_models[] = [
'message' => $message[0], 'message' => $message[0],
'level' => $message[1], 'level' => $message[1],

2
extensions/debug/panels/ProfilingPanel.php

@ -86,7 +86,7 @@ class ProfilingPanel extends Panel
$this->_models = []; $this->_models = [];
$timings = Yii::$app->getLog()->calculateTimings($this->data['messages']); $timings = Yii::$app->getLog()->calculateTimings($this->data['messages']);
foreach($timings as $seq => $profileTiming) { foreach ($timings as $seq => $profileTiming) {
$this->_models[] = [ $this->_models[] = [
'duration' => $profileTiming['duration'] * 1000, // in milliseconds 'duration' => $profileTiming['duration'] * 1000, // in milliseconds
'category' => $profileTiming['category'], 'category' => $profileTiming['category'],

35
extensions/debug/views/default/index.php

@ -3,6 +3,7 @@
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
use yii\data\ArrayDataProvider; use yii\data\ArrayDataProvider;
use yii\debug\panels\ConfigPanel;
/** /**
* @var \yii\web\View $this * @var \yii\web\View $this
@ -14,15 +15,18 @@ use yii\data\ArrayDataProvider;
$this->title = 'Yii Debugger'; $this->title = 'Yii Debugger';
?> ?>
<div class="default-index"> <div class="default-index">
<div id="yii-debug-toolbar" class="yii-debug-toolbar-top">
<div class="yii-debug-toolbar-block title">
<a href="<?= Yii::$app->homeUrl ?>"> <div id="yii-debug-toolbar" class="yii-debug-toolbar-top">
<span class="glyphicon glyphicon-home"></span> <div class="yii-debug-toolbar-block title">
</a> <a href="#">
</div> <img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
<div class="yii-debug-toolbar-block title"> Yii Debugger
Yii Debugger </a>
</div> </div>
<?php foreach ($panels as $panel): ?>
<?= $panel->getSummary() ?>
<?php endforeach; ?>
</div> </div>
<div class="container"> <div class="container">
@ -49,17 +53,15 @@ echo GridView::widget([
['class' => 'yii\grid\SerialColumn'], ['class' => 'yii\grid\SerialColumn'],
[ [
'attribute' => 'tag', 'attribute' => 'tag',
'value' => function ($data) 'value' => function ($data) {
{
return Html::a($data['tag'], ['view', 'tag' => $data['tag']]); return Html::a($data['tag'], ['view', 'tag' => $data['tag']]);
}, },
'format' => 'html', 'format' => 'html',
], ],
[ [
'attribute' => 'time', 'attribute' => 'time',
'value' => function ($data) use ($timeFormatter) 'value' => function ($data) use ($timeFormatter) {
{ return $timeFormatter->asDateTime($data['time'], 'short');
return $timeFormatter->asDateTime($data['time'], 'long');
}, },
], ],
'ip', 'ip',
@ -71,7 +73,7 @@ echo GridView::widget([
if ($dbPanel->isQueryCountCritical($data['sqlCount'])) { if ($dbPanel->isQueryCountCritical($data['sqlCount'])) {
$content = Html::tag('b', $data['sqlCount']) . ' ' . Html::tag('span','',['class' => 'glyphicon glyphicon-exclamation-sign']); $content = Html::tag('b', $data['sqlCount']) . ' ' . Html::tag('span', '', ['class' => 'glyphicon glyphicon-exclamation-sign']);
return Html::a($content, ['view', 'panel' => 'db', 'tag' => $data['tag']], [ return Html::a($content, ['view', 'panel' => 'db', 'tag' => $data['tag']], [
'title' => 'Too many queries. Allowed count is ' . $dbPanel->criticalQueryThreshold, 'title' => 'Too many queries. Allowed count is ' . $dbPanel->criticalQueryThreshold,
]); ]);
@ -88,8 +90,7 @@ echo GridView::widget([
], ],
[ [
'attribute'=>'ajax', 'attribute'=>'ajax',
'value' => function ($data) 'value' => function ($data) {
{
return $data['ajax'] ? 'Yes' : 'No'; return $data['ajax'] ? 'Yes' : 'No';
}, },
'filter' => ['No', 'Yes'], 'filter' => ['No', 'Yes'],

4
extensions/debug/views/default/panels/config/detail.php

@ -8,8 +8,6 @@ $extensions = $panel->getExtensions();
?> ?>
<h1>Configuration</h1> <h1>Configuration</h1>
<div><?= Html::a('Show phpinfo() »', ['phpinfo'], ['class' => 'btn btn-info', 'target' => 'phpinfo']) ?></div>
<?php <?php
echo $this->render('panels/config/table', [ echo $this->render('panels/config/table', [
'caption' => 'Application Configuration', 'caption' => 'Application Configuration',
@ -37,4 +35,6 @@ echo $this->render('panels/config/table', [
'Memcache' => $panel->data['php']['memcache'] ? 'Enabled' : 'Disabled', 'Memcache' => $panel->data['php']['memcache'] ? 'Enabled' : 'Disabled',
], ],
]); ]);
echo $panel->getPhpInfo();
?> ?>

9
extensions/debug/views/default/panels/config/summary.php

@ -8,10 +8,9 @@ use yii\helpers\Html;
?> ?>
<div class="yii-debug-toolbar-block"> <div class="yii-debug-toolbar-block">
<a href="<?= $panel->getUrl() ?>"> <a href="<?= $panel->getUrl() ?>">
<img width="29" height="30" alt="" src="<?= $panel->getYiiLogo() ?>"> Yii
<span><?= $panel->data['application']['yii'] ?></span> <span class="label label-info"><?= $panel->data['application']['yii'] ?></span>
PHP
<span class="label label-info"><?= $panel->data['php']['version'] ?></span>
</a> </a>
</div> </div>
<div class="yii-debug-toolbar-block">
<?= Html::a('PHP ' . $panel->data['php']['version'], ['phpinfo'], ['title' => 'Show phpinfo()', 'target' => 'phpinfo']) ?>
</div>

2
extensions/debug/views/default/panels/profile/summary.php

@ -1,6 +1,4 @@
<div class="yii-debug-toolbar-block"> <div class="yii-debug-toolbar-block">
<a href="<?= $panel->getUrl() ?>" title="Total request processing time was <?= $time ?>">Time <span class="label"><?= $time ?></span></a> <a href="<?= $panel->getUrl() ?>" title="Total request processing time was <?= $time ?>">Time <span class="label"><?= $time ?></span></a>
</div>
<div class="yii-debug-toolbar-block">
<a href="<?= $panel->getUrl() ?>" title="Peak memory consumption">Memory <span class="label"><?= $memory ?></span></a> <a href="<?= $panel->getUrl() ?>" title="Peak memory consumption">Memory <span class="label"><?= $memory ?></span></a>
</div> </div>

16
extensions/debug/views/default/toolbar.php

@ -5,6 +5,7 @@
* @var string $tag * @var string $tag
* @var string $position * @var string $position
*/ */
use yii\helpers\Html;
use yii\debug\panels\ConfigPanel; use yii\debug\panels\ConfigPanel;
$minJs = <<<EOD $minJs = <<<EOD
@ -23,22 +24,25 @@ if (window.localStorage) {
} }
EOD; EOD;
$url = $panels['request']->getUrl(); $firstPanel = reset($panels);
$url = $firstPanel->getUrl();
?> ?>
<div id="yii-debug-toolbar" class="yii-debug-toolbar-<?= $position ?>"> <div id="yii-debug-toolbar" class="yii-debug-toolbar-<?= $position ?>">
<div class="yii-debug-toolbar-block"> <div class="yii-debug-toolbar-block title">
<a href="<?= Yii::$app->homeUrl ?>"> <a href="<?= Html::url(['index']) ?>">
<span class="glyphicon glyphicon-home"></span> <img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
Yii Debugger
</a> </a>
</div> </div>
<?php foreach ($panels as $panel): ?> <?php foreach ($panels as $panel): ?>
<?= $panel->getSummary() ?> <?= $panel->getSummary() ?>
<?php endforeach; ?> <?php endforeach; ?>
<span class="yii-debug-toolbar-toggler" onclick="<?= $minJs ?>"></span> <span class="yii-debug-toolbar-toggler" onclick="<?= $minJs ?>"></span>
</div> </div>
<div id="yii-debug-toolbar-min"> <div id="yii-debug-toolbar-min">
<a href="<?= $url ?>" title="Open Yii Debugger" id="yii-debug-toolbar-logo"> <a href="<?= $url ?>" title="Open Yii Debugger" id="yii-debug-toolbar-logo">
<img width="29" height="30" alt="" src="<?= ConfigPanel::getYiiLogo() ?>"> <img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
</a> </a>
<span class="yii-debug-toolbar-toggler" onclick="<?= $maxJs ?>"></span> <span class="yii-debug-toolbar-toggler" onclick="<?= $maxJs ?>"></span>
</div> </div>

20
extensions/debug/views/default/view.php

@ -17,14 +17,14 @@ $this->title = 'Yii Debugger';
?> ?>
<div class="default-view"> <div class="default-view">
<div id="yii-debug-toolbar" class="yii-debug-toolbar-top"> <div id="yii-debug-toolbar" class="yii-debug-toolbar-top">
<div class="yii-debug-toolbar-block">
<a href="<?= Yii::$app->homeUrl ?>"> <div class="yii-debug-toolbar-block title">
<span class="glyphicon glyphicon-home"></span> <a href="<?= Html::url(['index']) ?>">
</a> <img width="29" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>">
</div> Yii Debugger
<div class="yii-debug-toolbar-block title"> </a>
<?= Html::a('Yii Debugger', ['index'], ['title' => 'Back to main debug page']) ?> </div>
</div>
<?php foreach ($panels as $panel): ?> <?php foreach ($panels as $panel): ?>
<?= $panel->getSummary() ?> <?= $panel->getSummary() ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -32,7 +32,7 @@ $this->title = 'Yii Debugger';
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-lg-2"> <div class="col-lg-2 col-md-2">
<div class="list-group"> <div class="list-group">
<?php <?php
foreach ($panels as $id => $panel) { foreach ($panels as $id => $panel) {
@ -44,7 +44,7 @@ $this->title = 'Yii Debugger';
?> ?>
</div> </div>
</div> </div>
<div class="col-lg-10"> <div class="col-lg-10 col-md-10">
<div class="callout callout-danger"> <div class="callout callout-danger">
<?php <?php
$count = 0; $count = 0;

Loading…
Cancel
Save