Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/NFDI4Chem/nmrxiv into prod-…
Browse files Browse the repository at this point in the history
…helm-deploy
  • Loading branch information
NishaSharma14 committed Nov 13, 2023
2 parents 8aed0de + acf920b commit cf245dc
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 146 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [1.0.1-rc.8](https://github.com/NFDI4Chem/nmrxiv/compare/v1.0.0-rc.8...v1.0.1-rc.8) (2023-11-13)


### Bug Fixes

* resolved [#888](https://github.com/NFDI4Chem/nmrxiv/issues/888) ([bb6da86](https://github.com/NFDI4Chem/nmrxiv/commit/bb6da86da78d2e7f451abb56c2187e18043e6847))
* updated dataset spectra loading logic and other minor updates ([e854cbb](https://github.com/NFDI4Chem/nmrxiv/commit/e854cbbd1c4c1681c79f128d8bd4f43b1f2524a1))
* updated DOIBadge component and various other fixes/updates ([ca36ea6](https://github.com/NFDI4Chem/nmrxiv/commit/ca36ea63dd99cd53b875ef2d43ffd2e528438670))
* updated nmrium info save routine ([5f22551](https://github.com/NFDI4Chem/nmrxiv/commit/5f225518eb7df42aaec30ff67b7f72df298c2742))

## 1.0.0 (2023-11-10)


Expand Down
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
Loading

0 comments on commit cf245dc

Please sign in to comment.