|
|
|
@@ -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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|