clrghouz/resources/views/domain/addedit.blade.php

183 lines
7.7 KiB
PHP

<!-- $o=Domain::class -->
@use(Illuminate\Support\Facades\Gate)
@use(App\Models\Echoarea)
@extends('layouts.app')
@section('htmlheader_title')
@if($o->exists) Update @else Add @endif Domain
@endsection
@section('content')
<form class="needs-validation" method="post" autocomplete="off" novalidate>
@csrf
<div class="row">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<h2 class="cap">@if($o->exists) Update @else Add @endif Domain</h2>
<div class="row">
<div class="col-4">
<label for="name" class="form-label">Name</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" placeholder="Name" name="name" value="{{ old('name',$o->name) }}" required @cannot('admin',$o)disabled @endcannot autofocus autocomplete="off">
<span class="invalid-feedback" role="alert">
@error('name')
{{ $message }}
@else
A name is required.
@enderror
</span>
</div>
</div>
<div class="col-2">
<label class="form-label">Active</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active))checked @endif>
<label class="btn btn-outline-success" for="active_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active))checked @endif>
<label class="btn btn-outline-danger" for="active_no">No</label>
</div>
</div>
</div>
<div class="col-2">
@if ($o->zones?->count() > 1)
<label class="form-label">Flatten Zones <i class="bi bi-info-circle" title="Treat this domain as a 2D domain"></i></label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="flatten" id="flatten_yes" value="1" required @if(old('flatten',$o->flatten))checked @endif>
<label class="btn btn-outline-warning" for="flatten_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="flatten" id="flatten_no" value="0" required @if(! old('flatten',$o->flatten))checked @endif>
<label class="btn btn-outline-success" for="flatten_no">No</label>
</div>
</div>
@endif
</div>
<div class="col-4">
@if ($o->isManaged())
@if ($o->nodelist_filename)
<label for="nodelist_filename" class="form-label">Nodelist File</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-file-earmark-break-fill"></i></span>
<input type="text" class="form-control" id="nodelist_filename" placeholder="Nodelist" name="nodelist_filename" value="{{ $o->nodelist_filename }}" readonly>
</div>
@else
No Nodelist file
@endif
@else
This domain is not configured here.
@endif
</div>
</div>
<div class="row">
<div class="col-4">
<label for="dnsdomain" class="form-label">DNS Domain</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="form-control @error('dnsdomain') is-invalid @enderror" id="dnsdomain" placeholder="DNS Domain (if applicable)" name="dnsdomain" value="{{ old('dnsdomain',$o->dnsdomain) }}" @cannot('admin',$o)disabled @endcannot>
<span class="invalid-feedback" role="alert">
@error('dnsdomain')
{{ $message }}
@enderror
</span>
</div>
</div>
<div class="col-2">
<label class="form-label">Public</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="public" id="public_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('public',$o->public))checked @endif>
<label class="btn btn-outline-success" for="public_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="public" id="public_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('public',$o->public))checked @endif>
<label class="btn btn-outline-danger" for="public_no">No</label>
</div>
</div>
</div>
<div class="col-2">
@if ($o->isManaged())
<label class="form-label">Applications</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="accept_app" id="accept_app_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('accept_app',$o->accept_app))checked @endif>
<label class="btn btn-outline-success" for="accept_app_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="accept_app" id="accept_app_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('accept_app',$o->accept_app))checked @endif>
<label class="btn btn-outline-danger" for="accept_app_no">No</label>
</div>
</div>
@endif
</div>
@if ($o->nodelist_filename)
<div class="col-4">
<label for="nodelist" class="form-label">Nodelist File Area</label>
<a href="{{ url('filearea/addedit',$o->nodelist_filearea_id) }}">
<div class="input-group">
<span class="input-group-text"><i class="bi bi-collection-fill"></i></span>
<input type="text" class="form-control @error('nodelist') is-invalid @enderror" id="nodelist" placeholder="Nodelist" name="nodelist" value="{{ $o->nodelist_filearea->name }}" readonly>
</div>
</a>
</div>
@endif
</div>
<div class="row">
<div class="col-8">
</div>
<div class="col-4">
@if ($o->isManaged())
@php
$helper = (! $o->nodestatus_id)
? sprintf('Add a <a href="%s">NEW Echoarea</a>. This echoarea is used to send node status messages.',url('echoarea/addedit'))
: sprintf('<a href="%s">Edit</a> Echoarea',url('echoarea/addedit',[$o->nodestatus_id]));
@endphp
<x-form.select name="nodestatus_id" icon="bi-journal-text" label="Echoarea Node Status" :helper="$helper" :value="$o->nodestatus_id" :options="Echoarea::select('id','description')->active()->where('domain_id',$o->id)->orderBy('description')->cursor()->map(fn($item)=>['id'=>$item->id,'value'=>$item->description])"/>
@endif
</div>
</div>
<div class="row">
<div class="col-12">
<x-form.notes name="notes" label="Notes" rows=3 placeholder="Notes..." :value="$o->notes" :disabled="Gate::denies('admin',$o)"/>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<h2 class="cap">Home Page</h2>
<div class="row">
<div class="col-12" >
<x-form.notes name="homepage" label="Home Page Text" rows=5 placeholder="Home Page..." :value="$o->homepage" :disabled="Gate::denies('admin',$o)" :simplemde="true"/>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<a href="{{ url('domain') }}" class="btn btn-danger">Cancel</a>
@can('admin',$o)
<button type="submit" name="submit" class="btn btn-success float-end">@if ($o->exists)Save @else Add @endif</button>
@endcan
</div>
</div>
</div>
</div>
</form>
@endsection