Added in network graph on about screen

This commit is contained in:
Deon George 2021-11-20 17:58:46 +11:00
parent 0be4ac0ad5
commit b333d38095
4 changed files with 105 additions and 8 deletions

View File

@ -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) {

View File

@ -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]
]
]);

View File

@ -7,6 +7,8 @@
<h2>About the FTN Clearing House</h2>
<p>Welcome to the FTN Clearing House.</p>
<div style="float:right; width: 50%; height: 20em;" id="network_traffic"></div>
<p>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.</p>
<p>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).</p>
@ -63,3 +65,66 @@ If you have more than 1 BBS, then the Clearing House can receive all your mail f
<p>This web UI has been inspired by the great work at <a href="https://int10h.org">int10h.org</a>. If you have ideas to make it even better, please send me a message, or submit your comments in <a href="https://dev.leenooks.net/bbs/clrghouz">gitlab</a></p>
<span class="float-end"><strong class="highlight">clrghouz</strong> <small>[<strong class="gray">{{ gethostname() }}</strong>@if (File::exists('../VERSION')) @ <strong class="success">{{ chop(File::get('../VERSION')) }}</strong>@endif]</small></span>
@endsection
@section('page-scripts')
@js('highcharts')
<script>
Highcharts.chart('network_traffic', {
chart: {
type: 'spline',
zoomType: 'x',
resetZoomButton: {
position: {
x: 0,
y: -40,
}
}
},
credits: {
enabled: false
},
exporting: {
buttons: false
},
title: {
text: 'FTN Network Traffic'
},
xAxis: {
type: 'datetime',
title: {
text: 'Time'
},
},
yAxis: {
title: {
text: 'Echomail'
},
},
legend: {
symbolWidth: 40
},
plotOptions: {
series: {
point: {
events: {
click: function () {
//window.location.href = this.series.options.website;
}
}
},
cursor: 'pointer'
}
},
series: [
@foreach (\App\Models\Domain::active()->public()->get() as $o)
{
name: '{{ $o->name }}',
data: {!! $o->daily_area_stats() !!},
dashStyle: 'ShortDot',
},
@endforeach
],
});
</script>
@append

View File

@ -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())