Usability fixes

This commit is contained in:
Deon George 2021-07-02 23:19:50 +10:00
parent 4522f26bf3
commit 64fd264427
8 changed files with 47 additions and 14 deletions

View File

@ -6,7 +6,7 @@ RUN mkdir /var/www/.composer \
&& ([ -r auth.json ] && mv auth.json /var/www/.composer/) || true \
&& touch .composer.refresh \
&& mv .env.example .env \
&& FORCE_PERMS=1 /sbin/init \
&& FORCE_PERMS=1 NGINX_START=FALSE /sbin/init \
&& chmod +x /var/www/html/artisan /var/www/html/init-php.sh \
&& touch .migrate \
&& rm -rf /var/www/.composer/*

View File

@ -65,7 +65,7 @@ class DomainController extends Controller
$oo = Address::where('role',self::NODE_NC)
->where('zone_id',$o->id)
->when($region,function($query,$region) { return $query->where('region_id',$region)->where('node_id','<>',0); })
->when((! $region),function($query) use ($region) { return $query->whereNull('region_id'); })
->when((! $region),function($query) use ($region) { return $query->where('region_id',0); })
->where('point_id',0)
->with(['system'])
->get();

View File

@ -7,7 +7,8 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use App\Classes\FTN\Packet;
use App\Models\{Address,Domain,Setup};
use App\Models\{Address, Domain, Setup, System};
use Illuminate\Support\Facades\DB;
class HomeController extends Controller
{
@ -28,6 +29,12 @@ class HomeController extends Controller
->with('user',Auth::user());
}
/**
* Show a packet dump
*
* @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
*/
public function pkt(Request $request)
{
$pkt = NULL;
@ -60,6 +67,12 @@ class HomeController extends Controller
->with('result',$pkt);
}
/**
* Process searching
*
* @param Request $request
* @return Collection
*/
public function search(Request $request): Collection
{
$this->middleware('auth');
@ -69,23 +82,33 @@ class HomeController extends Controller
list($zone_id,$host_id,$node_id,$point_id,$domain) = sscanf($request->query('term'),'%d:%d/%d.%d@%s');
# Look for Opportunities
foreach (Address::select(['domain_id','addresses.zone_id','host_id','node_id','point_id','addresses.system_id'])
->join('systems',['systems.id'=>'addresses.system_id'])
foreach (Address::select(['systems.name',DB::raw('systems.id AS system_id'),'zones.zone_id','region_id','host_id','node_id','point_id'])
->join('zones',['zones.id'=>'addresses.zone_id'])
->when($zone_id,function($q,$zone_id) { return $q->where('zones.zone_id','ilike','%'.$zone_id.'%'); })
->when($host_id,function($q,$host_id) { return $q->where('host_id','ilike','%'.$host_id.'%'); })
->when($node_id,function($q,$node_id) { return $q->where('node_id','ilike','%'.$node_id.'%'); })
->rightjoin('systems',['systems.id'=>'addresses.system_id'])
->when($zone_id || $host_id || $node_id,function($query) use ($zone_id,$host_id,$node_id) {
return $query
->when($zone_id,function($q,$zone_id) { return $q->where('zones.zone_id','ilike','%'.$zone_id.'%'); })
->where(function($q) use ($host_id) {
return $q
->when($host_id,function($q,$host_id) { return $q->where('region_id','ilike','%'.$host_id.'%'); })
->when($host_id,function($q,$host_id) { return $q->orWhere('host_id','ilike','%'.$host_id.'%'); });
})
->when($node_id,function($q,$node_id) { return $q->where('node_id','ilike','%'.$node_id.'%'); });
})
->orWhere('systems.name','ilike','%'.$request->query('term').'%')
->orWhere('systems.sysop','ilike','%'.$request->query('term').'%')
->limit(10)
->OrderBy('systems.name')
->with(['system'])
->get() as $o)
{
$result->push(['name'=>sprintf('%s (%s)',$o->system->name,$o->ftn),'value'=>url('ftn/system/addedit',[$o->system_id]),'category'=>'Systems']);
$ftn = NULL;
if ($o->zone_id && ($o->region_id||$o->host_id) && is_numeric($o->node_id) && is_numeric($o->point_id))
$ftn = sprintf('%d:%d/%d.%d',$o->zone_id,$o->host_id ?: $o->region_id,$o->node_id,$o->point_id);
$result->push(['id'=>$o->system_id,'name'=>$o->name.($ftn ? ' '.$ftn : ''),'value'=>url('ftn/system/addedit',[$o->system_id]),'category'=>'Systems']);
}
return $result;
return $result->unique(['id'])->take(10)->values();
}
/**

View File

@ -229,6 +229,8 @@ class SystemController extends Controller
session()->flash('add_address',TRUE);
$sid = $o->system_id;
$o->active = FALSE;
$o->save();
$o->delete();
return redirect()->to(sprintf('ftn/system/addedit/%d',$sid));

View File

@ -26,6 +26,11 @@ class Address extends Model
/* RELATIONS */
public function children()
{
return $this->belongsTo(self::class,'id','hub_id');
}
public function system()
{
return $this->belongsTo(System::class);

View File

@ -103,7 +103,6 @@
<td>{{ $aoo->system->full_name($aoo) }} @auth<span class="float-end"><small>[{{ $aoo->system_id }}]</small></span>@endauth</td>
<td>{{ $aoo->system->sysop }}</td>
<td>{{ $aoo->system->location }}</td>
<td>{{ $aoo->role }}</td>
<td>{{ $aoo->ftn_3d }}</td>
<td>-</td>
</tr>

View File

@ -18,7 +18,9 @@
@endauth
<dl>
<dt>Expore Networks</dt>
@foreach (\App\Models\Domain::active()->public()->orderBy('name')->get() as $o)
@foreach (\App\Models\Domain::active()
->when(! \Illuminate\Support\Facades\Auth::check(),function($query) { return $query->public(); })
->orderBy('name')->get() as $o)
<dd><a href="{{ url('network',['id'=>$o->id]) }}" title="{{ $o->description }}">{{ $o->name }}</a></dd>
@endforeach
</dl>

View File

@ -301,6 +301,7 @@
<td>{{ $oo->active ? 'YES' : 'NO' }}</td>
<td>{{ $oo->role }}</td>
<td style="width: 70px;">
@if (! $oo->children)
@can('admin',$oo)
<a href="{{ url('ftn/system/susaddress',[$oo->id]) }}" title="@if($oo->active)Pause @else Activate @endif Address" class="suspend"><i class="bi @if($oo->active)bi-pause-circle-fill @else bi-play-circle-fill @endif"></i></a>
{{--
@ -309,6 +310,7 @@
--}}
<a href="{{ url('ftn/system/deladdress',[$oo->id]) }}" title="Delete Address" class="delete"><i class="bi bi-trash-fill"></i></a>
@endcan
@endif
</td>
</tr>
@endforeach