An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: container logs are now followable in full-screen and sorted by timestamp
Andras Bacsai66287b43d0eb
diff --git a/app/Http/Livewire/Project/Shared/GetLogs.php b/app/Http/Livewire/Project/Shared/GetLogs.phpindex e82f204971..b693793cf1 100644--- a/app/Http/Livewire/Project/Shared/GetLogs.php+++ b/app/Http/Livewire/Project/Shared/GetLogs.php@@ -33,11 +33,16 @@ class GetLogs extends Componentif ($refresh) {$this->outputs = '';}- $command = Process::run($sshCommand);- $output = $command->output();- $error = $command->errorOutput();- $this->doSomethingWithThisChunkOfOutput($output);- $this->doSomethingWithThisChunkOfOutput($error);+ Process::run($sshCommand, function (string $type, string $output) {+ $this->doSomethingWithThisChunkOfOutput($output);+ });+ if ($this->showTimeStamps) {+ $this->outputs = str($this->outputs)->split('/\n/')->sort(function ($a, $b) {+ $a = explode(' ', $a);+ $b = explode(' ', $b);+ return $a[0] <=> $b[0];+ })->join("\n");+ }}}public function render()diff --git a/resources/views/livewire/project/shared/get-logs.blade.php b/resources/views/livewire/project/shared/get-logs.blade.phpindex 16b2853cf2..8913dd5469 100644--- a/resources/views/livewire/project/shared/get-logs.blade.php+++ b/resources/views/livewire/project/shared/get-logs.blade.php@@ -13,17 +13,28 @@<x-forms.input label="Only Show Number of Lines" placeholder="1000" required id="numberOfLines"></x-forms.input><x-forms.button type="submit">Refresh</x-forms.button></form>- <div x-data="{ fullscreen: false }" :class="fullscreen ? 'fullscreen' : 'container w-full pt-4 mx-auto'">+ <div id="screen" x-data="{ fullscreen: false, alwaysScroll: false, intervalId: null }" :class="fullscreen ? 'fullscreen' : 'container w-full pt-4 mx-auto'"><div class="relative flex flex-col-reverse w-full p-4 pt-6 overflow-y-auto text-white scrollbar border-coolgray-300":class="fullscreen ? '' : 'max-h-[40rem] border border-solid rounded'">- <button title="Minimize" x-show="fullscreen" class="fixed top-4 right-4"- x-on:click="fullscreen = !fullscreen"><svg class="icon" viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg">+ <button title="Minimize" x-show="fullscreen" class="fixed top-4 right-4" x-on:click="makeFullscreen"><svg+ class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"stroke-width="2" d="M6 14h4m0 0v4m0-4l-6 6m14-10h-4m0 0V6m0 4l6-6" /></svg></button>+ <button title="Go Top" x-show="fullscreen" class="fixed top-4 right-28" x-on:click="goTop"> <svg+ class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"+ stroke-width="2" d="M12 5v14m4-10l-4-4M8 9l4-4" />+ </svg></button>+ <button title="Follow Logs" x-show="fullscreen" :class="alwaysScroll ? 'text-warning' : ''"+ class="fixed top-4 right-16" x-on:click="toggleScroll"><svg class="icon" viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg">+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"+ stroke-width="2" d="M12 5v14m4-4l-4 4m-4-4l4 4" />+ </svg></button>+<button title="Fullscreen" x-show="!fullscreen" class="absolute top-2 right-8"- x-on:click="fullscreen = !fullscreen"><svg class="fixed icon" viewBox="0 0 24 24"+ x-on:click="makeFullscreen"><svg class="fixed icon" viewBox="0 0 24 24"xmlns="http://www.w3.org/2000/svg"><g fill="none"><path@@ -32,7 +43,40 @@d="M9.793 12.793a1 1 0 0 1 1.497 1.32l-.083.094L6.414 19H9a1 1 0 0 1 .117 1.993L9 21H4a1 1 0 0 1-.993-.883L3 20v-5a1 1 0 0 1 1.993-.117L5 15v2.586l4.793-4.793ZM20 3a1 1 0 0 1 .993.883L21 4v5a1 1 0 0 1-1.993.117L19 9V6.414l-4.793 4.793a1 1 0 0 1-1.497-1.32l.083-.094L17.586 5H15a1 1 0 0 1-.117-1.993L15 3h5Z" /></g></svg></button>- <pre class="font-mono whitespace-pre-wrap">{{ $outputs }}</pre>+ <pre id="logs" class="font-mono whitespace-pre-wrap">{{ $outputs }}</pre></div></div>+ <script>+ function makeFullscreen() {+ this.fullscreen = !this.fullscreen;+ if (this.fullscreen === false) {+ this.alwaysScroll = false;+ clearInterval(this.intervalId);+ }+ }++ function toggleScroll() {+ this.alwaysScroll = !this.alwaysScroll;++ if (this.alwaysScroll) {+ this.intervalId = setInterval(() => {+ const screen = document.getElementById('screen');+ const logs = document.getElementById('logs');+ if (screen.scrollTop !== logs.scrollHeight) {+ screen.scrollTop = logs.scrollHeight;+ }+ }, 100);+ } else {+ clearInterval(this.intervalId);+ this.intervalId = null;+ }+ }++ function goTop() {+ this.alwaysScroll = false;+ clearInterval(this.intervalId);+ const screen = document.getElementById('screen');+ screen.scrollTop = 0;+ }+ </script></div>