Web frontend work
This commit is contained in:
39
app/Http/Controllers/DomainController.php
Normal file
39
app/Http/Controllers/DomainController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Domain;
|
||||
|
||||
class DomainController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
46
app/Http/Controllers/NodeController.php
Normal file
46
app/Http/Controllers/NodeController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Node;
|
||||
|
||||
class NodeController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
39
app/Http/Controllers/ZoneController.php
Normal file
39
app/Http/Controllers/ZoneController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\Zone;
|
||||
|
||||
class ZoneController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->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');
|
||||
}
|
||||
}
|
12
app/Models/Domain.php
Normal file
12
app/Models/Domain.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\ScopeActive;
|
||||
|
||||
class Domain extends Model
|
||||
{
|
||||
use ScopeActive;
|
||||
}
|
@@ -6,18 +6,64 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Node extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'is_zc'=>'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()})
|
||||
|
9
app/Models/Protocol.php
Normal file
9
app/Models/Protocol.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Protocol extends Model
|
||||
{
|
||||
}
|
9
app/Models/Software.php
Normal file
9
app/Models/Software.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Software extends Model
|
||||
{
|
||||
}
|
@@ -10,6 +10,13 @@ class Zone extends Model
|
||||
{
|
||||
use ScopeActive;
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function domain()
|
||||
{
|
||||
return $this->belongsTo(Domain::class);
|
||||
}
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user