From 7bb224fd6b5e921bb1e06a77d819bd4b9491425c Mon Sep 17 00:00:00 2001 From: Venkata Chandra Sekhar Nainala Date: Tue, 28 Nov 2023 13:48:14 +0100 Subject: [PATCH] feat: ux/ui improvements - missing files display and archiving logic updates --- app/Http/Controllers/DraftController.php | 16 ++++++++-- app/Jobs/ProcessFiles.php | 18 +++++++++++ resources/js/Pages/Project/Index.vue | 6 +++- resources/js/Pages/Upload.vue | 2 +- resources/js/Shared/FileSystemBrowser.vue | 39 +++++++++++++++++++++-- routes/web.php | 2 ++ 6 files changed, 77 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/DraftController.php b/app/Http/Controllers/DraftController.php index b2751f00..49f142ba 100644 --- a/app/Http/Controllers/DraftController.php +++ b/app/Http/Controllers/DraftController.php @@ -96,12 +96,24 @@ public function files(Request $request, Draft $draft) ->orderBy('type') ->get(), ], - 'missing_files' => FileSystemObject::with('children') + 'missing_files' => FileSystemObject::where([ + ['draft_id', $draft->id], + ['status', 'missing'], + ]) + ->count(), + ]); + } + + public function missingFiles(Request $request, Draft $draft) + { + return response()->json( + [ + 'missing_files' => FileSystemObject::select('relative_url') ->where([ ['draft_id', $draft->id], ['status', 'missing'], ]) - ->count(), + ->get(), ]); } diff --git a/app/Jobs/ProcessFiles.php b/app/Jobs/ProcessFiles.php index 7a40d48d..e21cc654 100644 --- a/app/Jobs/ProcessFiles.php +++ b/app/Jobs/ProcessFiles.php @@ -4,6 +4,7 @@ use App\Models\Draft; use App\Models\FileSystemObject; +use App\Models\Project; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -58,18 +59,35 @@ public function handle(): void ->orWhere('status', 'missing') ->get(); + $missingFileAdded = false; foreach ($draftFSObjects as $fsObject) { if ($fsObject->path) { + $missingFile = false; + if ($fsObject->status == 'missing') { + $missingFile = true; + } $exists = Storage::disk(env('FILESYSTEM_DRIVER'))->exists($fsObject->path); if (! $exists) { $fsObject->status = 'missing'; } else { $fsObject->status = 'present'; + if ($missingFile) { + $missingFileAdded = true; + } } $fsObject->save(); } } + if ($missingFileAdded) { + $project = Project::where('draft_id', $draft->id)->first(); + foreach ($project->studies as $study) { + $study->download_url = null; + $study->save(); + } + ArchiveStudy::dispatch($project); + } + // $this->processFiles($draft->path); }); diff --git a/resources/js/Pages/Project/Index.vue b/resources/js/Pages/Project/Index.vue index 65936ea4..bfb06244 100644 --- a/resources/js/Pages/Project/Index.vue +++ b/resources/js/Pages/Project/Index.vue @@ -352,8 +352,12 @@ export default { this.emitter.emit("openProjectCreateDialog", data); }, getLink(project) { - if (project) { + if (!project.is_public) { return router.visit("upload?draft_id=" + project.draft_id); + } else { + return router.visit( + this.route("dashboard.projects", [project.id]) + ); } }, }, diff --git a/resources/js/Pages/Upload.vue b/resources/js/Pages/Upload.vue index a884597c..ca35a1ba 100644 --- a/resources/js/Pages/Upload.vue +++ b/resources/js/Pages/Upload.vue @@ -3242,4 +3242,4 @@ export default { }, }, }; - \ No newline at end of file + diff --git a/resources/js/Shared/FileSystemBrowser.vue b/resources/js/Shared/FileSystemBrowser.vue index 7edf5129..96f71c45 100644 --- a/resources/js/Shared/FileSystemBrowser.vue +++ b/resources/js/Shared/FileSystemBrowser.vue @@ -30,7 +30,8 @@ - @@ -47,7 +48,7 @@ > {{ missing_files }} files missing - +