This commit is contained in:
Marcel Pociot
2022-02-23 12:38:42 +01:00
parent a199aa8576
commit 89c9fa6742
6 changed files with 49 additions and 10 deletions

View File

@@ -120,6 +120,8 @@ class Client
$httpProtocol = $this->configuration->port() === 443 ? 'https' : 'http'; $httpProtocol = $this->configuration->port() === 443 ? 'https' : 'http';
$host = $data->server_host ?? $this->configuration->host(); $host = $data->server_host ?? $this->configuration->host();
$this->configuration->setServerHost($host);
$this->logger->info($data->message); $this->logger->info($data->message);
$this->logger->info("Local-URL:\t\t{$sharedUrl}"); $this->logger->info("Local-URL:\t\t{$sharedUrl}");
$this->logger->info("Dashboard-URL:\t\thttp://127.0.0.1:".config()->get('expose.dashboard_port')); $this->logger->info("Dashboard-URL:\t\thttp://127.0.0.1:".config()->get('expose.dashboard_port'));

View File

@@ -7,6 +7,9 @@ class Configuration
/** @var string */ /** @var string */
protected $host; protected $host;
/** @var string */
protected $serverHost;
/** @var int */ /** @var int */
protected $port; protected $port;
@@ -15,7 +18,7 @@ class Configuration
public function __construct(string $host, int $port, ?string $auth = null) public function __construct(string $host, int $port, ?string $auth = null)
{ {
$this->host = $host; $this->serverHost = $this->host = $host;
$this->port = $port; $this->port = $port;
@@ -27,6 +30,11 @@ class Configuration
return $this->host; return $this->host;
} }
public function serverHost(): string
{
return $this->serverHost;
}
public function auth(): ?string public function auth(): ?string
{ {
return $this->auth; return $this->auth;
@@ -37,10 +45,15 @@ class Configuration
return intval($this->port); return intval($this->port);
} }
public function setServerHost($host)
{
$this->serverHost = $host;
}
public function getUrl(string $subdomain): string public function getUrl(string $subdomain): string
{ {
$httpProtocol = $this->port() === 443 ? 'https' : 'http'; $httpProtocol = $this->port() === 443 ? 'https' : 'http';
$host = $this->host(); $host = $this->serverHost();
if ($httpProtocol !== 'https') { if ($httpProtocol !== 'https') {
$host .= ":{$this->port()}"; $host .= ":{$this->port()}";

View File

@@ -29,7 +29,7 @@ abstract class ServerAwareCommand extends Command
protected function configureConnectionLogger() protected function configureConnectionLogger()
{ {
app()->bind(CliRequestLogger::class, function () { app()->singleton(CliRequestLogger::class, function () {
return new CliRequestLogger(new ConsoleOutput()); return new CliRequestLogger(new ConsoleOutput());
}); });

View File

@@ -69,6 +69,8 @@ class CliRequestLogger extends Logger
public function logRequest(LoggedRequest $loggedRequest) public function logRequest(LoggedRequest $loggedRequest)
{ {
$dashboardUrl = 'http://127.0.0.1:'.config('expose.dashboard_port');
if ($this->requests->has($loggedRequest->id())) { if ($this->requests->has($loggedRequest->id())) {
$this->requests[$loggedRequest->id()] = $loggedRequest; $this->requests[$loggedRequest->id()] = $loggedRequest;
} else { } else {
@@ -78,11 +80,11 @@ class CliRequestLogger extends Logger
$this->section->clear(); $this->section->clear();
$this->table->setRows($this->requests->map(function (LoggedRequest $loggedRequest) { $this->table->setRows($this->requests->map(function (LoggedRequest $loggedRequest) use ($dashboardUrl) {
return [ return [
$loggedRequest->getRequest()->getMethod(), $loggedRequest->getRequest()->getMethod(),
$loggedRequest->getRequest()->getUri(), $loggedRequest->getRequest()->getUri(),
'<href=foo;fg='.$this->getRequestColor($loggedRequest).';options=bold>'. '<href='.$dashboardUrl.'/#'.$loggedRequest->id().';fg='.$this->getRequestColor($loggedRequest).';options=bold>'.
optional($loggedRequest->getResponse())->getStatusCode().' '.optional($loggedRequest->getResponse())->getReasonPhrase() optional($loggedRequest->getResponse())->getStatusCode().' '.optional($loggedRequest->getResponse())->getReasonPhrase()
.'</>' .'</>'
, ,

View File

@@ -24,7 +24,7 @@
"cboden/ratchet": "^0.4.3", "cboden/ratchet": "^0.4.3",
"clue/block-react": "^1.4", "clue/block-react": "^1.4",
"clue/buzz-react": "^2.9", "clue/buzz-react": "^2.9",
"clue/reactphp-sqlite": "^1.4", "clue/reactphp-sqlite": "dev-modular-worker-for-phar-support",
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.2",
"guzzlehttp/psr7": "^1.7", "guzzlehttp/psr7": "^1.7",
"illuminate/log": "^8.0", "illuminate/log": "^8.0",
@@ -66,6 +66,12 @@
"Tests\\": "tests/" "Tests\\": "tests/"
} }
}, },
"repositories": [
{
"type": "vcs",
"url": "https://github.com/seankndy/reactphp-sqlite"
}
],
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
"bin": [ "bin": [

View File

@@ -361,7 +361,7 @@
</div> </div>
<div class="px-4 py-5 border-b border-t dark:border-gray-700 border-gray-200 sm:px-6 flex justify-between" v-if="Object.keys(currentLog.request.post).length > 0"> <div class="px-4 py-5 border-b border-t dark:border-gray-700 border-gray-200 sm:px-6 flex justify-between" v-if="Object.keys(currentLog.request.post).length > 0">
<h3 class="text-lg leading-6 font-medium text-gray-900"> <h3 class="text-lg leading-6 font-medium dark:text-gray-100 text-gray-900">
Post Parameters Post Parameters
</h3> </h3>
<span class="inline-flex rounded-md shadow-sm ml-4"> <span class="inline-flex rounded-md shadow-sm ml-4">
@@ -374,11 +374,11 @@
</div> </div>
<div v-for="parameter in currentLog.request.post" <div v-for="parameter in currentLog.request.post"
:key="'post_' + parameter.name" :key="'post_' + parameter.name"
class="even:bg-gray-100 bg-gray-50 px-4 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> class="even:bg-gray-50 bg-gray-50 dark:even:bg-gray-700 dark:bg-gray-800 px-4 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm leading-5 font-medium text-gray-700"> <dt class="text-sm leading-5 font-medium dark:text-gray-200 text-gray-700">
@{ parameter.name } @{ parameter.name }
</dt> </dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2 break-all"> <dd class="mt-1 text-sm leading-5 dark:text-gray-200 text-gray-900 sm:mt-0 sm:col-span-2 break-all">
<span <span
v-if="parameter.is_file">File: @{ parameter.filename } (@{ parameter.mime_type })</span> v-if="parameter.is_file">File: @{ parameter.filename } (@{ parameter.mime_type })</span>
<span v-else>@{ parameter.value }</span> <span v-else>@{ parameter.value }</span>
@@ -585,6 +585,10 @@
this.currentLogId = id; this.currentLogId = id;
this.formatJsonResponse(); this.formatJsonResponse();
let url = new URL(window.location);
url.hash = id;
window.history.pushState({}, '', url);
this.$nextTick(function () { this.$nextTick(function () {
this.formatJsonResponse() this.formatJsonResponse()
new ClipboardJS('.clipboard'); new ClipboardJS('.clipboard');
@@ -645,11 +649,23 @@
this.logs = data; this.logs = data;
}); });
}, },
watchHash: function () {
window.addEventListener('hashchange', () => {
this.setLog(document.location.hash.replace('#', ''))
})
if (document.location.hash !== '') {
this.setLog(document.location.hash.replace('#', ''))
}
}
}, },
mounted: function () { mounted: function () {
this.connect(); this.connect();
this.watchHash();
this.loadLogs(); this.loadLogs();
} }
}); });