diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php
index b459062..25cb4de 100644
--- a/app/Http/Controllers/SystemController.php
+++ b/app/Http/Controllers/SystemController.php
@@ -626,6 +626,28 @@ class SystemController extends Controller
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)
{
if ($request->post()) {
diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php
index 2cac2d8..8fe565c 100644
--- a/resources/views/system/addedit.blade.php
+++ b/resources/views/system/addedit.blade.php
@@ -118,7 +118,7 @@
@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)
- trashed()) class="trashed" @elseif (! $oo->active) class="inactive" @endif>{{ $oo->ftn }} |
+ trashed()) class="trashed" @elseif (! $oo->active) class="inactive" @endif>{{ $oo->ftn }}$oo->validated,'bi-radioactive'=>(! $oo->validated)])> |
{{ $oo->active ? 'YES' : 'NO' }} |
{{ $oo->security }} |
{{ $oo->role_name }} |
@@ -693,6 +693,54 @@
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
+ });
+ }
+ });
});
@append
\ No newline at end of file
diff --git a/resources/views/system/widget/system.blade.php b/resources/views/system/widget/system.blade.php
index 467f786..c08dfc4 100644
--- a/resources/views/system/widget/system.blade.php
+++ b/resources/views/system/widget/system.blade.php
@@ -297,6 +297,11 @@
+
+
+
+
+
@endcan
@@ -440,6 +445,57 @@
$('#heartbeat_option').addClass('d-none');
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;
+ })
})
@append
\ No newline at end of file
diff --git a/routes/web.php b/routes/web.php
index f0e9622..3eb3619 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -59,6 +59,10 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
Route::match(['get','post'],'user/addedit/{o?}',[UserController::class,'add_edit'])
->where('o','[0-9]+');
+ /* ADDRESS PATHS */
+ Route::post('address/api/validated/{state}',[SystemController::class,'api_address_validated_toggle'])
+ ->whereIn('state',['on','off']);
+
/* DOMAIN PATHS */
Route::view('domain','domain.home');
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::post('system/api/address/{o}',[SystemController::class,'api_address'])
->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'])
->where('o','[0-9]+');
Route::get('system/api/address/orphan',[SystemController::class,'api_address_orphan']);