Enable setting autohold and address validation in web UI
This commit is contained in:
parent
92f964f572
commit
5389739920
@ -626,6 +626,28 @@ class SystemController extends Controller
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function api_address_validated_toggle(Request $request,string $state): array
|
||||||
|
{
|
||||||
|
$o = Address::findOrFail($request->id);
|
||||||
|
$o->validated = $state === 'off' ? FALSE : TRUE;
|
||||||
|
$o->save();
|
||||||
|
|
||||||
|
Log::debug(sprintf('%s:- Address Validated set to [%s]',self::LOGKEY,$o->autohold ? 'ON' : 'OFF'));
|
||||||
|
|
||||||
|
return ['validated'=>$o->validated];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function api_autohold_toggle(Request $request,string $state): array
|
||||||
|
{
|
||||||
|
$o = System::findOrFail($request->id);
|
||||||
|
$o->autohold = $state === 'off' ? FALSE : TRUE;
|
||||||
|
$o->save();
|
||||||
|
|
||||||
|
Log::debug(sprintf('%s:- Autohold set to [%s]',self::LOGKEY,$o->autohold ? 'ON' : 'OFF'));
|
||||||
|
|
||||||
|
return ['autohold'=>$o->autohold];
|
||||||
|
}
|
||||||
|
|
||||||
public function areafix(AreafixRequest $request,System $o,Zone $zo)
|
public function areafix(AreafixRequest $request,System $o,Zone $zo)
|
||||||
{
|
{
|
||||||
if ($request->post()) {
|
if ($request->post()) {
|
||||||
|
@ -118,7 +118,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($o->addresses->sortBy(function($item) { return sprintf('%04x%04x%04x%04x%04x',$item->zone->zone_id,$item->region_id,$item->host_id,$item->node_id,$item->point_id); }) as $oo)
|
@foreach ($o->addresses->sortBy(function($item) { return sprintf('%04x%04x%04x%04x%04x',$item->zone->zone_id,$item->region_id,$item->host_id,$item->node_id,$item->point_id); }) as $oo)
|
||||||
<tr>
|
<tr>
|
||||||
<td @if($oo->trashed()) class="trashed" @elseif (! $oo->active) class="inactive" @endif>{{ $oo->ftn }}<span class="float-end"><i title="@if($oo->validated)Mail flowing @else Mail held @endif" class="bi @if($oo->validated)bi-activity @else bi-radioactive @endif"></i></span></td>
|
<td @if($oo->trashed()) class="trashed" @elseif (! $oo->active) class="inactive" @endif>{{ $oo->ftn }}<span class="float-end"><data value="{{ $oo->id }}:{{ $oo->validated ? 1 : 0 }}" class="validated"><i title="@if($oo->validated)Mail flowing @else Mail held @endif" @class(['bi','bi-activity'=>$oo->validated,'bi-radioactive'=>(! $oo->validated)])></i></data></span></td>
|
||||||
<td>{{ $oo->active ? 'YES' : 'NO' }}</td>
|
<td>{{ $oo->active ? 'YES' : 'NO' }}</td>
|
||||||
<td class="text-end">{{ $oo->security }}</td>
|
<td class="text-end">{{ $oo->security }}</td>
|
||||||
<td>{{ $oo->role_name }}</td>
|
<td>{{ $oo->role_name }}</td>
|
||||||
@ -693,6 +693,54 @@
|
|||||||
cache: false
|
cache: false
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
$('data.validated').on('click',function(item) {
|
||||||
|
that = $(this);
|
||||||
|
var values = item.delegateTarget.value.split(':');
|
||||||
|
var icon = that.find('i');
|
||||||
|
|
||||||
|
if (values[1] === '1') {
|
||||||
|
$.ajax({
|
||||||
|
url: '/address/api/validated/off',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data : {id: values[0]},
|
||||||
|
beforeSend: function() {
|
||||||
|
that.addClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
that.removeClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
icon.removeClass('bi-activity')
|
||||||
|
.addClass('bi-radioactive');
|
||||||
|
|
||||||
|
that.attr('value',values[0]+':'+0);
|
||||||
|
},
|
||||||
|
cache: false
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$.ajax({
|
||||||
|
url: '/address/api/validated/on',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data : {id: values[0]},
|
||||||
|
beforeSend: function() {
|
||||||
|
that.addClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
that.removeClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
icon.removeClass('bi-radioactive')
|
||||||
|
.addClass('bi-activity');
|
||||||
|
|
||||||
|
that.attr('value',values[0]+':'+1);
|
||||||
|
},
|
||||||
|
cache: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@append
|
@append
|
@ -297,6 +297,11 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6">
|
||||||
|
<label for="passkey" class="form-label">Auto Hold</label>
|
||||||
|
<button id="autohold" @class(['btn','btn-danger'=>$o->autohold,'btn-success'=>(! $o->autohold)])><i @class(['bi-toggle-on'=>$o->autohold,'bi-toggle-off'=>(! $o->autohold)])></i></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endcan
|
@endcan
|
||||||
|
|
||||||
@ -440,6 +445,57 @@
|
|||||||
$('#heartbeat_option').addClass('d-none');
|
$('#heartbeat_option').addClass('d-none');
|
||||||
console.log('hold');
|
console.log('hold');
|
||||||
})
|
})
|
||||||
|
$("#autohold").on('click',function(item) {
|
||||||
|
var that = $(this)
|
||||||
|
var icon = that.find('i');
|
||||||
|
|
||||||
|
if (icon.hasClass('bi-toggle-on')) {
|
||||||
|
$.ajax({
|
||||||
|
url: '/system/api/autohold/off',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data : {id: {{ $o->id }}},
|
||||||
|
beforeSend: function() {
|
||||||
|
icon.addClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
icon.removeClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
icon.removeClass('bi-toggle-on')
|
||||||
|
.addClass('bi-toggle-off')
|
||||||
|
|
||||||
|
that.removeClass('btn-danger')
|
||||||
|
.addClass('btn-success')
|
||||||
|
},
|
||||||
|
cache: false
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$.ajax({
|
||||||
|
url: '/system/api/autohold/on',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data : {id: {{ $o->id }}},
|
||||||
|
beforeSend: function() {
|
||||||
|
icon.addClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
icon.removeClass('spinner-grow spinner-grow-sm')
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
icon.removeClass('bi-toggle-off')
|
||||||
|
.addClass('bi-toggle-on');
|
||||||
|
|
||||||
|
that.removeClass('btn-success')
|
||||||
|
.addClass('btn-danger')
|
||||||
|
},
|
||||||
|
cache: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@append
|
@append
|
@ -59,6 +59,10 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
|
|||||||
Route::match(['get','post'],'user/addedit/{o?}',[UserController::class,'add_edit'])
|
Route::match(['get','post'],'user/addedit/{o?}',[UserController::class,'add_edit'])
|
||||||
->where('o','[0-9]+');
|
->where('o','[0-9]+');
|
||||||
|
|
||||||
|
/* ADDRESS PATHS */
|
||||||
|
Route::post('address/api/validated/{state}',[SystemController::class,'api_address_validated_toggle'])
|
||||||
|
->whereIn('state',['on','off']);
|
||||||
|
|
||||||
/* DOMAIN PATHS */
|
/* DOMAIN PATHS */
|
||||||
Route::view('domain','domain.home');
|
Route::view('domain','domain.home');
|
||||||
Route::get('domain/api/hosts/{o}/{region}',[DomainController::class,'api_hosts'])
|
Route::get('domain/api/hosts/{o}/{region}',[DomainController::class,'api_hosts'])
|
||||||
@ -82,6 +86,8 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
|
|||||||
Route::view('system','system.home');
|
Route::view('system','system.home');
|
||||||
Route::post('system/api/address/{o}',[SystemController::class,'api_address'])
|
Route::post('system/api/address/{o}',[SystemController::class,'api_address'])
|
||||||
->where('o','[0-9]+');
|
->where('o','[0-9]+');
|
||||||
|
Route::post('system/api/autohold/{state}',[SystemController::class,'api_autohold_toggle'])
|
||||||
|
->whereIn('state',['on','off']);
|
||||||
Route::get('system/api/address/get/{o}',[SystemController::class,'api_address_get'])
|
Route::get('system/api/address/get/{o}',[SystemController::class,'api_address_get'])
|
||||||
->where('o','[0-9]+');
|
->where('o','[0-9]+');
|
||||||
Route::get('system/api/address/orphan',[SystemController::class,'api_address_orphan']);
|
Route::get('system/api/address/orphan',[SystemController::class,'api_address_orphan']);
|
||||||
|
Loading…
Reference in New Issue
Block a user