Skip to content

Commit

Permalink
Merge pull request #887 from NFDI4Chem/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NishaSharma14 authored Nov 13, 2023
2 parents 4236d59 + bb6da86 commit 89eddbc
Show file tree
Hide file tree
Showing 17 changed files with 234 additions and 146 deletions.
4 changes: 2 additions & 2 deletions app/Console/Commands/ArchiveData.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function handle()
])->get();

foreach ($projects as $project) {
echo($project->identifier);
echo("\r\n");
echo $project->identifier;
echo "\r\n";
ArchiveProject::dispatch($project);
ArchiveStudy::dispatch($project);
}
Expand Down
85 changes: 44 additions & 41 deletions app/Console/Commands/ExtractSpectra.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function handle()
])->get();

foreach ($projects as $project) {
echo "\r\n";
echo $project->identifier;
echo "\r\n";
$studies = $project->studies;
Expand Down Expand Up @@ -90,61 +91,63 @@ public function handle()
}
$study = $study->fresh();
foreach ($study->datasets as $dataset) {
echo $dataset->identifier;
echo "\r\n";
// echo $dataset->identifier;
// echo "\r\n";
// if(!$dataset->has_nmrium){
$nmriumInfo = json_decode($study->nmrium['nmrium_info'], true);
$_nmriumJSON = $nmriumInfo;
$fsObject = $dataset->fsObject;
$level = -($fsObject->level);
// echo $fsObject->path;
// echo("\r\n");
// echo $study->name;
// echo("\r\n");
$path = $study->name.'/'.$dataset->name;

$studyFSObject = $study->fsObject;
$datasetFSObject = $dataset->fsObject;
$path = '/'.$studyFSObject->name.'/'.$datasetFSObject->name;
// echo($path);
// echo "\r\n";
$pathsMatch = false;
foreach ($nmriumInfo['data']['spectra'] as $spectra) {
unset($_nmriumJSON['data']['spectra']);
$files = $spectra['sourceSelector']['files'];
// echo($path);
// echo("\r\n");
$pathsMatch = true;
if ($files) {
foreach ($files as $file) {
// echo $file;
// echo "\r\n";
if (! str_contains($file, $path)) {
$pathsMatch = false;
if (str_contains($file, $path)) {
$pathsMatch = true;
}
}
}
// echo($pathsMatch);
// echo("\r\n");
if ($pathsMatch) {
$_nmriumJSON['data']['spectra'] = [$spectra];
// dd($_nmriumJSON);
$_nmrium = $dataset->nmrium;
if ($_nmrium) {
$_nmrium->nmrium_info = json_encode($_nmriumJSON, JSON_UNESCAPED_UNICODE);
$dataset->has_nmrium = true;
$_nmrium->save();
} else {
$_nmrium = NMRium::create([
'nmrium_info' => json_encode($_nmriumJSON, JSON_UNESCAPED_UNICODE),
]);
$dataset->nmrium()->save($_nmrium);
$dataset->has_nmrium = true;
}
$experimentDetailsExists = array_key_exists('experiment', $spectra['info']);
if ($experimentDetailsExists) {
$experiment = $spectra['info']['experiment'];
$nucleus = $spectra['info']['nucleus'];
if (is_array($nucleus)) {
$nucleus = implode('-', $nucleus);
}
$dataset->type = $experiment.','.$nucleus;
break;
}
}
if (! $pathsMatch) {
echo $project->identifier;
echo "\r\n";

echo '===========> no match';
echo "\r\n";
} else {
$_nmriumJSON['data']['spectra'] = [$spectra];
$_nmrium = $dataset->nmrium;
if ($_nmrium) {
$_nmrium->nmrium_info = json_encode($_nmriumJSON, JSON_UNESCAPED_UNICODE);
$dataset->has_nmrium = true;
$_nmrium->save();
} else {
$_nmrium = NMRium::create([
'nmrium_info' => json_encode($_nmriumJSON, JSON_UNESCAPED_UNICODE),
]);
$dataset->nmrium()->save($_nmrium);
$dataset->has_nmrium = true;
}
$experimentDetailsExists = array_key_exists('experiment', $spectra['info']);
if ($experimentDetailsExists) {
$experiment = $spectra['info']['experiment'];
$nucleus = $spectra['info']['nucleus'];
if (is_array($nucleus)) {
$nucleus = implode('-', $nucleus);
}
$dataset->save();
$dataset->type = $experiment.','.$nucleus;
}
$dataset->save();
}
// }
}
Expand All @@ -154,7 +157,7 @@ public function handle()

public function processSpectra($url)
{
$response = Http::timeout(300)->post('https://nodejsdev.nmrxiv.org/spectra-parser', [
$response = Http::timeout(300)->post('https://nodejs.nmrxiv.org/spectra-parser', [
'urls' => [$url],
'snapshot' => false,
]);
Expand Down
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\App;

class Kernel extends ConsoleKernel
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/DatasetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function fetchNMRium(Request $request, Dataset $dataset)
if ($dataset) {
$nmrium = $dataset->nmrium;
if ($nmrium) {
return $nmrium;
return json_decode($nmrium->nmrium_info);
} else {
return null;
}
Expand Down
61 changes: 33 additions & 28 deletions app/Http/Controllers/StudyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,45 +209,50 @@ public function nmriumInfo(Request $request, Study $study)
$_nmriumJSON = $nmriumInfo;
foreach ($study->datasets as $dataset) {
$fsObject = $dataset->fsObject;
$level = -($fsObject->level + 1);
// echo $fsObject->path;
$path = implode('/', array_slice(explode('/', $fsObject->path), $level));

$studyFSObject = $study->fsObject;
$datasetFSObject = $dataset->fsObject;
$path = '/'.$studyFSObject->name.'/'.$datasetFSObject->name;

$pathsMatch = false;
foreach ($nmriumInfo['data']['spectra'] as $spectra) {
unset($_nmriumJSON['data']['spectra']);
$files = $spectra['sourceSelector']['files'];
$pathsMatch = true;
if ($files) {
foreach ($files as $file) {
if (! str_contains($file, $path)) {
$pathsMatch = false;
if (str_contains($file, $path)) {
$pathsMatch = true;
}
}
}
if ($pathsMatch) {
$_nmriumJSON['data']['spectra'] = [$spectra];
$_nmrium = $dataset->nmrium;
if ($_nmrium) {
$_nmrium->nmrium_info = $_nmriumJSON;
$dataset->has_nmrium = true;
$_nmrium->save();
} else {
$_nmrium = NMRium::create([
'nmrium_info' => json_encode($_nmriumJSON),
]);
$dataset->nmrium()->save($_nmrium);
$dataset->has_nmrium = true;
}
$experimentDetailsExists = array_key_exists('experiment', $spectra['info']);
if ($experimentDetailsExists) {
$experiment = $spectra['info']['experiment'];
$nucleus = $spectra['info']['nucleus'];
if (is_array($nucleus)) {
$nucleus = implode('-', $nucleus);
}
$dataset->type = $experiment.','.$nucleus;
break;
}
}
if ($pathsMatch){
$_nmriumJSON['data']['spectra'] = [$spectra];
$_nmrium = $dataset->nmrium;
if ($_nmrium) {
$_nmrium->nmrium_info = json_encode($_nmriumJSON, JSON_UNESCAPED_UNICODE);
$dataset->has_nmrium = true;
$_nmrium->save();
} else {
$_nmrium = NMRium::create([
'nmrium_info' => json_encode($_nmriumJSON, JSON_UNESCAPED_UNICODE),
]);
$dataset->nmrium()->save($_nmrium);
$dataset->has_nmrium = true;
}
$experimentDetailsExists = array_key_exists('experiment', $spectra['info']);
if ($experimentDetailsExists) {
$experiment = $spectra['info']['experiment'];
$nucleus = $spectra['info']['nucleus'];
if (is_array($nucleus)) {
$nucleus = implode('-', $nucleus);
}
$dataset->save();
$dataset->type = $experiment.','.$nucleus;
}
$dataset->save();
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function register()
*/
public function boot()
{
// if ($this->app->environment('production')) {
// \URL::forceScheme('https');
// }
if ($this->app->environment('production')) {
\URL::forceScheme('https');
}
}
}
12 changes: 7 additions & 5 deletions resources/js/Mixins/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ export default {

return str;
},
copyToClipboard(text, id) {
document.getElementById(id).select();
copyText(text, undefined, (error, event) => {
copyToClipboard(text, element) {
if (typeof element == "string") {
document.getElementById(id).select();
} else {
element.select();
}
copyText(text, undefined, (error) => {
if (error) {
console.log(error);
} else {
// console.log(event)
}
});
},
Expand Down
4 changes: 3 additions & 1 deletion resources/js/Pages/Project/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
v-if="project.identifier"
class="text-gray-400 mt-2"
>
<img :src="'/badge/doi/' + project.identifier" />
<DOIBadge :doi="project.doi"></DOIBadge>
</div>
<div
class="mt-2 flex items-center text-xs text-gray-400"
Expand Down Expand Up @@ -567,6 +567,7 @@ import Citation from "@/Shared/Citation.vue";
import Publish from "@/Shared/Publish.vue";
import AuthorCard from "@/Shared/AuthorCard.vue";
import CitationCard from "@/Shared/CitationCard.vue";
import DOIBadge from "@/Shared/DOIBadge.vue";
export default {
components: {
Expand All @@ -585,6 +586,7 @@ export default {
Publish,
AuthorCard,
CitationCard,
DOIBadge,
},
props: [
"project",
Expand Down
20 changes: 12 additions & 8 deletions resources/js/Pages/Public/Project/Dataset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
</span>
<div class="text-sm">
<span class="text-gray-400 pt-2">
<img :src="'badge/doi/' + study.data.identifier" />
<DOIBadge
:doi="study.data.doi"
color="bg-yellow-300"
></DOIBadge>
</span>
</div>
<div class="float-right">
Expand Down Expand Up @@ -97,7 +100,7 @@
</div>
</div>
</h1>
<div class="mt-4">
<!-- <div class="mt-4">
<div class="relative">
<div
class="absolute inset-0 flex items-center"
Expand All @@ -118,7 +121,7 @@
class="prose mt-1 text-sm text-blue-gray-500"
v-html="md(study.data.description)"
></p>
</div>
</div> -->
<div v-if="study.data.tags.length > 0" class="mt-4">
<div class="relative">
<div
Expand Down Expand Up @@ -309,11 +312,10 @@
><br />
<div class="text-sm">
<span class="text-gray-400 pt-2">
<img
:src="
'badge/doi/' + dataset.data.identifier
"
/>
<DOIBadge
:doi="dataset.data.doi"
color="bg-green-100"
></DOIBadge>
</span>
</div>
</h1>
Expand All @@ -338,6 +340,7 @@ import ProjectLayout from "@/Pages/Public/Project/Layout.vue";
import { ShareIcon, ClipboardDocumentIcon } from "@heroicons/vue/24/solid";
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
import SpectraViewer from "@/Shared/SpectraViewer.vue";
import DOIBadge from "@/Shared/DOIBadge.vue";
export default {
components: {
Expand All @@ -349,6 +352,7 @@ export default {
MenuItem,
MenuItems,
SpectraViewer,
DOIBadge,
},
props: ["project", "tab", "study", "dataset"],
data() {
Expand Down
4 changes: 3 additions & 1 deletion resources/js/Pages/Public/Project/Files.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<project-layout :project="project" :selected-tab="tab">
<template #project-content>
<div class="pb-10 mb-10 max-w-7xl mx-auto py-4">
<div
class="pb-10 mb-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-4 pb-6"
>
<div v-if="project.data.files">
<nav
v-if="$page.props.selectedFolder"
Expand Down
13 changes: 6 additions & 7 deletions resources/js/Pages/Public/Project/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,15 @@
>
</h1>
<p class="text-gray-700 pl-1 pt-2">
<img
:src="
'badge/doi/' +
project.data.identifier
"
/>
<DOIBadge
:doi="project.data.doi"
></DOIBadge>
</p>
<div class="sm:col-span-12 pt-4">
<span
v-for="tag in project.data.tags"
:key="tag.id"
class="mt-1 inline-flex items-center rounded-full bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10"
class="mt-1 mr-1 inline-flex items-center rounded-full bg-gray-50 px-2 py-1 text-sm font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10"
target="_blank"
:href="
'/projects?tag=' + tag.name.en
Expand Down Expand Up @@ -179,11 +176,13 @@
import AppLayout from "@/Layouts/AppLayout.vue";
import { Link, router } from "@inertiajs/vue3";
import { ArrowDownTrayIcon } from "@heroicons/vue/24/solid";
import DOIBadge from "@/Shared/DOIBadge.vue";
export default {
components: {
AppLayout,
Link,
ArrowDownTrayIcon,
DOIBadge,
},
props: ["project", "selectedTab"],
data() {
Expand Down
Loading

0 comments on commit 89eddbc

Please sign in to comment.