mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +00:00
Migrate to HTMX (#114)
Dropped Livewire Added HTMX Added Blade code lint Drop Mysql and Redis Migrate to SQLite
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<x-server-layout :server="$server">
|
||||
<x-slot name="pageTitle">{{ __("Firewall") }}</x-slot>
|
||||
|
||||
<livewire:firewall.firewall-rules-list :server="$server"/>
|
||||
@include("firewall.partials.firewall-rules-list")
|
||||
</x-server-layout>
|
||||
|
@ -0,0 +1,92 @@
|
||||
<div>
|
||||
<x-primary-button x-data="" x-on:click.prevent="$dispatch('open-modal', 'create-rule')">
|
||||
{{ __("Create new Rule") }}
|
||||
</x-primary-button>
|
||||
|
||||
<x-modal name="create-rule">
|
||||
<form
|
||||
id="create-rule-form"
|
||||
hx-post="{{ route("servers.firewall.store", ["server" => $server]) }}"
|
||||
hx-swap="outerHTML"
|
||||
hx-select="#create-rule-form"
|
||||
class="p-6"
|
||||
>
|
||||
@csrf
|
||||
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
||||
{{ __("Create new Rule") }}
|
||||
</h2>
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="type" :value="__('Rule Type')" />
|
||||
<x-select-input id="type" name="type" class="mt-1 w-full">
|
||||
<option value="allow" @if(old('type', 'allow') === 'allow') selected @endif>
|
||||
{{ __("Allow") }}
|
||||
</option>
|
||||
<option value="deny" @if(old('type', 'allow') === 'deny') selected @endif>
|
||||
{{ __("Deny") }}
|
||||
</option>
|
||||
</x-select-input>
|
||||
@error("type")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mt-6 grid grid-cols-1 gap-3 lg:grid-cols-2">
|
||||
<div>
|
||||
<x-input-label for="protocol" :value="__('Protocol')" />
|
||||
<x-select-input id="protocol" name="protocol" class="mt-1 w-full">
|
||||
@foreach (config("core.firewall_protocols_port") as $key => $value)
|
||||
<option value="{{ $key }}" @if($key === old('protocol')) selected @endif>
|
||||
{{ $key }}
|
||||
</option>
|
||||
@endforeach
|
||||
</x-select-input>
|
||||
@error("protocol")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<x-input-label for="port" :value="__('Port')" />
|
||||
<x-text-input value="{{ old('port') }}" id="port" name="port" type="text" class="mt-1 w-full" />
|
||||
@error("port")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<x-input-label for="source" :value="__('Source')" />
|
||||
<x-text-input
|
||||
value="{{ old('source') }}"
|
||||
id="source"
|
||||
name="source"
|
||||
type="text"
|
||||
class="mt-1 w-full"
|
||||
/>
|
||||
@error("source")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<x-input-label for="mask" :value="__('Mask')" />
|
||||
<x-text-input value="{{ old('mask') }}" id="mask" name="mask" type="text" class="mt-1 w-full" />
|
||||
@error("mask")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
</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 class="ml-3" hx-disable>
|
||||
{{ __("Create") }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-modal>
|
||||
</div>
|
@ -0,0 +1,65 @@
|
||||
<div x-data="{ deleteAction: '' }">
|
||||
<x-card-header>
|
||||
<x-slot name="title">{{ __("Firewall Rules") }}</x-slot>
|
||||
<x-slot name="description">
|
||||
{{ __("Your server's firewall rules are here. You can manage them") }}
|
||||
</x-slot>
|
||||
<x-slot name="aside">
|
||||
@include("firewall.partials.create-firewall-rule")
|
||||
</x-slot>
|
||||
</x-card-header>
|
||||
|
||||
<x-live id="live-rules">
|
||||
<div x-data="" class="space-y-3">
|
||||
@foreach ($rules as $rule)
|
||||
<x-item-card>
|
||||
<div class="flex flex-grow flex-col items-start justify-center">
|
||||
<span class="mb-1 flex items-center uppercase">
|
||||
{{ $rule->protocol }}
|
||||
<x-status :status="$rule->type == 'allow' ? 'success' : 'danger'" class="ml-1">
|
||||
{{ $rule->type }}
|
||||
</x-status>
|
||||
</span>
|
||||
<span class="text-sm text-gray-400">
|
||||
{{ __("From") }}
|
||||
{{ $rule->source }}/{{ $rule->mask }} {{ __("Port") }} {{ $rule->port }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
@include("firewall.partials.status", ["status" => $rule->status])
|
||||
<div class="inline">
|
||||
<x-icon-button
|
||||
x-on:click="deleteAction = '{{ route('servers.firewall.destroy', ['server' => $server, 'firewallRule' => $rule]) }}'; $dispatch('open-modal', 'delete-rule')"
|
||||
>
|
||||
<x-heroicon-o-trash class="h-5 w-5" />
|
||||
</x-icon-button>
|
||||
</div>
|
||||
</div>
|
||||
</x-item-card>
|
||||
@endforeach
|
||||
|
||||
<x-item-card>
|
||||
<div class="flex flex-grow flex-col items-start justify-center">
|
||||
<span class="mb-1 flex items-center uppercase">
|
||||
{{ __("All") }}
|
||||
<x-status status="danger" class="ml-1">
|
||||
{{ __("Deny") }}
|
||||
</x-status>
|
||||
</span>
|
||||
<span class="text-sm text-gray-400">{{ __("From") }} 0.0.0.0/0</span>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
{{ __("Default") }}
|
||||
</div>
|
||||
</x-item-card>
|
||||
</div>
|
||||
</x-live>
|
||||
|
||||
<x-confirmation-modal
|
||||
name="delete-rule"
|
||||
:title="__('Confirm')"
|
||||
:description="__('Are you sure that you want to delete this rule?')"
|
||||
method="delete"
|
||||
x-bind:action="deleteAction"
|
||||
/>
|
||||
</div>
|
11
resources/views/firewall/partials/status.blade.php
Normal file
11
resources/views/firewall/partials/status.blade.php
Normal file
@ -0,0 +1,11 @@
|
||||
@if ($status == \App\Enums\FirewallRuleStatus::READY)
|
||||
<x-status status="success">{{ $status }}</x-status>
|
||||
@endif
|
||||
|
||||
@if ($status == \App\Enums\FirewallRuleStatus::CREATING)
|
||||
<x-status status="warning">{{ $status }}</x-status>
|
||||
@endif
|
||||
|
||||
@if ($status == \App\Enums\FirewallRuleStatus::DELETING)
|
||||
<x-status status="danger">{{ $status }}</x-status>
|
||||
@endif
|
Reference in New Issue
Block a user