Skip to content

Commit

Permalink
feat: ux/ui improvements - missing files display and archiving logic …
Browse files Browse the repository at this point in the history
…updates
  • Loading branch information
CS76 committed Nov 28, 2023
1 parent 5028bc7 commit 7bb224f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 6 deletions.
16 changes: 14 additions & 2 deletions app/Http/Controllers/DraftController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
}

Expand Down
18 changes: 18 additions & 0 deletions app/Jobs/ProcessFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});

Expand Down
6 changes: 5 additions & 1 deletion resources/js/Pages/Project/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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])
);
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3242,4 +3242,4 @@ export default {
},
},
};
</script>
</script>
39 changes: 37 additions & 2 deletions resources/js/Shared/FileSystemBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
</span>
</a>
</i>
<span
<a
@click="showMissingFilesDetailsModal()"
v-if="missing_files > 0"
class="text-red-900 text-strong float-right"
>
Expand All @@ -47,7 +48,7 @@
></path>
</svg>
{{ missing_files }} files missing
</span>
</a>
</div>
<!-- <button class="float-right" @click="toggleFullScreen">
<span v-if="fullScreen">
Expand Down Expand Up @@ -567,6 +568,26 @@
</jet-danger-button>
</template>
</jet-confirmation-modal>

<jet-confirmation-modal
:show="missing_files > 0 && showMissingFilesDetails"
@close="showMissingFilesDetails = null"
>
<template #title> Missing Files </template>

<template #content>
Following files are mising <br />
<span v-for="file in missing_files_list">
{{ file.relative_url }} <br />
</span>
</template>

<template #footer>
<jet-secondary-button @click="showMissingFilesDetails = null">
Cancel
</jet-secondary-button>
</template>
</jet-confirmation-modal>
</template>
<script>
import JetDialogModal from "@/Jetstream/DialogModal.vue";
Expand Down Expand Up @@ -635,7 +656,9 @@ export default {
showLogsDialog: false,
currentLog: null,
fsoBeingDeleted: null,
showMissingFilesDetails: null,
missing_files: 0,
missing_files_list: [],
};
},
computed: {
Expand Down Expand Up @@ -680,6 +703,18 @@ export default {
});
}
},
showMissingFilesDetailsModal() {
this.fetchMissingFiles();
this.showMissingFilesDetails = true;
},
fetchMissingFiles() {
axios
.get("/dashboard/drafts/" + this.draft.id + "/missing-files")
.then((response) => {
console.log(response);
this.missing_files_list = response.data.missing_files;
});
},
toggleFullScreen() {
this.fullScreen = !this.fullScreen;
},
Expand Down
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@
->name('dashboard.draft.info');
Route::get('drafts/{draft}/files', [DraftController::class, 'files'])
->name('dashboard.draft.files');
Route::get('drafts/{draft}/missing-files', [DraftController::class, 'missingFiles'])
->name('dashboard.draft.missing-files');
Route::put('drafts/{draft}', [DraftController::class, 'update'])
->name('dashboard.draft.update');
Route::delete('drafts/{draft}/files/{filesystemobject}', [DraftController::class, 'deleteFSO'])
Expand Down

0 comments on commit 7bb224f

Please # to comment.