clrghouz/resources/views/system/widget/form-echoarea.blade.php
Deon George e9b5783945
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 43s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m34s
Create Docker Image / Final Docker Image Manifest (push) Successful in 11s
Complete implement of select2 component, and replaced existing use of select2. Also deprecated CustomBlade definitions of select2/simplemde
2024-12-06 14:44:19 +11:00

149 lines
4.1 KiB
PHP

<form class="needs-validation" method="post" action="{{ url('system/echoarea',$o->id) }}" autocomplete="off" novalidate>
@csrf
<div class="row pt-0">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<div class="row">
<!-- Select Domain -->
<div class="col-3">
<x-form.select id="echoarea_domain_id" name="domain_id" icon="bi-hash" label="Network" :options="$o->sessions->map(fn($item)=>['id'=>$item->domain_id,'value'=>sprintf('%s (%s)',$item->zone_id,$item->domain->name)])"/>
</div>
<!-- Select Address -->
<div class="col-3">
<div class="d-none" id="echoarea_address-select">
<x-form.select id="echoarea_address_id" name="address_id" icon="bi-hash" label="Address"/>
</div>
</div>
<!-- Summary of Addresses -->
<div class="offset-3 col-3" id="echoarea-summary">
<table class="table monotable">
<thead>
<tr>
<th>Network</th>
<th class="text-end">Areas</th>
</tr>
</thead>
<tbody>
@foreach ($o->echoareas()->with(['domain'])->get()->groupBy('domain_id') as $oo)
<tr>
<td>{{ $oo->first()->domain->name }}</td>
<td class="text-end">{{ $oo->count() }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@if($errors->count())
<div class="row">
<span class="btn btn-sm btn-danger" role="alert" style="text-align: left;">
There were errors with the submission.
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</span>
</div>
@endif
<div class="row">
<div class="col-12 d-none" id="echoarea-select"></div>
</div>
</div>
</div>
</div>
</form>
@section('page-scripts')
<script type="text/javascript" src="{{ asset('plugin/checkboxes/jquery.checkboxes-1.2.2.min.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#echoarea_domain_id').on('change',function() {
if (! $('#echoarea-select').hasClass('d-none'))
$('#echoarea-select').addClass('d-none');
if (! $(this).val()) {
$('#echoarea-summary').removeClass('d-none');
$('#echoarea_address-select').addClass('d-none');
return;
} else {
$('#echoarea_address-select').removeClass('d-none');
}
var item = this;
icon = $(item).parent().find('i');
$.ajax({
type: 'POST',
data: {domain_id: $(item).val()},
beforeSend: function() {
icon.addClass('spinner-grow spinner-grow-sm');
},
success: function(data) {
icon.removeClass('spinner-grow spinner-grow-sm');
$('#echoarea_address_id')
.empty()
.append($('<option>'))
.append(data.map(function(item) {
return $('<option>').val(item.id).text(item.value);
}));
},
error: function(e) {
icon.removeClass('spinner-grow spinner-grow-sm');
if (e.status != 412)
alert('That didnt work? Please try again....');
},
url: '{{ url('system/api/address',[$o->id]) }}',
cache: false
})
});
$('#echoarea_address_id').on('change',function() {
if (! $(this).val()) {
$('#echoarea-summary').removeClass('d-none');
$('#echoarea-select').addClass('d-none');
return;
}
if ($('#echoarea-select').hasClass('d-none')) {
$('#echoarea-select').removeClass('d-none');
$('#echoarea-summary').addClass('d-none');
}
var item = this;
icon = $(item).parent().find('i');
$.ajax({
type: 'GET',
data: {address_id: $(item).val()},
beforeSend: function() {
icon.addClass('spinner-grow spinner-grow-sm');
},
success: function(data) {
icon.removeClass('spinner-grow spinner-grow-sm');
$('#echoarea-select').empty().append(data);
$('#echoareas').checkboxes('range',true);
},
error: function(e) {
icon.removeClass('spinner-grow spinner-grow-sm');
if (e.status != 412)
alert('That didnt work? Please try again....');
},
url: '{{ url('system/echoarea',[$o->id]) }}',
cache: false
})
});
});
</script>
@append