diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php new file mode 100644 index 0000000..f24315d --- /dev/null +++ b/app/Http/Controllers/DomainController.php @@ -0,0 +1,39 @@ +middleware('auth'); + } + + /** + * Add or edit a node + */ + public function add_edit(Request $request,Domain $o) + { + if ($request->post()) { + foreach (['name','dnsdomain','active','notes'] as $key) + $o->{$key} = $request->post($key); + + $o->active = TRUE; + $o->save(); + + return redirect()->action([self::class,'home']); + } + + return view('domain.addedit') + ->with('o',$o); + } + + public function home() + { + return view('domain.home'); + } +} diff --git a/app/Http/Controllers/NodeController.php b/app/Http/Controllers/NodeController.php new file mode 100644 index 0000000..f6dcda5 --- /dev/null +++ b/app/Http/Controllers/NodeController.php @@ -0,0 +1,46 @@ +middleware('auth'); + } + + /** + * Add or edit a node + */ + public function add_edit(Request $request,Node $o) + { + if ($request->post()) { + foreach ([ + 'zone_id','host_id','node_id','point_id', + 'system','sysop','location','email', + 'address','port','notes','software_id','protocol_id', + 'sespass','pktpass','ticpass','fixpass' + ] as $key) + $o->{$key} = $request->post($key); + + foreach(['is_zc','is_rc','is_hub','is_host','active'] as $key) + $o->{$key} = $request->post($key,FALSE); + + $o->save(); + + return redirect()->action([self::class,'home']); + } + + return view('node.addedit') + ->with('o',$o); + } + + public function home() + { + return view('node.home'); + } +} diff --git a/app/Http/Controllers/ZoneController.php b/app/Http/Controllers/ZoneController.php new file mode 100644 index 0000000..617fe50 --- /dev/null +++ b/app/Http/Controllers/ZoneController.php @@ -0,0 +1,39 @@ +middleware('auth'); + } + + /** + * Add or edit a node + */ + public function add_edit(Request $request,Zone $o) + { + if ($request->post()) { + foreach (['zone_id','name','active','description','notes','domain_id'] as $key) + $o->{$key} = $request->post($key); + + $o->active = TRUE; + $o->save(); + + return redirect()->action([self::class,'home']); + } + + return view('zone.addedit') + ->with('o',$o); + } + + public function home() + { + return view('zone.home'); + } +} diff --git a/app/Models/Domain.php b/app/Models/Domain.php new file mode 100644 index 0000000..b3a8371 --- /dev/null +++ b/app/Models/Domain.php @@ -0,0 +1,12 @@ +'boolean', + 'is_rc'=>'boolean', + 'is_hub'=>'boolean', + 'is_host'=>'boolean', + ]; protected $fillable = ['zone_id','host_id','node_id','point_id']; - public function flags() { + /* SCOPES */ + + public function scopeHost() + { + + } + + /* RELATIONS */ + + /** + * Node nodelist flags + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function flags() + { return $this->belongsToMany(Flag::class); } - public function getFTNAttribute() + public function zone() { - return sprintf('%s:%s/%s.%s',$this->zone_id,$this->host_id,$this->node_id,$this->point_id); + return $this->belongsTo(Zone::class); } - public function hasFlag($relation, $model) + /* ATTRIBUTES */ + + /** + * Render the node name in full 5D + * + * @return string + */ + public function getFTNAttribute() + { + return $this->zone_id + ? sprintf('%s:%s/%s.%s',$this->zone->zone_id,$this->host_id,$this->node_id,$this->point_id) + : '-'; + } + + /** + * Get this nodes uplink + */ + public function getUplinkAttribute() + { + // @todo Need to work this out properly + return static::where('zone_id','10')->where('host_id',1)->where('node_id',0)->where('point_id',0)->first(); + } + + /* METHODS */ + + public function hasFlag($relation,$model) { return (bool) $this->{$relation}() ->wherePivot($model->getForeignKey(),$model->{$model->getKeyName()}) diff --git a/app/Models/Protocol.php b/app/Models/Protocol.php new file mode 100644 index 0000000..de8dd69 --- /dev/null +++ b/app/Models/Protocol.php @@ -0,0 +1,9 @@ +belongsTo(Domain::class); + } + /* SCOPES */ /** diff --git a/database/migrations/2019_04_16_090345_create_domains.php b/database/migrations/2019_04_16_090345_create_domains.php index f62166d..e5dccee 100644 --- a/database/migrations/2019_04_16_090345_create_domains.php +++ b/database/migrations/2019_04_16_090345_create_domains.php @@ -18,6 +18,8 @@ class CreateDomains extends Migration $table->timestamps(); $table->string('name',8)->unique(); $table->string('dnsdomain')->nullable(); + $table->string('notes')->nullable(); + $table->boolean('active'); }); } diff --git a/database/migrations/2019_04_16_105253_create_zones.php b/database/migrations/2019_04_16_105253_create_zones.php index 2e29215..81a6a92 100644 --- a/database/migrations/2019_04_16_105253_create_zones.php +++ b/database/migrations/2019_04_16_105253_create_zones.php @@ -14,12 +14,13 @@ class CreateZones extends Migration public function up() { Schema::create('zones', function (Blueprint $table) { - $table->integer('id')->primary(); + $table->id(); $table->timestamps(); $table->integer('zone_id'); $table->string('description')->nullable(); - $table->boolean('active')->default(TRUE); + $table->boolean('active'); + $table->string('notes')->nullable(); $table->boolean('public')->default(TRUE); $table->ipAddress('ipv4')->nullable(); @@ -33,6 +34,8 @@ class CreateZones extends Migration $table->binary('zt_id',10)->nullable()->unique(); $table->foreign('zt_id')->references('id')->on('zt'); + + $table->unique(['zone_id','domain_id']); }); } diff --git a/database/migrations/2019_04_16_105254_create_nodes.php b/database/migrations/2019_04_16_105254_create_nodes.php index 82b1c50..97055eb 100644 --- a/database/migrations/2019_04_16_105254_create_nodes.php +++ b/database/migrations/2019_04_16_105254_create_nodes.php @@ -13,14 +13,32 @@ class CreateNodes extends Migration */ public function up() { + Schema::create('protocols', function (Blueprint $table) { + $table->increments('id'); + $table->timestamps(); + $table->string('name'); + $table->integer('port')->nullable(); + $table->boolean('active'); + }); + + Schema::create('software', function (Blueprint $table) { + $table->increments('id'); + $table->timestamps(); + $table->string('name'); + $table->boolean('active'); + }); + Schema::create('nodes', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); - $table->integer('zone_id')->index(); + + $table->integer('zone_id')->nullable()->index(); + $table->foreign('zone_id')->references('id')->on('zones'); + $table->integer('region_id')->nullable(); - $table->integer('host_id')->index(); + $table->integer('host_id')->nullable()->index(); $table->integer('hub_id')->nullable()->index(); - $table->integer('node_id')->index(); + $table->integer('node_id')->nullable()->index(); $table->integer('point_id')->default(0); $table->boolean('active'); @@ -28,15 +46,34 @@ class CreateNodes extends Migration $table->string('system'); $table->string('sysop'); $table->string('location'); - $table->integer('baud')->default('0'); + $table->string('email')->nullable(); + $table->string('address')->nullable(); + $table->integer('port')->nullable(); + $table->integer('baud')->nullable(); $table->string('phone')->nullable(); + $table->string('notes')->nullable(); - $table->binary('zt',10)->nullable(); + $table->boolean('is_zc')->default(FALSE); + $table->boolean('is_rc')->default(FALSE); + $table->boolean('is_hub')->default(FALSE); + $table->boolean('is_host')->default(FALSE); + + $table->string('sespass')->nullable(); + $table->string('pktpass',8)->nullable(); + $table->string('ticpass')->nullable(); + $table->string('fixpass')->nullable(); + + $table->string('zt',10)->nullable(); $table->unique(['zone_id','host_id','node_id','point_id']); $table->unique(['zone_id','zt']); - $table->foreign('zone_id')->references('id')->on('zones'); + + $table->integer('protocol_id')->nullable(); + $table->foreign('protocol_id')->references('id')->on('protocols'); + $table->integer('software_id')->nullable(); + $table->foreign('software_id')->references('id')->on('software'); + // $table->unique(['zone_id','host_id','id']); // $table->index(['zone_id','host_id']); @@ -54,5 +91,7 @@ class CreateNodes extends Migration public function down() { Schema::dropIfExists('nodes'); + Schema::dropIfExists('protocols'); + Schema::dropIfExists('software'); } } diff --git a/database/seeds/InitialSetupSeeder.php b/database/seeds/InitialSetupSeeder.php index d4c809a..c8e489f 100644 --- a/database/seeds/InitialSetupSeeder.php +++ b/database/seeds/InitialSetupSeeder.php @@ -30,7 +30,8 @@ class InitialSetupSeeder extends Seeder ]); DB::table('domains')->insert([ - 'name' => 'private', + 'name'=>'private', + 'active'=>TRUE, ]); DB::table('zones')->insert([ @@ -62,8 +63,9 @@ class InitialSetupSeeder extends Seeder 'opt_md'=>'1', ]); - DB::table('setup')->insert([ - 'node_id' => '1', + DB::table('node_setup')->insert([ + 'node_id'=>'1', + 'setup_id'=>'1', ]); } } diff --git a/resources/views/domain/addedit.blade.php b/resources/views/domain/addedit.blade.php new file mode 100644 index 0000000..b5335a1 --- /dev/null +++ b/resources/views/domain/addedit.blade.php @@ -0,0 +1,58 @@ +@extends('layouts.app') + +@section('htmlheader_title') + @if($o->exists) Update @else Add @endif Domain +@endsection + +@section('main-content') +
+

@if($o->exists) Update @else Add @endif Domain

+ +
+ {{ csrf_field() }} + +
+
+
+
+ + +
+ +
+ + +
+ +
+ +
+
+ active)checked @endif> + +
+ +
+ active)checked @endif> + +
+
+
+ +
+ + +
+ +
+
+ + Cancel +
+
+
+
+
+
+
+@endsection diff --git a/resources/views/domain/home.blade.php b/resources/views/domain/home.blade.php new file mode 100644 index 0000000..826feed --- /dev/null +++ b/resources/views/domain/home.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('main-content') +
+
+ + + + + + + + + + + + + + + @foreach (\App\Models\Domain::cursor() as $oo) + + + + + + + @endforeach + +
IDActiveDomainDNS domain
Add New Domain
{{ $oo->id }}{{ $oo->active ? 'YES' : 'NO' }}{{ $oo->name }}{{ $oo->dnsdomain }}
+
+
+@endsection + +@section('page-scripts') + +@append diff --git a/resources/views/layouts/partials/topmenu.blade.php b/resources/views/layouts/partials/topmenu.blade.php index b006cc3..709ce77 100644 --- a/resources/views/layouts/partials/topmenu.blade.php +++ b/resources/views/layouts/partials/topmenu.blade.php @@ -22,9 +22,9 @@ @endauth diff --git a/resources/views/node/addedit.blade.php b/resources/views/node/addedit.blade.php new file mode 100644 index 0000000..8ff6906 --- /dev/null +++ b/resources/views/node/addedit.blade.php @@ -0,0 +1,166 @@ +@extends('layouts.app') + +@section('htmlheader_title') + @if($o->exists) Update @else Add @endif Node +@endsection + +@section('main-content') +
+

@if($o->exists) Update @else Add @endif Node

+
+ {{ csrf_field() }} + +
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ + is_rc)checked @endif> +
+
+ + is_regis_rcion)checked @endif> +
+
+ + is_hub)checked @endif> +
+
+ + is_host)checked @endif> +
+ +
+ + active)checked @endif> +
+
+
+ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ @foreach (\App\Models\Protocol::cursor() as $oo) +
+ protocol_id==$oo->id)checked @endif> + +
+ @endforeach +
+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ + +
+ +
+
+ + Cancel +
+
+
+
+
+
+
+@endsection diff --git a/resources/views/node/home.blade.php b/resources/views/node/home.blade.php new file mode 100644 index 0000000..86fa303 --- /dev/null +++ b/resources/views/node/home.blade.php @@ -0,0 +1,49 @@ +@extends('layouts.app') + +@section('main-content') +
+
+ + + + + + + + + + + + + + + + + @foreach (\App\Models\Node::with(['zone'])->cursor() as $oo) + + + + + + + + + @endforeach + +
IDDomainNodeActiveSystemSysop
Add New Node
{{ $oo->id }}@if ($oo->zone_id){{ $oo->zone->name }}@else - @endif{{ $oo->ftn }}{{ $oo->active ? 'YES' : 'NO' }}{{ $oo->system }}{{ $oo->sysop }}
+
+
+@endsection + +@section('page-scripts') + +@append diff --git a/resources/views/zone/addedit.blade.php b/resources/views/zone/addedit.blade.php new file mode 100644 index 0000000..edd742a --- /dev/null +++ b/resources/views/zone/addedit.blade.php @@ -0,0 +1,73 @@ +@extends('layouts.app') + +@section('htmlheader_title') + @if($o->exists) Update @else Add @endif Zone +@endsection + +@section('main-content') +
+

@if($o->exists) Update @else Add @endif Zone

+ +
+ {{ csrf_field() }} + +
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ active)checked @endif> + +
+ +
+ active)checked @endif> + +
+
+
+ +
+ + +
+ +
+
+ + Cancel +
+
+
+
+
+
+
+@endsection diff --git a/resources/views/zone/home.blade.php b/resources/views/zone/home.blade.php new file mode 100644 index 0000000..40df805 --- /dev/null +++ b/resources/views/zone/home.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('main-content') +
+
+ + + + + + + + + + + + + + + @foreach (\App\Models\Zone::cursor() as $oo) + + + + + + + @endforeach + +
IDActiveZoneDomain
Add New Zone
{{ $oo->zone_id }}{{ $oo->active ? 'YES' : 'NO' }}{{ $oo->name }}{{ $oo->domain->name }}
+
+
+@endsection + +@section('page-scripts') + +@append diff --git a/routes/web.php b/routes/web.php index 0dadffd..1b93dd0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,7 +3,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; -use App\Http\Controllers\HomeController; +use App\Http\Controllers\{HomeController,DomainController,NodeController,ZoneController}; use App\Http\Controllers\Auth\LoginController; /* @@ -28,6 +28,18 @@ Auth::routes([ Route::get('logout',[LoginController::class,'logout']); Route::get('/',[HomeController::class,'welcome']); -Route::get('network/{name}',[HomeController::class,'network']); +Route::get('home',[HomeController::class,'home']); -Route::get('home',[HomeController::class,'home']); \ No newline at end of file +Route::get('ftn/domain',[DomainController::class,'home']); +Route::match(['get','post'],'ftn/domain/addedit/{o?}',[DomainController::class,'add_edit']) + ->where('o','[0-9]+'); + +Route::get('ftn/node',[NodeController::class,'home']); +Route::match(['get','post'],'ftn/node/addedit/{o?}',[NodeController::class,'add_edit']) + ->where('o','[0-9]+'); + +Route::get('ftn/zone',[ZoneController::class,'home']); +Route::match(['get','post'],'ftn/zone/addedit/{o?}',[ZoneController::class,'add_edit']) + ->where('o','[0-9]+'); + +Route::get('ftn/network/{name}',[HomeController::class,'network']); \ No newline at end of file