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
feat: save timestamp configuration for logs
Andras Bacsai3b67d0a8de20
diff --git a/app/Http/Livewire/Project/Shared/GetLogs.php b/app/Http/Livewire/Project/Shared/GetLogs.phpindex 4244bed12d..933938f560 100644--- a/app/Http/Livewire/Project/Shared/GetLogs.php+++ b/app/Http/Livewire/Project/Shared/GetLogs.php@@ -2,7 +2,16 @@namespace App\Http\Livewire\Project\Shared;+use App\Models\Application;use App\Models\Server;+use App\Models\Service;+use App\Models\ServiceApplication;+use App\Models\ServiceDatabase;+use App\Models\StandaloneMariadb;+use App\Models\StandaloneMongodb;+use App\Models\StandaloneMysql;+use App\Models\StandalonePostgresql;+use App\Models\StandaloneRedis;use Illuminate\Support\Facades\Process;use Livewire\Component;@@ -10,17 +19,44 @@ class GetLogs extends Component{public string $outputs = '';public string $errors = '';+ public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $resource;+ public ServiceApplication|ServiceDatabase|null $servicesubtype = null;public Server $server;public ?string $container = null;public ?bool $streamLogs = false;public ?bool $showTimeStamps = true;public int $numberOfLines = 100;++ public function mount()+ {+ if ($this->resource->getMorphClass() === 'App\Models\Application') {+ $this->showTimeStamps = $this->resource->settings->is_include_timestamps;+ } else {+ if ($this->servicesubtype) {+ $this->showTimeStamps = $this->servicesubtype->is_include_timestamps;+ } else {+ $this->showTimeStamps = $this->resource->is_include_timestamps;+ }+ }+ }public function doSomethingWithThisChunkOfOutput($output){$this->outputs .= removeAnsiColors($output);}public function instantSave(){+ if ($this->resource->getMorphClass() === 'App\Models\Application') {+ $this->resource->settings->is_include_timestamps = $this->showTimeStamps;+ $this->resource->settings->save();+ } else {+ if ($this->servicesubtype) {+ $this->servicesubtype->is_include_timestamps = $this->showTimeStamps;+ $this->servicesubtype->save();+ } else {+ $this->resource->is_include_timestamps = $this->showTimeStamps;+ $this->resource->save();+ }+ }}public function getLogs($refresh = false){diff --git a/app/Http/Livewire/Project/Shared/Logs.php b/app/Http/Livewire/Project/Shared/Logs.phpindex 982f729b4e..18b632ab48 100644--- a/app/Http/Livewire/Project/Shared/Logs.php+++ b/app/Http/Livewire/Project/Shared/Logs.php@@ -22,6 +22,7 @@ class Logs extends Componentpublic $parameters;public $query;public $status;+ public $serviceSubType;public function mount(){@@ -64,6 +65,11 @@ class Logs extends Component} else if (data_get($this->parameters, 'service_uuid')) {$this->type = 'service';$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();+ $service_name = data_get($this->parameters, 'service_name');+ $this->serviceSubType = $this->resource->applications()->where('name', $service_name)->first();+ if (!$this->serviceSubType) {+ $this->serviceSubType = $this->resource->databases()->where('name', $service_name)->first();+ }$this->status = $this->resource->status;$this->server = $this->resource->server;$this->container = data_get($this->parameters, 'service_name') . '-' . $this->resource->uuid;diff --git a/database/migrations/2023_12_01_091723_save_logs_view_settings.php b/database/migrations/2023_12_01_091723_save_logs_view_settings.phpnew file mode 100644index 0000000000..a435644549--- /dev/null+++ b/database/migrations/2023_12_01_091723_save_logs_view_settings.php@@ -0,0 +1,64 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('application_settings', function (Blueprint $table) {+ $table->boolean('is_include_timestamps')->default(false);+ });+ Schema::table('service_applications', function (Blueprint $table) {+ $table->boolean('is_include_timestamps')->default(false);+ });+ Schema::table('service_databases', function (Blueprint $table) {+ $table->boolean('is_include_timestamps')->default(false);+ });+ Schema::table('standalone_mysqls', function (Blueprint $table) {+ $table->boolean('is_include_timestamps')->default(false);+ });+ Schema::table('standalone_postgresqls', function (Blueprint $table) {+ $table->boolean('is_include_timestamps')->default(false);+ });+ Schema::table('standalone_redis', function (Blueprint $table) {+ $table->boolean('is_include_timestamps')->default(false);+ });+ Schema::table('standalone_mongodbs', function (Blueprint $table) {+ $table->boolean('is_include_timestamps')->default(false);+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('application_settings', function (Blueprint $table) {+ $table->dropColumn('is_include_timestamps');+ });+ Schema::table('service_applications', function (Blueprint $table) {+ $table->dropColumn('is_include_timestamps');+ });+ Schema::table('service_databases', function (Blueprint $table) {+ $table->dropColumn('is_include_timestamps');+ });+ Schema::table('standalone_mysqls', function (Blueprint $table) {+ $table->dropColumn('is_include_timestamps');+ });+ Schema::table('standalone_postgresqls', function (Blueprint $table) {+ $table->dropColumn('is_include_timestamps');+ });+ Schema::table('standalone_redis', function (Blueprint $table) {+ $table->dropColumn('is_include_timestamps');+ });+ Schema::table('standalone_mongodbs', function (Blueprint $table) {+ $table->dropColumn('is_include_timestamps');+ });+ }+};diff --git a/resources/views/livewire/project/shared/logs.blade.php b/resources/views/livewire/project/shared/logs.blade.phpindex db5320a17a..2b21f18a9e 100644--- a/resources/views/livewire/project/shared/logs.blade.php+++ b/resources/views/livewire/project/shared/logs.blade.php@@ -7,7 +7,7 @@@if ($loop->first)<h2 class="pb-4">Logs</h2>@endif- <livewire:project.shared.get-logs :server="$server" :container="$container" />+ <livewire:project.shared.get-logs :server="$server" :resource="$resource" :container="$container" />@empty<div>No containers are not running.</div>@endforelse@@ -16,7 +16,7 @@<h1>Logs</h1><livewire:project.database.heading :database="$resource" /><div class="pt-4">- <livewire:project.shared.get-logs :server="$server" :container="$container" />+ <livewire:project.shared.get-logs :resource="$resource" :server="$server" :container="$container" /></div>@elseif ($type === 'service')<livewire:project.service.navbar :service="$resource" :parameters="$parameters" :query="$query" />@@ -28,7 +28,7 @@</a></div><div class="flex-1 pl-8">- <livewire:project.shared.get-logs :server="$server" :container="$container" />+ <livewire:project.shared.get-logs :server="$server" :resource="$resource" :servicesubtype="$serviceSubType" :container="$container" /></div></div>@endif