Enabled akas() method to only show current active akas. Should fix the link register netmail from polling an invalid FTN id.
This commit is contained in:
parent
b8534d8598
commit
fdbc58856b
@ -596,7 +596,7 @@ class SystemController extends Controller
|
||||
|
||||
$ca = NULL;
|
||||
$la = NULL;
|
||||
foreach ($s->addresses as $ao) {
|
||||
foreach ($s->akas as $ao) {
|
||||
if (($ca=$so->match($ao->zone))->count())
|
||||
break;
|
||||
}
|
||||
|
@ -61,6 +61,18 @@ class Address extends Model
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->select($this->getTable().'.*')
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->join('domains',['domains.id'=>'zones.domain_id'])
|
||||
->where('addresses.active',TRUE)
|
||||
->where('zones.active',TRUE)
|
||||
->where('domains.active',TRUE)
|
||||
->orderBy('domains.name')
|
||||
->FTNorder();
|
||||
}
|
||||
|
||||
public function scopeFTNOrder($query)
|
||||
{
|
||||
return $query
|
||||
@ -293,6 +305,17 @@ class Address extends Model
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
/**
|
||||
* Return if this address is active
|
||||
*
|
||||
* @param bool $value
|
||||
* @return bool
|
||||
*/
|
||||
public function getActiveAttribute(bool $value): bool
|
||||
{
|
||||
return $value && $this->zone->active && $this->zone->domain->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the node name in full 5D
|
||||
*
|
||||
@ -356,7 +379,6 @@ class Address extends Model
|
||||
// Are we looking for a region address
|
||||
if (($ftn['f'] === 0) && $ftn['p'] === 0) {
|
||||
$o = (new self)->active()
|
||||
->select('addresses.*')
|
||||
->where('zones.zone_id',$ftn['z'])
|
||||
->where(function($q) use ($ftn) {
|
||||
return $q
|
||||
@ -367,11 +389,6 @@ class Address extends Model
|
||||
})
|
||||
->where('node_id',$ftn['f'])
|
||||
->where('point_id',$ftn['p'])
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->join('domains',['domains.id'=>'zones.domain_id'])
|
||||
->where('zones.active',TRUE)
|
||||
->where('domains.active',TRUE)
|
||||
->where('addresses.active',TRUE)
|
||||
->when($ftn['d'],function($query,$domain) {
|
||||
$query->where('domains.name',$domain);
|
||||
})
|
||||
@ -385,7 +402,6 @@ class Address extends Model
|
||||
}
|
||||
|
||||
$o = (new self)->active()
|
||||
->select('addresses.*')
|
||||
->where('zones.zone_id',$ftn['z'])
|
||||
->where(function($q) use ($ftn) {
|
||||
return $q->where(function($qq) use ($ftn) {
|
||||
@ -400,11 +416,6 @@ class Address extends Model
|
||||
})
|
||||
->where('node_id',$ftn['f'])
|
||||
->where('point_id',$ftn['p'])
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->join('domains',['domains.id'=>'zones.domain_id'])
|
||||
->where('zones.active',TRUE)
|
||||
->where('domains.active',TRUE)
|
||||
->where('addresses.active',TRUE)
|
||||
->when($ftn['d'],function($query,$domain) {
|
||||
$query->where('domains.name',$domain);
|
||||
})
|
||||
|
@ -59,17 +59,19 @@ final class Netmail extends Model implements Packet
|
||||
static::created(function($model) {
|
||||
// Save the Path
|
||||
$ppoid = NULL;
|
||||
foreach ($model->set_path as $path) {
|
||||
$po = DB::select('INSERT INTO netmail_path (netmail_id,address_id,parent_id,datetime,program) VALUES (?,?,?,?,?) RETURNING id',[
|
||||
$model->id,
|
||||
$path['node']->id,
|
||||
$ppoid,
|
||||
(string)$path['datetime'],
|
||||
$path['program'],
|
||||
]);
|
||||
|
||||
$ppoid = $po[0]->id;
|
||||
}
|
||||
if (isset($model->set_path))
|
||||
foreach ($model->set_path as $path) {
|
||||
$po = DB::select('INSERT INTO netmail_path (netmail_id,address_id,parent_id,datetime,program) VALUES (?,?,?,?,?) RETURNING id',[
|
||||
$model->id,
|
||||
$path['node']->id,
|
||||
$ppoid,
|
||||
(string)$path['datetime'],
|
||||
$path['program'],
|
||||
]);
|
||||
|
||||
$ppoid = $po[0]->id;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,12 @@ class System extends Model
|
||||
->FTNorder();
|
||||
}
|
||||
|
||||
public function akas()
|
||||
{
|
||||
return $this->hasMany(Address::class)
|
||||
->active();
|
||||
}
|
||||
|
||||
public function logs()
|
||||
{
|
||||
return $this->hasMany(SystemLog::class);
|
||||
|
4
public/oldschool/css/main.css
vendored
4
public/oldschool/css/main.css
vendored
@ -819,6 +819,10 @@ a.link:focus:after {
|
||||
color: #0c0c0c;
|
||||
}
|
||||
|
||||
.inactive {
|
||||
color: #3f6982;
|
||||
}
|
||||
|
||||
.trashed {
|
||||
text-decoration: line-through;
|
||||
color: #3f6982;
|
||||
|
@ -24,7 +24,7 @@
|
||||
@foreach ($user->systems as $o)
|
||||
<tr>
|
||||
<th><a href="{{ url('ftn/system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
|
||||
<th class="text-end">{!! $o->addresses->pluck('ftn')->join('<br>') !!}</th>
|
||||
<th class="text-end">{!! $o->akas->pluck('ftn')->join('<br>') !!}</th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@ -107,7 +107,7 @@
|
||||
<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)
|
||||
<tr>
|
||||
<td @if($oo->trashed()) class="trashed" @endif>{{ $oo->ftn }}</td>
|
||||
<td @if($oo->trashed()) class="trashed" @elseif (! $oo->active) class="inactive" @endif>{{ $oo->ftn }}</td>
|
||||
<td>{{ $oo->active ? 'YES' : 'NO' }}</td>
|
||||
<td>{{ $oo->role_name }}</td>
|
||||
<td class="nowrap actions">
|
||||
@ -120,6 +120,9 @@
|
||||
@if($oo->trashed())
|
||||
<a href="{{ url('ftn/system/recaddress',[$oo->id]) }}" title="Restore Address"><i class="bi bi-bandaid-fill"></i></a>
|
||||
<a href="{{ url('ftn/system/puraddress',[$oo->id]) }}" title="Purge Address" class="purge"><i class="bi bi-scissors"></i></a>
|
||||
@elseif(! $oo->active)
|
||||
<!-- No options -->
|
||||
<a href="javascript:;" title="Net Disabled"><i class="bi bi-slash-square"></i></a>
|
||||
@else
|
||||
<a href="{{ url('ftn/system/susaddress',[$oo->id]) }}" title="@if($oo->active)Pause @else Activate @endif Address"><i class="bi @if($oo->active)bi-pause-circle-fill @else bi-play-circle-fill @endif"></i></a>
|
||||
<a href="{{ url('ftn/system/movaddress',[$o->id,$oo->id]) }}" title="Move Address to another System"><i class="bi bi-arrow-right-square-fill"></i></a>
|
||||
|
@ -15,7 +15,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Networks</th>
|
||||
<th>{{ $o->addresses->pluck('ftn')->join(', ') }}</th>
|
||||
<th>{{ $o->akas->pluck('ftn')->join(', ') }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Address</th>
|
||||
|
Loading…
Reference in New Issue
Block a user