diff --git a/app/Client/Client.php b/app/Client/Client.php index b373356..c2a850e 100644 --- a/app/Client/Client.php +++ b/app/Client/Client.php @@ -120,6 +120,8 @@ class Client $httpProtocol = $this->configuration->port() === 443 ? 'https' : 'http'; $host = $data->server_host ?? $this->configuration->host(); + $this->configuration->setServerHost($host); + $this->logger->info($data->message); $this->logger->info("Local-URL:\t\t{$sharedUrl}"); $this->logger->info("Dashboard-URL:\t\thttp://127.0.0.1:".config()->get('expose.dashboard_port')); diff --git a/app/Client/Configuration.php b/app/Client/Configuration.php index 069861e..e422877 100644 --- a/app/Client/Configuration.php +++ b/app/Client/Configuration.php @@ -6,6 +6,9 @@ class Configuration { /** @var string */ protected $host; + + /** @var string */ + protected $serverHost; /** @var int */ protected $port; @@ -15,7 +18,7 @@ class Configuration public function __construct(string $host, int $port, ?string $auth = null) { - $this->host = $host; + $this->serverHost = $this->host = $host; $this->port = $port; @@ -27,6 +30,11 @@ class Configuration return $this->host; } + public function serverHost(): string + { + return $this->serverHost; + } + public function auth(): ?string { return $this->auth; @@ -37,10 +45,15 @@ class Configuration return intval($this->port); } + public function setServerHost($host) + { + $this->serverHost = $host; + } + public function getUrl(string $subdomain): string { $httpProtocol = $this->port() === 443 ? 'https' : 'http'; - $host = $this->host(); + $host = $this->serverHost(); if ($httpProtocol !== 'https') { $host .= ":{$this->port()}"; diff --git a/app/Commands/ServerAwareCommand.php b/app/Commands/ServerAwareCommand.php index 00fecdf..c21fbf3 100644 --- a/app/Commands/ServerAwareCommand.php +++ b/app/Commands/ServerAwareCommand.php @@ -29,7 +29,7 @@ abstract class ServerAwareCommand extends Command protected function configureConnectionLogger() { - app()->bind(CliRequestLogger::class, function () { + app()->singleton(CliRequestLogger::class, function () { return new CliRequestLogger(new ConsoleOutput()); }); diff --git a/app/Logger/CliRequestLogger.php b/app/Logger/CliRequestLogger.php index 588b9bd..d18634e 100644 --- a/app/Logger/CliRequestLogger.php +++ b/app/Logger/CliRequestLogger.php @@ -69,6 +69,8 @@ class CliRequestLogger extends Logger public function logRequest(LoggedRequest $loggedRequest) { + $dashboardUrl = 'http://127.0.0.1:'.config('expose.dashboard_port'); + if ($this->requests->has($loggedRequest->id())) { $this->requests[$loggedRequest->id()] = $loggedRequest; } else { @@ -78,11 +80,11 @@ class CliRequestLogger extends Logger $this->section->clear(); - $this->table->setRows($this->requests->map(function (LoggedRequest $loggedRequest) { + $this->table->setRows($this->requests->map(function (LoggedRequest $loggedRequest) use ($dashboardUrl) { return [ $loggedRequest->getRequest()->getMethod(), $loggedRequest->getRequest()->getUri(), - 'getRequestColor($loggedRequest).';options=bold>'. + 'id().';fg='.$this->getRequestColor($loggedRequest).';options=bold>'. optional($loggedRequest->getResponse())->getStatusCode().' '.optional($loggedRequest->getResponse())->getReasonPhrase() .'' , diff --git a/composer.json b/composer.json index 7fe25b2..ee71014 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "cboden/ratchet": "^0.4.3", "clue/block-react": "^1.4", "clue/buzz-react": "^2.9", - "clue/reactphp-sqlite": "^1.4", + "clue/reactphp-sqlite": "dev-modular-worker-for-phar-support", "guzzlehttp/guzzle": "^7.2", "guzzlehttp/psr7": "^1.7", "illuminate/log": "^8.0", @@ -66,6 +66,12 @@ "Tests\\": "tests/" } }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/seankndy/reactphp-sqlite" + } + ], "minimum-stability": "dev", "prefer-stable": true, "bin": [ diff --git a/resources/views/client/dashboard.twig b/resources/views/client/dashboard.twig index 0944f07..41f33e4 100644 --- a/resources/views/client/dashboard.twig +++ b/resources/views/client/dashboard.twig @@ -361,7 +361,7 @@
-

+

Post Parameters

@@ -374,11 +374,11 @@
-
+ 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"> +
@{ parameter.name }
-
+
File: @{ parameter.filename } (@{ parameter.mime_type }) @{ parameter.value } @@ -585,6 +585,10 @@ this.currentLogId = id; this.formatJsonResponse(); + let url = new URL(window.location); + url.hash = id; + window.history.pushState({}, '', url); + this.$nextTick(function () { this.formatJsonResponse() new ClipboardJS('.clipboard'); @@ -645,11 +649,23 @@ 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 () { this.connect(); + this.watchHash(); + this.loadLogs(); } });