detail.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* @var $panel yii\httpclient\debug\HttpClientPanel */
  3. /* @var $searchModel yii\httpclient\debug\SearchModel */
  4. /* @var $dataProvider yii\data\ArrayDataProvider */
  5. use yii\helpers\Html;
  6. use yii\grid\GridView;
  7. ?>
  8. <h1><?= $panel->getName(); ?> Requests</h1>
  9. <?php
  10. echo GridView::widget([
  11. 'dataProvider' => $dataProvider,
  12. 'id' => 'db-panel-detailed-grid',
  13. 'options' => ['class' => 'detail-grid-view table-responsive'],
  14. 'filterModel' => $searchModel,
  15. 'filterUrl' => $panel->getUrl(),
  16. 'columns' => [
  17. ['class' => 'yii\grid\SerialColumn'],
  18. [
  19. 'attribute' => 'seq',
  20. 'label' => 'Time',
  21. 'value' => function ($data) {
  22. $timeInSeconds = $data['timestamp'] / 1000;
  23. $millisecondsDiff = (int) (($timeInSeconds - (int) $timeInSeconds) * 1000);
  24. return date('H:i:s.', $timeInSeconds) . sprintf('%03d', $millisecondsDiff);
  25. },
  26. 'headerOptions' => [
  27. 'class' => 'sort-numerical'
  28. ]
  29. ],
  30. [
  31. 'attribute' => 'duration',
  32. 'value' => function ($data) {
  33. return sprintf('%.1f ms', $data['duration']);
  34. },
  35. 'options' => [
  36. 'width' => '10%',
  37. ],
  38. 'headerOptions' => [
  39. 'class' => 'sort-numerical'
  40. ]
  41. ],
  42. [
  43. 'attribute' => 'type',
  44. 'value' => function ($data) {
  45. return Html::encode($data['type']);
  46. },
  47. 'filter' => $panel->getTypes(),
  48. ],
  49. [
  50. 'attribute' => 'method',
  51. 'value' => function ($data) {
  52. return Html::encode(mb_strtoupper($data['method'], 'utf8'));
  53. },
  54. 'filter' => $panel->getMethods(),
  55. ],
  56. [
  57. 'attribute' => 'request',
  58. 'value' => function ($data) {
  59. $query = Html::encode($data['request']);
  60. if (!empty($data['trace'])) {
  61. $query .= Html::ul($data['trace'], [
  62. 'class' => 'trace',
  63. 'item' => function ($trace) {
  64. return "<li>{$trace['file']} ({$trace['line']})</li>";
  65. },
  66. ]);
  67. }
  68. if ($data['type'] !== 'batch') {
  69. $query .= Html::tag(
  70. 'div',
  71. implode('<br>', [
  72. Html::a('&gt;&gt; Execute', ['request-execute', 'seq' => $data['seq'], 'tag' => Yii::$app->controller->summary['tag']], ['target' => '_blank']),
  73. Html::a('&gt;&gt; Pass Through', ['request-execute', 'seq' => $data['seq'], 'tag' => Yii::$app->controller->summary['tag'], 'passthru' => true], ['target' => '_blank']),
  74. ]),
  75. ['class' => 'db-explain']
  76. );
  77. }
  78. return $query;
  79. },
  80. 'format' => 'raw',
  81. 'options' => [
  82. 'width' => '60%',
  83. ],
  84. ]
  85. ],
  86. ]);
  87. ?>