From 2790381a30d0f2d59a67887266e2aaaa22aecde3 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 4 Nov 2022 17:20:22 +1100 Subject: [PATCH] Determine if an inbound file is a nodelist --- app/Http/Controllers/FileareaController.php | 7 ++++ app/Jobs/TicProcess.php | 3 ++ app/Models/Domain.php | 5 +++ .../migrations/2022_11_03_115325_nodelist.php | 37 +++++++++++++++++++ resources/views/domain/addedit.blade.php | 24 ++++++++++++ resources/views/filearea/addedit.blade.php | 25 ++++++++++--- 6 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 database/migrations/2022_11_03_115325_nodelist.php diff --git a/app/Http/Controllers/FileareaController.php b/app/Http/Controllers/FileareaController.php index 44c273b..93d1a6d 100644 --- a/app/Http/Controllers/FileareaController.php +++ b/app/Http/Controllers/FileareaController.php @@ -26,6 +26,7 @@ class FileareaController extends Controller 'description' => 'required', 'active' => 'required|boolean', 'public' => 'required|boolean', + 'nodelist' => 'nullable|string|max:12' ]); foreach (['name','description','active','public','notes','domain_id'] as $key) @@ -33,6 +34,12 @@ class FileareaController extends Controller $o->save(); + if ($request->post('nodelist')) { + $o->domain->nodelist_filename = $request->post('nodelist'); + $o->domain->nodelist_filearea_id = $o->id; + $o->domain->save(); + } + return redirect()->action([self::class,'home']); } diff --git a/app/Jobs/TicProcess.php b/app/Jobs/TicProcess.php index 713dfc7..a406952 100644 --- a/app/Jobs/TicProcess.php +++ b/app/Jobs/TicProcess.php @@ -41,5 +41,8 @@ class TicProcess implements ShouldQueue Log::info(sprintf('%s:Processed [%s] storing [%s] as id [%d]',self::LOGKEY,$this->file,$to->fo->file,$to->fo->id)); unlink($this->file); + + if ($to->isNodelist()) + NodelistImport::dispatch($to->fo); } } \ No newline at end of file diff --git a/app/Models/Domain.php b/app/Models/Domain.php index f514802..1b3046d 100644 --- a/app/Models/Domain.php +++ b/app/Models/Domain.php @@ -44,6 +44,11 @@ class Domain extends Model return $this->hasMany(Filearea::class); } + public function nodelist_filearea() + { + return $this->belongsTo(Filearea::class); + } + public function zones() { return $this->hasMany(Zone::class); diff --git a/database/migrations/2022_11_03_115325_nodelist.php b/database/migrations/2022_11_03_115325_nodelist.php new file mode 100644 index 0000000..b797ec3 --- /dev/null +++ b/database/migrations/2022_11_03_115325_nodelist.php @@ -0,0 +1,37 @@ +string('nodelist_filename')->nullable(); + + $table->bigInteger('nodelist_filearea_id')->nullable(); + $table->foreign('nodelist_filearea_id')->references('id')->on('fileareas'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('domains', function (Blueprint $table) { + $table->dropForeign(['nodelist_filearea_id']); + + $table->dropColumn(['nodelist_filename','nodelist_filearea_id']); + }); + } +}; diff --git a/resources/views/domain/addedit.blade.php b/resources/views/domain/addedit.blade.php index 604eb71..ec4e3ea 100644 --- a/resources/views/domain/addedit.blade.php +++ b/resources/views/domain/addedit.blade.php @@ -41,6 +41,18 @@ + +
+ @if ($o->nodelist_filename) + +
+ + +
+ @else + No Nodelist filearea + @endif +
@@ -69,6 +81,18 @@
+ + @if ($o->nodelist_filename) +
+ + +
+ + +
+
+
+ @endif
diff --git a/resources/views/filearea/addedit.blade.php b/resources/views/filearea/addedit.blade.php index 9f42f0d..498948e 100644 --- a/resources/views/filearea/addedit.blade.php +++ b/resources/views/filearea/addedit.blade.php @@ -1,3 +1,4 @@ + @extends('layouts.app') @section('htmlheader_title') @@ -26,10 +27,10 @@ @error('domain_id') - {{ $message }} + {{ $message }} @else A domain is required. - @enderror + @enderror Add a NEW Domain
@@ -42,10 +43,10 @@ @error('name') - {{ $message }} + {{ $message }} @else A name is required. - @enderror + @enderror @@ -78,19 +79,31 @@
-
+
@error('description') - {{ $message }} + {{ $message }} @enderror
+
+ +
+ + domain)disabled @endcannot> + + @error('nodelist') + {{ $message }} + @enderror + +
+