refactor: service logs are now on one page
This commit is contained in:
parent
2846e049fa
commit
956416b522
@ -80,7 +80,7 @@ class ExecuteContainerCommand extends Component
|
|||||||
$this->resource = $resource;
|
$this->resource = $resource;
|
||||||
$this->server = $this->resource->destination->server;
|
$this->server = $this->resource->destination->server;
|
||||||
$this->container = $this->resource->uuid;
|
$this->container = $this->resource->uuid;
|
||||||
if (data_get($this,'resource.status') == 'running') {
|
if (str(data_get($this,'resource.status'))->startsWith('running')) {
|
||||||
$this->containers->push($this->container);
|
$this->containers->push($this->container);
|
||||||
}
|
}
|
||||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||||
|
@ -51,19 +51,26 @@ class GetLogs extends Component
|
|||||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||||
$this->resource->settings->is_include_timestamps = $this->showTimeStamps;
|
$this->resource->settings->is_include_timestamps = $this->showTimeStamps;
|
||||||
$this->resource->settings->save();
|
$this->resource->settings->save();
|
||||||
} else {
|
}
|
||||||
if ($this->servicesubtype) {
|
if ($this->resource->getMorphClass() === 'App\Models\Service') {
|
||||||
$this->servicesubtype->is_include_timestamps = $this->showTimeStamps;
|
$serviceName = str($this->container)->beforeLast('-')->value();
|
||||||
$this->servicesubtype->save();
|
$subType = $this->resource->applications()->where('name', $serviceName)->first();
|
||||||
|
if ($subType) {
|
||||||
|
$subType->is_include_timestamps = $this->showTimeStamps;
|
||||||
|
$subType->save();
|
||||||
} else {
|
} else {
|
||||||
$this->resource->is_include_timestamps = $this->showTimeStamps;
|
$subType = $this->resource->databases()->where('name', $serviceName)->first();
|
||||||
$this->resource->save();
|
if ($subType) {
|
||||||
|
$subType->is_include_timestamps = $this->showTimeStamps;
|
||||||
|
$subType->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function getLogs($refresh = false)
|
public function getLogs($refresh = false)
|
||||||
{
|
{
|
||||||
|
if (!$refresh && $this->resource->getMorphClass() === 'App\Models\Service') return;
|
||||||
if ($this->container) {
|
if ($this->container) {
|
||||||
if ($this->showTimeStamps) {
|
if ($this->showTimeStamps) {
|
||||||
$sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}");
|
$sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}");
|
||||||
|
@ -62,17 +62,24 @@ class Logs extends Component
|
|||||||
$this->status = $this->resource->status;
|
$this->status = $this->resource->status;
|
||||||
$this->server = $this->resource->destination->server;
|
$this->server = $this->resource->destination->server;
|
||||||
$this->container = $this->resource->uuid;
|
$this->container = $this->resource->uuid;
|
||||||
|
if (str(data_get($this,'resource.status'))->startsWith('running')) {
|
||||||
|
$this->containers->push($this->container);
|
||||||
|
}
|
||||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||||
$this->type = 'service';
|
$this->type = 'service';
|
||||||
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
||||||
$service_name = data_get($this->parameters, 'service_name');
|
$this->resource->applications()->get()->each(function ($application) {
|
||||||
$this->serviceSubType = $this->resource->applications()->where('name', $service_name)->first();
|
if (str(data_get($application, 'status'))->contains('running')) {
|
||||||
if (!$this->serviceSubType) {
|
$this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||||
$this->serviceSubType = $this->resource->databases()->where('name', $service_name)->first();
|
}
|
||||||
}
|
});
|
||||||
$this->status = $this->resource->status;
|
$this->resource->databases()->get()->each(function ($database) {
|
||||||
|
if (str(data_get($database, 'status'))->contains('running')) {
|
||||||
|
$this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$this->server = $this->resource->server;
|
$this->server = $this->resource->server;
|
||||||
$this->container = data_get($this->parameters, 'service_name') . '-' . $this->resource->uuid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
@click.prevent="activeTab = 'execute-command';
|
@click.prevent="activeTab = 'execute-command';
|
||||||
window.location.hash = 'execute-command'"
|
window.location.hash = 'execute-command'"
|
||||||
href="#">Execute Command</a>
|
href="#">Execute Command</a>
|
||||||
|
<a :class="activeTab === 'logs' && 'text-white'"
|
||||||
|
@click.prevent="activeTab = 'logs';
|
||||||
|
window.location.hash = 'logs'"
|
||||||
|
href="#">Logs</a>
|
||||||
<a :class="activeTab === 'storages' && 'text-white'"
|
<a :class="activeTab === 'storages' && 'text-white'"
|
||||||
@click.prevent="activeTab = 'storages';
|
@click.prevent="activeTab = 'storages';
|
||||||
window.location.hash = 'storages'"
|
window.location.hash = 'storages'"
|
||||||
@ -60,9 +64,6 @@
|
|||||||
@endif
|
@endif
|
||||||
<div class="text-xs">{{ $application->status }}</div>
|
<div class="text-xs">{{ $application->status }}</div>
|
||||||
</a>
|
</a>
|
||||||
<a wire:navigate class="flex items-center gap-2 p-1 mx-4 font-bold rounded group-hover:text-white hover:no-underline"
|
|
||||||
href="{{ route('project.service.logs', [...$parameters, 'service_name' => $application->name]) }}"><span
|
|
||||||
class="hover:text-warning">Logs</span></a>
|
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@foreach ($databases as $database)
|
@foreach ($databases as $database)
|
||||||
@ -90,9 +91,6 @@
|
|||||||
@endif
|
@endif
|
||||||
<div class="text-xs">{{ $database->status }}</div>
|
<div class="text-xs">{{ $database->status }}</div>
|
||||||
</a>
|
</a>
|
||||||
<a wire:navigate class="flex items-center gap-2 p-1 mx-4 font-bold rounded hover:no-underline group-hover:text-white"
|
|
||||||
href="{{ route('project.service.logs', [...$parameters, 'service_name' => $database->name]) }}"><span
|
|
||||||
class="hover:text-warning">Logs</span></a>
|
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
@ -114,8 +112,11 @@
|
|||||||
<div x-cloak x-show="activeTab === 'webhooks'">
|
<div x-cloak x-show="activeTab === 'webhooks'">
|
||||||
<livewire:project.shared.webhooks :resource="$service" />
|
<livewire:project.shared.webhooks :resource="$service" />
|
||||||
</div>
|
</div>
|
||||||
|
<div x-cloak x-show="activeTab === 'logs'">
|
||||||
|
<livewire:project.shared.logs :resource="$service" />
|
||||||
|
</div>
|
||||||
<div x-cloak x-show="activeTab === 'execute-command'">
|
<div x-cloak x-show="activeTab === 'execute-command'">
|
||||||
<livewire:project.shared.execute-container-command :resource="$service" />
|
<livewire:project.shared.execute-container-command :resource="$service" />
|
||||||
</div>
|
</div>
|
||||||
<div x-cloak x-show="activeTab === 'environment-variables'">
|
<div x-cloak x-show="activeTab === 'environment-variables'">
|
||||||
<div x-cloak x-show="activeTab === 'environment-variables'">
|
<div x-cloak x-show="activeTab === 'environment-variables'">
|
||||||
|
@ -20,12 +20,6 @@
|
|||||||
<a :class="activeTab === 'backups' && 'text-white'"
|
<a :class="activeTab === 'backups' && 'text-white'"
|
||||||
@click.prevent="activeTab = 'backups'; window.location.hash = 'backups'" href="#">Backups</a>
|
@click.prevent="activeTab = 'backups'; window.location.hash = 'backups'" href="#">Backups</a>
|
||||||
@endif
|
@endif
|
||||||
@if (data_get($parameters, 'service_name'))
|
|
||||||
<a wire:navigate class="{{ request()->routeIs('project.service.logs') ? 'text-white' : '' }}"
|
|
||||||
href="{{ route('project.service.logs', $parameters) }}">
|
|
||||||
<button>Logs</button>
|
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full pl-8">
|
<div class="w-full pl-8">
|
||||||
@isset($serviceApplication)
|
@isset($serviceApplication)
|
||||||
|
@ -16,21 +16,25 @@
|
|||||||
<h1>Logs</h1>
|
<h1>Logs</h1>
|
||||||
<livewire:project.database.heading :database="$resource" />
|
<livewire:project.database.heading :database="$resource" />
|
||||||
<div class="pt-4">
|
<div class="pt-4">
|
||||||
<livewire:project.shared.get-logs :resource="$resource" :server="$server" :container="$container" />
|
@forelse ($containers as $container)
|
||||||
|
@if ($loop->first)
|
||||||
|
<h2 class="pb-4">Logs</h2>
|
||||||
|
@endif
|
||||||
|
<livewire:project.shared.get-logs :server="$server" :resource="$resource" :container="$container" />
|
||||||
|
@empty
|
||||||
|
<div>No containers are not running.</div>
|
||||||
|
@endforelse
|
||||||
</div>
|
</div>
|
||||||
@elseif ($type === 'service')
|
@elseif ($type === 'service')
|
||||||
<livewire:project.service.navbar :service="$resource" :parameters="$parameters" :query="$query" />
|
<div>
|
||||||
<div class="flex gap-4 pt-6">
|
@forelse ($containers as $container)
|
||||||
<div>
|
@if ($loop->first)
|
||||||
<a wire:navigate class="{{ request()->routeIs('project.service.show') ? 'text-white' : '' }}"
|
<h2 class="pb-4">Logs</h2>
|
||||||
href="{{ route('project.service.show', $parameters) }}">
|
@endif
|
||||||
<button><- Back</button>
|
<livewire:project.shared.get-logs :server="$server" :resource="$resource" :container="$container" />
|
||||||
</a>
|
@empty
|
||||||
</div>
|
<div>No containers are not running.</div>
|
||||||
<div class="flex-1 pl-8">
|
@endforelse
|
||||||
<livewire:project.shared.get-logs :server="$server" :resource="$resource" :servicesubtype="$serviceSubType"
|
|
||||||
:container="$container" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@ -136,7 +136,6 @@ Route::middleware(['auth', 'verified'])->group(function () {
|
|||||||
// Services
|
// Services
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', ServiceIndex::class)->name('project.service.configuration');
|
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', ServiceIndex::class)->name('project.service.configuration');
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}', ServiceShow::class)->name('project.service.show');
|
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}', ServiceShow::class)->name('project.service.show');
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}/logs', Logs::class)->name('project.service.logs');
|
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/command', ExecuteContainerCommand::class)->name('project.service.command');
|
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/command', ExecuteContainerCommand::class)->name('project.service.command');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user