Added echomail search and display
This commit is contained in:
parent
12f9ee1960
commit
271f066667
19
app/Http/Controllers/EchomailController.php
Normal file
19
app/Http/Controllers/EchomailController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Echomail;
|
||||
|
||||
class EchomailController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function view(Echomail $o)
|
||||
{
|
||||
return view('echomail.view')
|
||||
->with('o',$o);
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
use App\Classes\FTN\Packet;
|
||||
use App\Models\{Address,Domain,Setup};
|
||||
use App\Models\{Address,Domain,Echomail,Setup};
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@ -86,7 +86,7 @@ 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
|
||||
# Look for Systems
|
||||
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'])
|
||||
->rightjoin('systems',['systems.id'=>'addresses.system_id'])
|
||||
@ -113,6 +113,14 @@ class HomeController extends Controller
|
||||
$result->push(['id'=>$o->system_id,'name'=>$o->name.($ftn ? ' '.$ftn : ''),'value'=>url('ftn/system/addedit',[$o->system_id]),'category'=>'Systems']);
|
||||
}
|
||||
|
||||
# Look for Messages
|
||||
foreach (Echomail::select(['id','fftn_id','from'])
|
||||
->where('msgid','like','%'.$request->query('term').'%')
|
||||
->get() as $o)
|
||||
{
|
||||
$result->push(['id'=>$o->id,'name'=>sprintf('%s (%s)',$o->from,$o->fftn->ftn3d),'value'=>url('echomail/view',[$o->id]),'category'=>'Echomail']);
|
||||
}
|
||||
|
||||
return $result->unique(['id'])->take(10)->values();
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,11 @@ class Address extends Model
|
||||
return sprintf('%s@%s',$this->getFTN4DAttribute(),$this->zone->domain->name);
|
||||
}
|
||||
|
||||
public function getFTN2DAttribute(): string
|
||||
{
|
||||
return sprintf('%d/%d',$this->host_id ?: $this->region_id,$this->node_id);
|
||||
}
|
||||
|
||||
public function getFTN3DAttribute(): string
|
||||
{
|
||||
return sprintf('%d:%d/%d',$this->zone->zone_id,$this->host_id ?: $this->region_id,$this->node_id);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Jenssegers\Mongodb\Eloquent\Model;
|
||||
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
|
||||
|
||||
@ -32,6 +33,18 @@ class Echomail extends Model implements Packet
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
public function getPathAttribute($value): Collection
|
||||
{
|
||||
return Address::whereIn('id',$value)->get()->pluck('ftn3d');
|
||||
}
|
||||
|
||||
public function getSeenByAttribute($value): Collection
|
||||
{
|
||||
return Address::whereIn('id',$value)->get()->pluck('ftn2d');
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
public function jsonSerialize(): array
|
||||
|
7
resources/views/echomail/view.blade.php
Normal file
7
resources/views/echomail/view.blade.php
Normal file
@ -0,0 +1,7 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<h3>Echomail</h3>
|
||||
|
||||
@include('widgets.message',['msg'=>$o])
|
||||
@endsection
|
43
resources/views/widgets/message.blade.php
Normal file
43
resources/views/widgets/message.blade.php
Normal file
@ -0,0 +1,43 @@
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
DATE: <strong class="highlight">{{ $msg->datetime->format('Y-m-d H:i:s') }}</strong>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
MSGID: <strong class="highlight">{{ $msg->msgid }}</strong>@if($x=\App\Models\Echomail::where('reply',$msg->msgid)->count()) (<strong class="highlight">{{$x}}</strong> replies)@endif @if($msg->reply)<br>REPLY: <strong class="highlight">{{ $msg->reply }}</strong>@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-4">
|
||||
FROM: <strong class="highlight">{{ $msg->from }}</strong> (<strong class="highlight">{{ $msg->fftn->ftn }}</strong>)
|
||||
</div>
|
||||
<div class="col-4">
|
||||
TO: <strong class="highlight">{{ $msg->to }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-8">
|
||||
SUBJECT: <strong class="highlight">{!! \App\Classes\FTN\Message::tr($msg->subject) !!}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-8">
|
||||
<div class="pad pb-0">
|
||||
<pre class="highlight">{!! \App\Classes\FTN\Message::tr($msg->msg).($msg->origin ? sprintf("\r * Origin: %s",$msg->origin) : '') !!}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-8">
|
||||
SEENBY: <br><strong class="highlight">{!! $msg->seenby->join('</strong>, <strong class="highlight">') !!}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-8">
|
||||
PATH: <br><strong class="highlight">{!! $msg->path->join('</strong> -> <strong class="highlight">') !!}</strong>
|
||||
</div>
|
||||
</div>
|
@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\{HomeController,
|
||||
DomainController,
|
||||
EchoareaController,
|
||||
EchomailController,
|
||||
FileareaController,
|
||||
SystemController,
|
||||
UserController,
|
||||
@ -83,6 +84,7 @@ Route::get('search',[HomeController::class,'search']);
|
||||
Route::middleware(['auth','can:admin'])->group(function () {
|
||||
Route::match(['get','post'],'setup',[HomeController::class,'setup']);
|
||||
|
||||
Route::get('echomail/view/{o}',[EchomailController::class,'view']);
|
||||
Route::get('user/list',[UserController::class,'home']);
|
||||
Route::match(['get','post'],'user/addedit/{o?}',[UserController::class,'add_edit'])
|
||||
->where('o','[0-9]+');
|
||||
|
Loading…
Reference in New Issue
Block a user