From 13f89cf5158e394cb20d4a2938fa59c26a4e65b1 Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Sun, 11 Aug 2024 15:43:51 +0100 Subject: [PATCH] IRRDB last updated on member overview --- app/Models/Customer.php | 3 +- app/Models/IrrdbUpdateLog.php | 76 ++++++++++++++++++- public/css/ixp-pack.css | 15 +++- public/css/tailwind.css | 15 +++- public/mix-manifest.json | 4 +- .../customer/overview-tabs/overview.foil.php | 28 ++++++- 6 files changed, 129 insertions(+), 12 deletions(-) diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 5529319fb..6ef9fa173 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -921,7 +921,8 @@ public function irrdbFiltered(): bool { return (bool)self::leftJoin( 'virtualinterface AS vi', 'vi.custid', 'cust.id' ) ->leftJoin( 'vlaninterface AS vli', 'vli.virtualinterfaceid', 'vi.id' ) - ->where( 'cust.id', $this->id )->where( 'irrdbfilter', true ) + ->where( 'cust.id', $this->id )->where( 'rsclient', true ) + ->where( 'irrdbfilter', true ) ->get()->count(); } diff --git a/app/Models/IrrdbUpdateLog.php b/app/Models/IrrdbUpdateLog.php index 092a6fc84..f3cc6bfe0 100644 --- a/app/Models/IrrdbUpdateLog.php +++ b/app/Models/IrrdbUpdateLog.php @@ -2,6 +2,7 @@ namespace IXP\Models; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -12,10 +13,10 @@ * @method static \Illuminate\Database\Eloquent\Builder|IrrdbUpdateLog query() * @property int $id * @property int $cust_id - * @property string|null $prefix_v4 - * @property string|null $prefix_v6 - * @property string|null $asn_v4 - * @property string|null $asn_v6 + * @property \Illuminate\Support\Carbon|null $prefix_v4 + * @property \Illuminate\Support\Carbon|null $prefix_v6 + * @property \Illuminate\Support\Carbon|null $asn_v4 + * @property \Illuminate\Support\Carbon|null $asn_v6 * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @method static \Illuminate\Database\Eloquent\Builder|IrrdbUpdateLog whereAsnV4($value) @@ -44,4 +45,71 @@ class IrrdbUpdateLog extends Model 'asn_v6', ]; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'prefix_v4' => 'datetime', + 'prefix_v6' => 'datetime', + 'asn_v4' => 'datetime', + 'asn_v6' => 'datetime', + ]; + } + + /** + * Find the /oldest/ /relevant/ last update: + * + * - oldest: will be null if never updated + * - relevant: if customer is not v6 enabled, ignore these fields + * + * @param Customer $c + * @return Carbon + */ + public static function lastUpdatedMax( Customer $c ): ?Carbon + { + /** @var IrrdbUpdateLog $log */ + $log = self::firstWhere('cust_id', $c->id); + + if( !$log || !$c->irrdbFiltered() ) { + return null; + } + + $oldest = null; + + if( $c->isIPvXEnabled(4) ) { + if( !$oldest && $log->prefix_v4 ) { + $oldest = $log->prefix_v4; + } else if( $oldest && $oldest > $log->prefix_v4 ) { + $oldest = $log->prefix_v4; + } + + if( !$oldest && $log->asn_v4 ) { + $oldest = $log->asn_v4; + } else if( $oldest && $oldest > $log->asn_v4 ) { + $oldest = $log->asn_v4; + } + } + + if( $c->isIPvXEnabled(6) ) { + if( !$oldest && $log->prefix_v6 ) { + $oldest = $log->prefix_v6; + } else if( $oldest && $oldest > $log->prefix_v6 ) { + $oldest = $log->prefix_v6; + } + + if( !$oldest && $log->asn_v6 ) { + $oldest = $log->asn_v6; + } else if( $oldest && $oldest > $log->asn_v6 ) { + $oldest = $log->asn_v6; + } + } + + return $oldest; + } + } diff --git a/public/css/ixp-pack.css b/public/css/ixp-pack.css index 217769e12..a744a934e 100644 --- a/public/css/ixp-pack.css +++ b/public/css/ixp-pack.css @@ -3308,7 +3308,7 @@ td a:hover{ * * @import "tailwindcss/preflight"; */ -/*! tailwindcss v3.4.7 | MIT License | https://tailwindcss.com +/*! tailwindcss v3.4.9 | MIT License | https://tailwindcss.com */ /* 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) @@ -4417,6 +4417,9 @@ a:hover { .tw-flex { display: flex; } +.tw-inline-flex { + display: inline-flex; +} .tw-hidden { display: none; } @@ -4606,6 +4609,10 @@ a:hover { padding-left: 2.5rem; padding-right: 2.5rem; } +.tw-px-2 { + padding-left: 0.5rem; + padding-right: 0.5rem; +} .tw-px-3 { padding-left: 0.75rem; padding-right: 0.75rem; @@ -4706,6 +4713,9 @@ a:hover { .tw-font-bold { font-weight: 700; } +.tw-font-medium { + font-weight: 500; +} .tw-font-normal { font-weight: 400; } @@ -4814,6 +4824,9 @@ a:hover { --tw-shadow-colored: 0 4px 8px 0 var(--tw-shadow-color), 0 2px 4px 0 var(--tw-shadow-color); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); } +.tw-ring-yellow-600\/20 { + --tw-ring-color: rgb(214 158 46 / 0.2); +} .\[a-f0-9\:\\\.\\-\] { a-f0-9: \.\-; } diff --git a/public/css/tailwind.css b/public/css/tailwind.css index 2e89749bd..740f213eb 100644 --- a/public/css/tailwind.css +++ b/public/css/tailwind.css @@ -9,7 +9,7 @@ * * @import "tailwindcss/preflight"; */ -/*! tailwindcss v3.4.7 | MIT License | https://tailwindcss.com +/*! tailwindcss v3.4.9 | MIT License | https://tailwindcss.com */ /* 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) @@ -1118,6 +1118,9 @@ a:hover { .tw-flex { display: flex; } +.tw-inline-flex { + display: inline-flex; +} .tw-hidden { display: none; } @@ -1307,6 +1310,10 @@ a:hover { padding-left: 2.5rem; padding-right: 2.5rem; } +.tw-px-2 { + padding-left: 0.5rem; + padding-right: 0.5rem; +} .tw-px-3 { padding-left: 0.75rem; padding-right: 0.75rem; @@ -1407,6 +1414,9 @@ a:hover { .tw-font-bold { font-weight: 700; } +.tw-font-medium { + font-weight: 500; +} .tw-font-normal { font-weight: 400; } @@ -1515,6 +1525,9 @@ a:hover { --tw-shadow-colored: 0 4px 8px 0 var(--tw-shadow-color), 0 2px 4px 0 var(--tw-shadow-color); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); } +.tw-ring-yellow-600\/20 { + --tw-ring-color: rgb(214 158 46 / 0.2); +} .\[a-f0-9\:\\\.\\-\] { a-f0-9: \.\-; } diff --git a/public/mix-manifest.json b/public/mix-manifest.json index fba5cb979..6f6fc593b 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,7 +1,7 @@ { - "/css/tailwind.css": "/css/tailwind.css?id=36c5dc0854a90855bacbdf77cb4d91fb", + "/css/tailwind.css": "/css/tailwind.css?id=869de96c060a52baebfdf0a41c343ea9", "/js/ixp-pack.js": "/js/ixp-pack.js?id=ec1db54aba350f56e45c1c8297dd62d7", - "/css/ixp-pack.css": "/css/ixp-pack.css?id=27c9999fbdb5d8e52ad36e151eb8a2e8", + "/css/ixp-pack.css": "/css/ixp-pack.css?id=2e976369d67ec2c99b81e9c105b4e740", "/fonts/FontAwesome.otf": "/fonts/FontAwesome.otf?id=663236d7aa447620b641032d1b7be57c", "/fonts/fontawesome-webfont.eot": "/fonts/fontawesome-webfont.eot?id=016fa45033a942ffecadc970f22fe41b", "/fonts/fontawesome-webfont.svg": "/fonts/fontawesome-webfont.svg?id=912ec66d7572ff821749319396470bde", diff --git a/resources/views/customer/overview-tabs/overview.foil.php b/resources/views/customer/overview-tabs/overview.foil.php index ac6864d62..fa34d8219 100644 --- a/resources/views/customer/overview-tabs/overview.foil.php +++ b/resources/views/customer/overview-tabs/overview.foil.php @@ -1,5 +1,8 @@ c; /** @var \IXP\Models\Customer $c */ + +use IXP\Models\IrrdbUpdateLog; + +$c = $t->c; /** @var \IXP\Models\Customer $c */ ?>
@@ -94,11 +97,30 @@ IRRDB - irrdbConfig ): ?> + irrdbFiltered() && $irrdb = $c->irrdbConfig ): ?> ee( $irrdb->source )?> routeServerClient() && $c->irrdbFiltered() ): ?> - ( $c->id, "type" => 'prefix', "protocol" => $c->isIPvXEnabled( 4) ? 4 : 6 ] ) ?>">entries) + ( $c->id, "type" => 'prefix', "protocol" => $c->isIPvXEnabled( 4) ? 4 : 6 ] ) ?>">entries)
+ + isBefore( now()->subDay() ) ) { + $lastUpdatedWarn = true; + } + $lastUpdated = $lastUpdated->format('Y-m-d H:i'); + } else { + $lastUpdatedWarn = true; + $lastUpdated = 'NEVER'; + } + ?> + Last updated: + ' : '' ?> + + ' : '' ?> + + (no IRRDB filtering)