Skip to content

Commit

Permalink
fix: enabled nmredata detection and other minor ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Oct 19, 2023
1 parent ce52a43 commit bad18af
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 32 deletions.
78 changes: 55 additions & 23 deletions app/Http/Controllers/DraftController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ public function files(Request $request, Draft $draft)
]);
}

public function update(Request $request, Draft $draft)
{
$draft->name = $request->get('name');
$draft->save();

return $draft;
}

public function deleteFSO(Request $request, Draft $draft, FileSystemObject $filesystemobject)
{
$fsoIds = $this->getChildrenIds($filesystemobject, []);
Expand Down Expand Up @@ -131,7 +139,7 @@ public function complete(Request $request, Draft $draft)
// ProcessDraft::dispatch($draft);

return response()->json([
'project' => Project::with(['studies.datasets', 'owner'])->where('draft_id', $draft->id)->first(),
'project' => Project::with(['studies.datasets', 'owner', 'citations', 'authors'])->where('draft_id', $draft->id)->first(),
'validation' => $validation,
]);
}
Expand Down Expand Up @@ -246,7 +254,6 @@ public function process(Request $request, Draft $draft)
['draft_id', $draft->id],
['status', '<>', 'missing'],
['model_type', 'study'],
['is_processed', false],
])
->orderBy('type')
->get();
Expand Down Expand Up @@ -285,14 +292,13 @@ public function process(Request $request, Draft $draft)
$study->sample()->save($sample);

$folder->study_id = $study->id;
$folder->is_processed = true;
$folder->save();
}

$sChildren = $folder->children;

foreach ($sChildren as $sChild) {
if ($sChild->instrument_type != null) {
if ($sChild->instrument_type != null && $sChild->instrument_type != 'nmredata') {
// associate all children with the study_id, project_id, dataset_id
// create samples
// create assays
Expand Down Expand Up @@ -403,7 +409,7 @@ public function process(Request $request, Draft $draft)
}

return response()->json([
'project' => $project->load(['owner']),
'project' => $project->load(['owner', 'citations', 'authors']),
'studies' => $studies,
]);
});
Expand Down Expand Up @@ -438,31 +444,40 @@ public function processFolder($folders)
{
foreach ($folders as $folder) {
if ($folder->type == 'directory') {
if ($folder->instrument_type == null) {
if ($this->isBruker($folder)) {
$this->saveInstrumentType($folder, 'bruker');
$this->saveModelType($folder->parent);
} elseif ($this->isVarian($folder)) {
$this->saveInstrumentType($folder, 'varian');
$this->saveModelType($folder->parent);
} else {
$this->processFolder($folder->children);
}
if ($this->isBruker($folder)) {
$this->saveInstrumentType($folder, 'bruker');
$this->saveModelType($folder->parent);
} elseif ($this->isVarian($folder)) {
$this->saveInstrumentType($folder, 'varian');
$this->saveModelType($folder->parent);
} else {
$this->processFolder($folder->children);
}
} else {
if ($folder->instrument_type == null) {
if ($this->isJOEL($folder)) {
$this->saveInstrumentType($folder, 'joel');
$this->saveModelType($folder->parent);
} elseif ($this->isJcampDX($folder)) {
$this->saveInstrumentType($folder, 'jcamp');
$this->saveModelType($folder->parent);
}
if ($this->isJOEL($folder)) {
$this->saveInstrumentType($folder, 'joel');
$this->saveModelType($folder->parent);
} elseif ($this->isJcampDX($folder)) {
$this->saveInstrumentType($folder, 'jcamp');
$this->saveModelType($folder->parent);
} elseif ($this->isNMReData($folder)) {
$this->saveInstrumentType($folder, 'nmredata');
$this->saveAnnotationsDetected($folder->parent);
}
}
}
}

public function saveAnnotationsDetected($folder)
{
$study = $folder->study;

if ($study) {
$study->has_nmredata = true;
$study->save();
}
}

public function saveModelType($folder)
{
if ($folder) {
Expand Down Expand Up @@ -526,6 +541,23 @@ public function isJcampDX($folder)
return false;
}

public function isNMReData($folder)
{
$fileTypes = ['nmredata'];
$names = [$folder->name];
$extensions = array_map(fn ($s) => substr("$s", (strrpos($s, '.') + 1)), $names);
$isNMReData = false;
if (array_intersect($fileTypes, $extensions) == $fileTypes) {
$isNMReData = true;
}

if ($isNMReData) {
return true;
}

return false;
}

public function isJOEL($folder)
{
$fileTypes = ['jdf'];
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Shared/SpectraEditor.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div>
<div class="mb-2 float-right">
<!-- <div class="mb-2 float-right">
<small>
<a
class="text-xs cursor-pointer hover:text-blue-700 mr-2"
Expand All @@ -28,7 +28,7 @@
Preview</a
>
</small>
</div>
</div> -->
<small class="text-gray-400">
<span v-if="info">{{ info }}</span>
</small>
Expand Down
14 changes: 7 additions & 7 deletions resources/js/Shared/Submission.vue
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,18 @@
height: 80vh;
overflow: scroll !important;
"
class="flex-1 xl:overflow-y-auto p-2"
class="flex-1 xl:overflow-y-auto"
>
<div
class="mx-auto flex flex-col md:px-4 xl:px-0"
class="mx-auto flex flex-col md:px-0 xl:px-0"
>
<main class="flex-1">
<div
class="relative mx-auto md:px-4 xl:px-0"
class="relative mx-auto md:px-0 xl:px-0"
>
<div class="pt-5 pb-16">
<div
class="px-4 sm:px-6"
class="px-3 sm:px-3"
>
<h1
class="text-3xl font-extrabold text-gray-900"
Expand Down Expand Up @@ -636,7 +636,7 @@
</select>
</div>
<div
class="hidden lg:block px-4 sm:px-6"
class="hidden lg:block px-3 sm:px-3"
>
<div
class="border-b border-gray-200"
Expand Down Expand Up @@ -816,7 +816,7 @@
class="px-4 sm:px-6 md:px-0"
>
<div
class="p-6"
class="p-3"
>
<!-- <div>
<label
Expand Down Expand Up @@ -867,7 +867,7 @@
</select>
</div> -->
<div
class="my-7"
class="my-3"
>
<SpectraEditor
:dataset="
Expand Down

0 comments on commit bad18af

Please sign in to comment.