From b333d38095e1e831cc58c9181c4481b7d67eecd5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 20 Nov 2021 17:58:46 +1100 Subject: [PATCH] Added in network graph on about screen --- app/Models/Domain.php | 18 +++++++- app/Traits/UseMongo.php | 15 ++++++- resources/views/about.blade.php | 67 ++++++++++++++++++++++++++++- resources/views/dashboard.blade.php | 13 ++++-- 4 files changed, 105 insertions(+), 8 deletions(-) diff --git a/app/Models/Domain.php b/app/Models/Domain.php index 746eb66..73e778c 100644 --- a/app/Models/Domain.php +++ b/app/Models/Domain.php @@ -2,6 +2,7 @@ namespace App\Models; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; @@ -53,6 +54,21 @@ class Domain extends Model /* METHODS */ + public function daily_area_stats(): Collection + { + if (! $this->echoareas->count()) + return collect(); + + $where = ['echoarea_id'=>$this->echoareas->pluck('id')->toArray()]; + + $echostats = Echomail::countGroupBy(['datetime',['datetime'=>'%Y-%m-%d']],$where); + + return $echostats + ->sortBy(function($item) { return $item->id->datetime; }) + ->map(function($item) { return ['x'=>Carbon::createFromFormat('Y-m-d',$item->id->datetime)->timestamp*1000,'y'=>$item->count]; }) + ->values(); + } + public function stats(System $o=NULL): Collection { if (! $this->echoareas->count()) @@ -63,7 +79,7 @@ class Domain extends Model if ($o) $where->put('fftn_id',$o->addresses()->pluck('id')); - $echostats = Echomail::countGroupBy('echoarea_id',$where->toArray()); + $echostats = Echomail::countGroupBy(['echoarea_id'],$where->toArray()); return $this->echoareas->map(function($item) use ($echostats) { $stats = $echostats->filter(function($x) use ($item) { diff --git a/app/Traits/UseMongo.php b/app/Traits/UseMongo.php index ca44bb7..51c7e61 100644 --- a/app/Traits/UseMongo.php +++ b/app/Traits/UseMongo.php @@ -45,7 +45,7 @@ trait UseMongo /* METHODS */ - public static function countGroupBy(string $field,array $where=[]): Collection + public static function countGroupBy(array $fields,array $where=[]): Collection { $query = collect(); @@ -64,9 +64,20 @@ trait UseMongo ]); } + $gb = collect(); + foreach ($fields as $field) + if (is_array($field)) { + foreach ($field as $k=>$v) { + $gb->put('datetime',['$dateToString'=>['format'=>$v,'date'=>'$'.$k]]); + } + + } else { + $gb->put($field,'$'.$field); + } + $query->push([ '$group' => [ - '_id' => [$field=>'$'.$field], + '_id' => $gb->toArray(), 'count' => ['$sum' => 1] ] ]); diff --git a/resources/views/about.blade.php b/resources/views/about.blade.php index 7c2fae6..d6be6cd 100644 --- a/resources/views/about.blade.php +++ b/resources/views/about.blade.php @@ -7,6 +7,8 @@

About the FTN Clearing House

Welcome to the FTN Clearing House.

+ +

The FTN Clearing House (FCH) is both a FTN Mailer and FTN message tosser, where mail is stored internally in a DB. FCH can also hatch and toss files into FTN networks for both up/downstream nodes.

It was created as an idea to bring modern technology and capabilities to a legacy computing network that existed in the 1970's, 1980's and 1990's (before the Internet basically).

@@ -62,4 +64,67 @@ If you have more than 1 BBS, then the Clearing House can receive all your mail f

FTN Clearing House is build with Open Source software. At it's core, PHP drives this web UI and the interaction with nodes.

This web UI has been inspired by the great work at int10h.org. If you have ideas to make it even better, please send me a message, or submit your comments in gitlab

clrghouz [{{ gethostname() }}@if (File::exists('../VERSION')) @ {{ chop(File::get('../VERSION')) }}@endif] -@endsection \ No newline at end of file +@endsection + +@section('page-scripts') + @js('highcharts') + + +@append \ No newline at end of file diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 1d04146..16ff935 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -106,6 +106,9 @@ credits: { enabled: false }, + exporting: { + buttons: false + }, title: { text: 'Echomail Statistics' }, @@ -147,10 +150,6 @@ series: { borderWidth: 0, grouping: false, - xdataLabels: { - enabled: false, - format: ''//'{point.y:.0f}' - } } }, tooltip: { @@ -190,6 +189,12 @@ }, ], drilldown: { + drillUpButton: { + position: { + x: 0, + y: -50, + } + }, series: [ @foreach($o->addresses->pluck('zone.domain')->sortBy('name') as $oo) @php($x = $oo->stats())