diff --git a/Dockerfile b/Dockerfile index a26acc1..5899c1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/* diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php index d292dc3..f0c4736 100644 --- a/app/Http/Controllers/DomainController.php +++ b/app/Http/Controllers/DomainController.php @@ -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(); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index cba0f27..ab58ba5 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -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(); } /** diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 6629fb9..2680579 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -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)); diff --git a/app/Models/Address.php b/app/Models/Address.php index 6435d19..f8a412e 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -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); diff --git a/resources/views/domain/view.blade.php b/resources/views/domain/view.blade.php index 70d56d8..1015cc5 100644 --- a/resources/views/domain/view.blade.php +++ b/resources/views/domain/view.blade.php @@ -103,7 +103,6 @@ {{ $aoo->system->full_name($aoo) }} @auth[{{ $aoo->system_id }}]@endauth {{ $aoo->system->sysop }} {{ $aoo->system->location }} - {{ $aoo->role }} {{ $aoo->ftn_3d }} - diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 4287ec9..e9a6ba7 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -18,7 +18,9 @@ @endauth
Expore Networks
- @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)
{{ $o->name }}
@endforeach
diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 3936560..0b80329 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -301,6 +301,7 @@ {{ $oo->active ? 'YES' : 'NO' }} {{ $oo->role }} + @if (! $oo->children) @can('admin',$oo) {{-- @@ -309,6 +310,7 @@ --}} @endcan + @endif @endforeach