Skip to content

Commit

Permalink
Display API URL in debug panel
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Apr 24, 2015
1 parent 017154c commit 39fe2be
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions DebugPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use yii\debug\Panel;
use yii\helpers\ArrayHelper;
use yii\helpers\StringHelper;
use yii\helpers\Url;
use yii\log\Logger;
use yii\helpers\Html;
Expand Down Expand Up @@ -68,6 +69,13 @@ public function getDetail () {
ArrayHelper::multisort($timings, 3, SORT_DESC);
$rows = [];
$i = 0;
// Try to get API URL
try {
$hiresource = \Yii::$app->get('hiresource');
$apiUrl = (StringHelper::endsWith($hiresource->config['api_url'], '/')) ? $hiresource->config['api_url'] : $hiresource->config['api_url'] . '/';
} catch (\yii\base\InvalidConfigException $e) {
// Pass
}
foreach ($timings as $logId => $timing) {
$duration = sprintf('%.1f ms', $timing[3] * 1000);
$message = $timing[1];
Expand All @@ -90,10 +98,10 @@ public function getDetail () {
}
$ajaxUrl = Url::to(['hiresource-query', 'logId' => $logId, 'tag' => $this->tag]);
$runLink = Html::a('run query', $ajaxUrl, [
'class' => 'elastic-link',
'class' => 'hiar-link',
'data' => ['id' => $i]
]) . '<br/>';
$url_encoded = Html::encode($url);
$url_encoded = Html::encode((isset($apiUrl)) ? str_replace(' ', ' ' . $apiUrl, $url) : $url);
$rows[] = <<<HTML
<tr>
<td style="width: 10%;">$duration</td>
Expand Down Expand Up @@ -137,7 +145,7 @@ function syntaxHighlight(json) {
});
}
$('.elastic-link').on('click', function (event) {
$('.hiar-link').on('click', function (event) {
event.preventDefault();
var id = $(this).data('id');
Expand All @@ -156,10 +164,8 @@ function syntaxHighlight(json) {
}
result.find('.time').html(data.time);
if (is_json) {
console.log('123');
result.find('.result').html( syntaxHighlight( JSON.stringify( JSON.parse(data.result), undefined, 10) ) );
} else {
console.log('321');
result.find('.result').html( data.result );
}
},
Expand Down

0 comments on commit 39fe2be

Please sign in to comment.