Monitoring & Service Management (#163)

Monitoring & Service Management
This commit is contained in:
Saeed Vaziry
2024-04-13 11:47:56 +02:00
committed by GitHub
parent 87ec0af697
commit 052e28d2e3
95 changed files with 2423 additions and 341 deletions

View File

@ -3,5 +3,7 @@
@include("services.partials.services-list")
{{-- @include("services.partials.add-ons") --}}
@include("services.partials.available-services")
@stack("modals")
</x-server-layout>

View File

@ -1 +1,6 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1 +1,6 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1 +1,6 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1 +1,6 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1 +1,6 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1 +1,6 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1 +1,6 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1 +1,5 @@
@include("services.partials.unit-actions")
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")

View File

@ -0,0 +1,6 @@
@include("services.partials.unit-actions.restart")
@include("services.partials.unit-actions.start")
@include("services.partials.unit-actions.stop")
@include("services.partials.unit-actions.enable")
@include("services.partials.unit-actions.disable")
@include("services.partials.unit-actions.uninstall")

View File

@ -1,33 +0,0 @@
<div>
<x-card-header>
<x-slot name="title">Supported Services</x-slot>
<x-slot name="description">Here you can find the supported services to install</x-slot>
<x-slot name="aside"></x-slot>
</x-card-header>
<div class="grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
@foreach (config("core.add_on_services") as $addOn)
<div
class="relative flex h-auto flex-col items-center justify-between space-y-3 rounded-b-md rounded-t-md border border-gray-200 bg-white text-center dark:border-gray-700 dark:bg-gray-800"
>
<div class="space-y-3 p-5">
<div class="flex items-center justify-center">
<img src="{{ asset("static/images/" . $addOn . ".svg") }}" class="h-20 w-20" alt="" />
</div>
<div class="flex flex-grow flex-col items-start justify-center">
<div class="flex items-center">
<div class="flex items-center text-lg">
{{ $addOn }}
</div>
</div>
</div>
</div>
<div
class="flex w-full items-center justify-between rounded-b-md border-t border-t-gray-200 bg-gray-50 p-2 dark:border-t-gray-600 dark:bg-gray-700"
>
@include("services.partials.add-on-installers." . $addOn)
</div>
</div>
@endforeach
</div>
</div>

View File

@ -0,0 +1,33 @@
<div>
<x-card-header>
<x-slot name="title">Supported Services</x-slot>
<x-slot name="description">Here you can find the supported services to install</x-slot>
<x-slot name="aside"></x-slot>
</x-card-header>
<div class="grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
@foreach (config("core.service_handlers") as $key => $addOn)
@if (! $server->services()->where("name", $key)->exists())
<div
class="relative flex h-auto flex-col items-center justify-between space-y-3 rounded-b-md rounded-t-md border border-gray-200 bg-white text-center dark:border-gray-700 dark:bg-gray-800"
>
<div class="space-y-3 p-5">
<div class="flex items-center justify-center">
<img src="{{ asset("static/images/" . $key . ".svg") }}" class="h-20 w-20" alt="" />
</div>
<div class="flex flex-grow flex-col items-center justify-center">
<div class="flex items-center justify-center text-center text-lg">
{{ $key }}
</div>
</div>
</div>
<div
class="flex w-full items-center justify-between rounded-b-md border-t border-t-gray-200 bg-gray-50 p-2 dark:border-t-gray-600 dark:bg-gray-700"
>
@include("services.partials.installers." . $key)
</div>
</div>
@endif
@endforeach
</div>
</div>

View File

@ -0,0 +1,48 @@
<x-secondary-button class="!w-full" x-on:click="$dispatch('open-modal', 'install-mariadb')">Install</x-secondary-button>
@push("modals")
<x-modal name="install-mariadb">
<form
id="install-mariadb-form"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-mariadb-form"
class="p-6"
>
@csrf
<input type="hidden" name="name" value="mariadb" />
<input type="hidden" name="type" value="database" />
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __("Install mariadb") }}
</h2>
<div class="mt-6">
<x-input-label for="version" value="Version" />
<x-select-input id="version" name="version" class="mt-1 w-full">
@foreach (collect(config("core.databases_name"))->filter(fn ($value) => $value == "mariadb") as $db => $value)
<option value="{{ config("core.databases_version")[$db] }}">
{{ config("core.databases_name")[$db] }} {{ config("core.databases_version")[$db] }}
</option>
@endforeach
</x-select-input>
@error("version")
<x-input-error class="mt-2" :messages="$message" />
@enderror
@error("type")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">
{{ __("Cancel") }}
</x-secondary-button>
<x-primary-button id="btn-install-mariadb" hx-disable class="ml-3">
{{ __("Install") }}
</x-primary-button>
</div>
</form>
</x-modal>
@endpush

View File

@ -0,0 +1,48 @@
<x-secondary-button class="!w-full" x-on:click="$dispatch('open-modal', 'install-mysql')">Install</x-secondary-button>
@push("modals")
<x-modal name="install-mysql">
<form
id="install-mysql-form"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-mysql-form"
class="p-6"
>
@csrf
<input type="hidden" name="name" value="mysql" />
<input type="hidden" name="type" value="database" />
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __("Install Mysql") }}
</h2>
<div class="mt-6">
<x-input-label for="version" value="Version" />
<x-select-input id="version" name="version" class="mt-1 w-full">
@foreach (collect(config("core.databases_name"))->filter(fn ($value) => $value == "mysql") as $db => $value)
<option value="{{ config("core.databases_version")[$db] }}">
{{ config("core.databases_name")[$db] }} {{ config("core.databases_version")[$db] }}
</option>
@endforeach
</x-select-input>
@error("version")
<x-input-error class="mt-2" :messages="$message" />
@enderror
@error("type")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">
{{ __("Cancel") }}
</x-secondary-button>
<x-primary-button id="btn-install-mysql" hx-disable class="ml-3">
{{ __("Install") }}
</x-primary-button>
</div>
</form>
</x-modal>
@endpush

View File

@ -0,0 +1,13 @@
<form
id="install-nginx"
class="w-full"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-nginx"
>
@csrf
<input type="hidden" name="name" value="nginx" />
<input type="hidden" name="type" value="webserver" />
<input type="hidden" name="version" value="latest" />
<x-secondary-button class="!w-full" hx-disable>Install</x-secondary-button>
</form>

View File

@ -0,0 +1,43 @@
<x-secondary-button class="!w-full" x-on:click="$dispatch('open-modal', 'install-php')">Install</x-secondary-button>
@push("modals")
<x-modal name="install-php">
<form
id="install-php-form"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-php-form"
class="p-6"
>
@csrf
<input type="hidden" name="type" value="php" />
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __("Install PHP") }}
</h2>
<div class="mt-6">
<x-input-label for="version" value="Version" />
<x-select-input id="version" name="version" class="mt-1 w-full">
@foreach (config("core.php_versions") as $p)
<option value="{{ $p }}">
{{ $p }}
</option>
@endforeach
</x-select-input>
@error("version")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">
{{ __("Cancel") }}
</x-secondary-button>
<x-primary-button id="btn-install-php" hx-disable class="ml-3">
{{ __("Install") }}
</x-primary-button>
</div>
</form>
</x-modal>
@endpush

View File

@ -0,0 +1,50 @@
<x-secondary-button class="!w-full" x-on:click="$dispatch('open-modal', 'install-postgresql')">
Install
</x-secondary-button>
@push("modals")
<x-modal name="install-postgresql">
<form
id="install-postgresql-form"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-postgresql-form"
class="p-6"
>
@csrf
<input type="hidden" name="name" value="postgresql" />
<input type="hidden" name="type" value="database" />
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __("Install postgresql") }}
</h2>
<div class="mt-6">
<x-input-label for="version" value="Version" />
<x-select-input id="version" name="version" class="mt-1 w-full">
@foreach (collect(config("core.databases_name"))->filter(fn ($value) => $value == "postgresql") as $db => $value)
<option value="{{ config("core.databases_version")[$db] }}">
{{ config("core.databases_name")[$db] }} {{ config("core.databases_version")[$db] }}
</option>
@endforeach
</x-select-input>
@error("version")
<x-input-error class="mt-2" :messages="$message" />
@enderror
@error("type")
<x-input-error class="mt-2" :messages="$message" />
@enderror
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">
{{ __("Cancel") }}
</x-secondary-button>
<x-primary-button id="btn-install-postgresql" hx-disable class="ml-3">
{{ __("Install") }}
</x-primary-button>
</div>
</form>
</x-modal>
@endpush

View File

@ -0,0 +1,13 @@
<form
id="install-redis"
class="w-full"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-redis"
>
@csrf
<input type="hidden" name="name" value="redis" />
<input type="hidden" name="type" value="memory_database" />
<input type="hidden" name="version" value="latest" />
<x-secondary-button class="!w-full" hx-disable>Install</x-secondary-button>
</form>

View File

@ -0,0 +1,13 @@
<form
id="install-supervisor"
class="w-full"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-supervisor"
>
@csrf
<input type="hidden" name="name" value="supervisor" />
<input type="hidden" name="type" value="process_manager" />
<input type="hidden" name="version" value="latest" />
<x-secondary-button class="!w-full" hx-disable>Install</x-secondary-button>
</form>

View File

@ -0,0 +1,13 @@
<form
id="install-ufw"
class="w-full"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-ufw"
>
@csrf
<input type="hidden" name="name" value="ufw" />
<input type="hidden" name="type" value="firewall" />
<input type="hidden" name="version" value="latest" />
<x-secondary-button class="!w-full" hx-disable>Install</x-secondary-button>
</form>

View File

@ -0,0 +1,39 @@
<x-secondary-button class="!w-full" x-on:click="$dispatch('open-modal', 'install-vito-agent')">
Install
</x-secondary-button>
@push("modals")
<x-modal name="install-vito-agent">
<form
id="install-vito-agent-form"
hx-post="{{ route("servers.services.install", ["server" => $server]) }}"
hx-swap="outerHTML"
hx-select="#install-vito-agent-form"
class="p-6"
>
@csrf
<input type="hidden" name="name" value="vito-agent" />
<input type="hidden" name="type" value="monitoring" />
<input type="hidden" name="version" value="latest" />
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __("Install Vito Agent") }}
</h2>
<div class="mt-6">
<x-alert-warning>
Vito Agent is only works if you are running your Vito instance on a cloud not local!
</x-alert-warning>
</div>
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">
{{ __("Cancel") }}
</x-secondary-button>
<x-primary-button id="btn-vito-agent" hx-disable class="ml-3">
{{ __("Install") }}
</x-primary-button>
</div>
</form>
</x-modal>
@endpush

View File

@ -15,10 +15,10 @@ class="relative flex h-auto flex-col items-center justify-between space-y-3 roun
@include("services.partials.status", ["status" => $service->status])
</div>
<div class="space-y-3 p-5">
<div class="flex items-center justify-center">
<div class="mt-5 flex items-center justify-center">
<img
src="{{ asset("static/images/" . $service->name . ".svg") }}"
class="h-20 w-20"
class="h-[70px] w-[70px]"
alt=""
/>
</div>

View File

@ -11,7 +11,7 @@
@endif
@if ($status == \App\Enums\ServiceStatus::UNINSTALLING)
<x-status status="danger">{{ $status }}</x-status>
<x-status status="warning">{{ $status }}</x-status>
@endif
@if ($status == \App\Enums\ServiceStatus::FAILED)

View File

@ -1,42 +0,0 @@
<x-icon-button
data-tooltip="Restart Service"
class="cursor-pointer"
href="{{ route('servers.services.restart', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-arrow-path" class="h-5 w-5" />
</x-icon-button>
<x-icon-button
:disabled="$service->status != \App\Enums\ServiceStatus::STOPPED"
data-tooltip="Start Service"
class="cursor-pointer"
href="{{ route('servers.services.start', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-play" class="h-5 w-5 text-green-400" />
</x-icon-button>
<x-icon-button
data-tooltip="Stop Service"
:disabled="$service->status != \App\Enums\ServiceStatus::READY"
class="cursor-pointer"
href="{{ route('servers.services.stop', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-stop" class="h-5 w-5 text-red-400" />
</x-icon-button>
<x-icon-button
:disabled="$service->status != \App\Enums\ServiceStatus::DISABLED"
data-tooltip="Enable Service"
class="cursor-pointer"
href="{{ route('servers.services.enable', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-check" class="h-5 w-5" />
</x-icon-button>
<x-icon-button
data-tooltip="Disable Service"
class="cursor-pointer"
href="{{ route('servers.services.disable', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-no-symbol" class="h-5 w-5" />
</x-icon-button>

View File

@ -0,0 +1,7 @@
<x-icon-button
data-tooltip="Disable Service"
class="cursor-pointer"
href="{{ route('servers.services.disable', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-no-symbol" class="h-5 w-5" />
</x-icon-button>

View File

@ -0,0 +1,8 @@
<x-icon-button
:disabled="$service->status != \App\Enums\ServiceStatus::DISABLED"
data-tooltip="Enable Service"
class="cursor-pointer"
href="{{ route('servers.services.enable', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-check" class="h-5 w-5" />
</x-icon-button>

View File

@ -0,0 +1,7 @@
<x-icon-button
data-tooltip="Restart Service"
class="cursor-pointer"
href="{{ route('servers.services.restart', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-arrow-path" class="h-5 w-5" />
</x-icon-button>

View File

@ -0,0 +1,8 @@
<x-icon-button
:disabled="$service->status != \App\Enums\ServiceStatus::STOPPED"
data-tooltip="Start Service"
class="cursor-pointer"
href="{{ route('servers.services.start', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-play" class="h-5 w-5 text-green-400" />
</x-icon-button>

View File

@ -0,0 +1,8 @@
<x-icon-button
data-tooltip="Stop Service"
:disabled="$service->status != \App\Enums\ServiceStatus::READY"
class="cursor-pointer"
href="{{ route('servers.services.stop', ['server' => $server, 'service' => $service]) }}"
>
<x-heroicon name="o-stop" class="h-5 w-5 text-red-400" />
</x-icon-button>

View File

@ -0,0 +1,33 @@
<x-icon-button
data-tooltip="Uninstall Service"
class="cursor-pointer"
x-on:click="$dispatch('open-modal', 'uninstall-{{ $service->id }}')"
>
<x-heroicon name="o-trash" class="h-5 w-5" />
</x-icon-button>
@push("modals")
<x-modal name="uninstall-{{ $service->id }}">
<form
id="uninstall-{{ $service->id }}-form"
hx-post="{{ route("servers.services.uninstall", ["server" => $server, "service" => $service]) }}"
hx-target="#uninstall-{{ $service->id }}-form"
hx-select="#uninstall-{{ $service->id }}-form"
hx-swap="outerHTML"
class="p-6"
>
@csrf
@method("delete")
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">Confirm</h2>
<p>Are you sure that you want to uninstall this service?</p>
@error("service")
<x-input-error class="mt-2" :messages="$message" />
@enderror
<div class="mt-6 flex justify-end">
<x-secondary-button type="button" x-on:click="$dispatch('close')">Cancel</x-secondary-button>
<x-danger-button class="ml-3" hx-disable>Confirm</x-danger-button>
</div>
</form>
</x-modal>
@endpush