diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 00152f1..1740138 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -2,10 +2,11 @@ namespace App\Http\Controllers; +use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Arr; -use App\Models\{Address,System,SystemZone,Zone}; +use App\Models\{Address,Echoarea,System,SystemZone,Zone}; use App\Rules\{FidoInteger,TwoByteInteger}; class SystemController extends Controller @@ -27,7 +28,7 @@ class SystemController extends Controller { // @todo This should be admin of the zone $this->authorize('admin',$o); - session()->flash('add_address',TRUE); + session()->flash('accordion','address'); $request->validate([ 'action' => 'required|in:region,host,node', @@ -222,7 +223,7 @@ class SystemController extends Controller { // @todo This should be admin of the zone $this->authorize('admin',$o); - session()->flash('add_session',TRUE); + session()->flash('accordion','session'); $validate = $request->validate([ 'zone_id' => 'required|exists:zones,id', @@ -293,7 +294,7 @@ class SystemController extends Controller { // @todo This should be admin of the zone $this->authorize('admin',$o); - session()->flash('add_address',TRUE); + session()->flash('accordion','address'); $sid = $o->system_id; $o->active = FALSE; @@ -313,13 +314,46 @@ class SystemController extends Controller public function del_session(System $o,Zone $zo) { $this->authorize('admin',$zo); - session()->flash('add_session',TRUE); + session()->flash('accordion','session'); $o->sessions()->detach($zo); return redirect()->to(sprintf('ftn/system/addedit/%d',$o->id)); } + /** + * Update the systems echoareas + * + * @param Request $request + * @param System $o + */ + public function echoareas(Request $request,System $o) + { + $ao = $o->addresses->filter(function($item) use ($request) { return $item->zone->domain_id == $request->domain_id; })->first(); + + if (($request->method() == 'POST') && $request->post()) { + session()->flash('accordion','echoarea'); + + // Ensure we have session details for this address. + if (! $ao->session('sespass')) + return redirect()->back()->withErrors('System doesnt belong to this network'); + + $ao->echoareas()->syncWithPivotValues($request->id,['subscribed'=>Carbon::now()]); + + return redirect()->back()->with('success','Echoareas updated');; + } + + $eo = Echoarea::active() + ->where('domain_id',$request->domain_id) + ->orderBy('name') + ->get(); + + return view('system.widget.echoarea') + ->with('o',$o) + ->with('ao',$ao) + ->with('echoareas',$eo); + } + /** * Move address to another system * @@ -331,6 +365,8 @@ class SystemController extends Controller */ public function mov_address(Request $request,System $so,Address $o) { + session()->flash('accordion','address'); + // Quick check that this address belongs to this system if ($so->addresses->search(function($item) use ($o) { return $item->id == $o->id; }) === FALSE) abort(404); @@ -378,7 +414,7 @@ class SystemController extends Controller { // @todo This should be admin of the zone $this->authorize('admin',$o); - session()->flash('add_address',TRUE); + session()->flash('accordion','address'); $o->active = (! $o->active); $o->save(); diff --git a/app/Models/Address.php b/app/Models/Address.php index 25f4292..4f7aac1 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -109,6 +109,12 @@ class Address extends Model ->with(['zone.domain']); } + public function echoareas() + { + return $this->belongsToMany(Echoarea::class) + ->withPivot(['subscribed']); + } + /** * Who we send this systems mail to. * diff --git a/app/Models/System.php b/app/Models/System.php index 5a39045..8b1ceef 100644 --- a/app/Models/System.php +++ b/app/Models/System.php @@ -72,6 +72,14 @@ class System extends Model /* METHODS */ + public function echoareas() + { + return Echoarea::select('echoareas.*') + ->join('address_echoarea',['address_echoarea.echoarea_id'=>'echoareas.id']) + ->join('addresses',['addresses.id'=>'address_echoarea.address_id']) + ->where('addresses.system_id',$this->id); + } + /** * Return the system's address in the same zone * diff --git a/public/plugin/checkboxes/jquery.checkboxes-1.2.2.min.js b/public/plugin/checkboxes/jquery.checkboxes-1.2.2.min.js new file mode 100644 index 0000000..7e4352c --- /dev/null +++ b/public/plugin/checkboxes/jquery.checkboxes-1.2.2.min.js @@ -0,0 +1 @@ +/*! checkboxes.js v1.2.2 | (c) 2013 - 2018 Rubens Mariuzzo | http://github.com/rmariuzzo/checkboxes.js/LICENSE */"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function a(a,b){for(var c=0;c0){var b=this;this.$context.on("click.checkboxes.max",":checkbox",function(){b.$context.find(":checked").length===a?b.$context.find(":checkbox:not(:checked)").prop("disabled",!0):b.$context.find(":checkbox:not(:checked)").prop("disabled",!1)})}else this.$context.off("click.checkboxes.max")}},{key:"range",value:function(b){if(b){var c=this;this.$context.on("click.checkboxes.range",":checkbox",function(b){var d=a(b.target);if(b.shiftKey&&c.$last){var e=c.$context.find(":checkbox:visible"),f=e.index(c.$last),g=e.index(d),h=Math.min(f,g),i=Math.max(f,g)+1;e.slice(h,i).filter(":not(:disabled)").prop("checked",d.prop("checked")).trigger("change")}c.$last=d})}else this.$context.off("click.checkboxes.range")}}]),b}(),c=a.fn.checkboxes;a.fn.checkboxes=function(c){var d=Array.prototype.slice.call(arguments,1);return this.each(function(e,f){var g=a(f),h=g.data("checkboxes");h||g.data("checkboxes",h=new b(g)),"string"==typeof c&&h[c]&&h[c].apply(h,d)})},a.fn.checkboxes.Constructor=b,a.fn.checkboxes.noConflict=function(){return a.fn.checkboxes=c,this};var d=function(b){var c=a(b.target),d=c.attr("href"),e=a(c.data("context")||d&&d.replace(/.*(?=#[^\s]+$)/,"")),f=c.data("action");e&&f&&(c.is(":checkbox")||b.preventDefault(),e.checkboxes(f))},e=function(){a("[data-toggle^=checkboxes]").each(function(){var b=a(this),c=b.data();delete c.toggle;for(var d in c)b.checkboxes(d,c[d])})};a(document).on("click.checkboxes.data-api","[data-toggle^=checkboxes]",d),a(document).on("ready.checkboxes.data-api",e)}(window.jQuery); \ No newline at end of file diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 8636543..e0afa88 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -24,19 +24,129 @@ use App\Http\Controllers\DomainController as DC;

System

-
+
@include('system.form-system')
+ +
+ + +
+
+

FidoNet addresses are constructed in the format zone:net/node.point@domain.

+ +
+ + +
+
+

FidoNet system are also assigned some roles, and in some cases, those roles have a particular address format:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RoleAddress Format
Zone (optional) + ZONE:0/0.0, where the net, node and point values are zero. Zones normally have 1 or more Regions and/or Hosts.

+ (Systems that do not configure other systems with a zone, assume that that other system is in the same zone as the system being configured.) +
Region (optional) + zone:REGION/0.0, where the zone indicates which zone the region is in. The node and point values are zero. Regions normally have 1 or more Hosts.

+ Fidonet software normally doesnt configure the region address per-se. It is used by the mailer to receive packets destined to it by routing, in transition to the final destination. The region number must be unique with a zone. +
Host (mandatory) + zone:HOST/0.0, where the zone indicates which zone the host is in. The node and point values are zero. The Host system is normally configured with an additional address, where the NET address is the same and the NODE number that is greater than zero. Hosts may may zero or more Hubs and 1 or more Nodes.

+ The host number must be unique within a zone, which implies that it cannot be the same as a region, if regions are used. +
Hub (optional) + zone:net/NODE.0, where the zone/net indicates which zone/net the hub is in. The system(s) in the nodelist below a Hub are fed from that hub from a routing perspective.

+ The node is unique within the net and point is zero. +
Node (required) + zone:net/NODE.0, where the zone/net indicates which zone/net the node is in.

+ The node is unique within the net and point is zero. +
+
+
+
+ + @if($o->addresses->count()) +

This system has the following addresses assigned to it:

+ + + + + + + + + + + + @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) + + + + + + + @endforeach + +
AddressActiveRole
{{ $oo->ftn }}{{ $oo->active ? 'YES' : 'NO' }}{{ $oo->role_name }} + @can('admin',$oo) + + {{-- + @if (! $oo->role & (DC::NODE_ZC|DC::NODE_RC|DC::NODE_NC)) + + @endif + --}} + + + @endcan +
+ @endif + + @can('admin',$o) + @include('system.form-address') + + @else + You'll need to ask an admin to assign addresses. + @endcan +
+
+
+ @if(! $o->setup)
-
+
@if ($o->sessions->count()) @@ -90,193 +200,95 @@ use App\Http\Controllers\DomainController as DC; - @endif - -
- + +
+ -
-
-

FidoNet addresses are constructed in the format zone:net/node.point@domain.

+
+
+

This system can subscribe to the following echoareas:

+ @include('system.form-echoarea') +
+
+
-
- + +
+ -
-
-

FidoNet system are also assigned some roles, and in some cases, those roles have a particular address format:

-
- - - - - - +
+
+
+ +
+ @if(! $o->setup && ($x=\App\Models\Zone::active() + ->whereIn('id',$o->zones->pluck('id')) + ->whereNotIn('id',$o->sessions->pluck('id')) + ->get())->count()) -
- - - - - - - - - - - - - - - - - - - - - -
RoleAddress Format
Zone (optional) - ZONE:0/0.0, where the net, node and point values are zero. Zones normally have 1 or more Regions and/or Hosts.

- (Systems that do not configure other systems with a zone, assume that that other system is in the same zone as the system being configured.) -
Region (optional) - zone:REGION/0.0, where the zone indicates which zone the region is in. The node and point values are zero. Regions normally have 1 or more Hosts.

- Fidonet software normally doesnt configure the region address per-se. It is used by the mailer to receive packets destined to it by routing, in transition to the final destination. The region number must be unique with a zone. -
Host (mandatory) - zone:HOST/0.0, where the zone indicates which zone the host is in. The node and point values are zero. The Host system is normally configured with an additional address, where the NET address is the same and the NODE number that is greater than zero. Hosts may may zero or more Hubs and 1 or more Nodes.

- The host number must be unique within a zone, which implies that it cannot be the same as a region, if regions are used. -
Hub (optional) - zone:net/NODE.0, where the zone/net indicates which zone/net the hub is in. The system(s) in the nodelist below a Hub are fed from that hub from a routing perspective.

- The node is unique within the net and point is zero. -
Node (required) - zone:net/NODE.0, where the zone/net indicates which zone/net the node is in.

- The node is unique within the net and point is zero. -
+

This host's mail is sent to:

+ + + + + + + + + + @foreach($x as $zo) + @foreach ($o->match($zo) as $oo) + + + + + @endforeach + @endforeach + +
ZoneSystem
{{ $oo->ftn }} + @if ($x=$oo->parent()) + {{ $x->ftn4d }} + @else + No destination for mail. + @endif +
+ @endif +
+ + +
+

This host collects mail for the following systems:

+ + @if($o->sessions->count()) + + + + + + + + + + @foreach ($o->sessions->sortBy('zone_id') as $zo) + @foreach ($o->match($zo) as $oo) + + + + + @endforeach + @endforeach + +
ZoneSystem
{{ $oo->ftn }}{!! (($x=$oo->children) && $x->count()) ? $x->pluck('ftn4d')->join('
') : 'None' !!}
+ @else +

This host doesnt collect mail.

+ @endif
- - @if($o->addresses->count()) -

This system has the following addresses assigned to it:

- - - - - - - - - - - - @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) - - - - - - - @endforeach - -
AddressActiveRole
{{ $oo->ftn }}{{ $oo->active ? 'YES' : 'NO' }}{{ $oo->role_name }} - @can('admin',$oo) - - {{-- - @if (! $oo->role & (DC::NODE_ZC|DC::NODE_RC|DC::NODE_NC)) - - @endif - --}} - - - @endcan -
- @endif - - @can('admin',$o) - @include('system.form-address') - - @else - This system does not currently belong to any Fido networks. You'll need to ask an admin to assign addresses. - @endcan
- - - -
- - -
-
-
- -
- @if(! $o->setup && ($x=\App\Models\Zone::active() - ->whereIn('id',$o->zones->pluck('id')) - ->whereNotIn('id',$o->sessions->pluck('id')) - ->get())->count()) - -

This host's mail is sent to:

- - - - - - - - - - @foreach($x as $zo) - @foreach ($o->match($zo) as $oo) - - - - - @endforeach - @endforeach - -
ZoneSystem
{{ $oo->ftn }} - @if ($x=$oo->parent()) - {{ $x->ftn4d }} - @else - No destination for mail. - @endif -
- @endif -
- - -
-

This host collects mail for the following systems:

- - @if($o->sessions->count()) - - - - - - - - - - @foreach ($o->sessions->sortBy('zone_id') as $zo) - @foreach ($o->match($zo) as $oo) - - - - - @endforeach - @endforeach - -
ZoneSystem
{{ $oo->ftn }}{!! (($x=$oo->children) && $x->count()) ? $x->pluck('ftn4d')->join('
') : 'None' !!}
- @else -

This host doesnt collect mail.

- @endif -
-
-
-
-
+ @endif @else @include('system.form-system') @endif @@ -293,7 +305,7 @@ use App\Http\Controllers\DomainController as DC; icon = $(item).find('i'); $.ajax({ - type:'POST', + type: 'POST', data: {sid: {{$o->id}},_token: '{{csrf_token()}}',set:(icon.hasClass('bi-square') ? 1 : 0)}, beforeSend: function() { $(item).find('i').addClass('spinner-grow spinner-grow-sm'); diff --git a/resources/views/system/form-echoarea.blade.php b/resources/views/system/form-echoarea.blade.php new file mode 100644 index 0000000..e7a1740 --- /dev/null +++ b/resources/views/system/form-echoarea.blade.php @@ -0,0 +1,108 @@ +@if(($x=\App\Models\Domain::active() + ->select('domains.*') + ->join('zones',['zones.domain_id'=>'domains.id']) + ->whereIn('zone_id',$o->sessions->pluck('zone_id')) + ->get())->count()) + +
+ @csrf + +
+
+
+
+ +
+ +
+ + + + @error('domain_id') + {{ $message }} + @enderror + +
+
+ +
+ + + + + + + + + + @foreach ($o->echoareas()->with(['domain'])->get()->groupBy('domain_id') as $oo) + + + + + @endforeach + +
NetworkAreas
{{ $oo->first()->domain->name }}{{ $oo->count() }}
+
+
+ +
+
+
+
+
+
+
+@endif + +@section('page-scripts') + + + +@append \ No newline at end of file diff --git a/resources/views/system/widget/echoarea.blade.php b/resources/views/system/widget/echoarea.blade.php new file mode 100644 index 0000000..1bd5265 --- /dev/null +++ b/resources/views/system/widget/echoarea.blade.php @@ -0,0 +1,44 @@ +
+
+ + + + + + + + + + + @foreach ($echoareas as $oo) + + + + + + @endforeach + +
SubscribedEchoareaDescription
echoareas->search(function($item) use ($oo) { return $item->id == $oo->id; }) !== FALSE)checked @endif>{{ $oo->name }}{{ $oo->description }}
+
+
+ +
+
+ Cancel +
+ + + @if($errors->count()) + + There were errors with the submission. + @dump($errors) + + @endif + + + @can('admin',$o) +
+ +
+ @endcan +
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index d555c2e..e0c2369 100644 --- a/routes/web.php +++ b/routes/web.php @@ -65,6 +65,8 @@ Route::middleware(['verified','activeuser'])->group(function () { Route::get('ftn/system/delsession/{o}/{zo}',[SystemController::class,'del_session']) ->where('o','[0-9]+') ->where('zo','[0-9]+'); + Route::match(['get','post'],'ftn/system/echoarea/{o}',[SystemController::class,'echoareas']) + ->where('o','[0-9]+'); Route::match(['get','post'],'ftn/system/movaddress/{so}/{o}',[SystemController::class,'mov_address']) ->where('so','[0-9]+') ->where('o','[0-9]+');