Skip to content

Commit

Permalink
fix: updated DOIBadge component and various other fixes/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Nov 12, 2023
1 parent 30cc6e1 commit ca36ea6
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 67 deletions.
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
6 changes: 4 additions & 2 deletions resources/js/Pages/Public/Project/Samples.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="p-8">
<div
class="pb-10 mb-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-4 pb-6"
>
<div class="flex items-baseline justify-between">
<div>
<h2 class="text-lg mb-3 font-bold">Studies</h2>
Expand Down Expand Up @@ -70,7 +72,7 @@
</div>
<div v-else>
<div
class="mt-8 mx-auto max-w-md grid gap-8 sm:max-w-lg lg:grid-cols-3 lg:max-w-7xl"
class="mt-8 mx-auto max-w-md grid gap-8 sm:max-w-lg lg:grid-cols-4 lg:max-w-7xl"
>
<div
v-for="study in studies.data"
Expand Down
15 changes: 13 additions & 2 deletions resources/js/Pages/Public/Project/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
<project-layout :project="project" :selected-tab="tab">
<template #project-content>
<div
class="pb-10 mb-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6"
class="pb-10 mb-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-4 pb-6"
>
<div
class="-mx-4"
v-if="project.data.is_public && project.data.doi != null"
>
<Citation
:model="'project'"
:doi="project.data.doi"
></Citation>
</div>
<div class="mt-2 space-y-4 divide-y divide-y-blue-gray-200">
<div>
<h3 class="text-xl font-extrabold text-blue-gray-900">
Expand All @@ -22,7 +31,7 @@
</div>
</div>

<div class="pt-2">
<div v-if="project.data.species" class="pt-2">
<h3 class="text-xl font-extrabold text-blue-gray-900">
Organism
</h3>
Expand Down Expand Up @@ -146,12 +155,14 @@ import ProjectLayout from "@/Pages/Public/Project/Layout.vue";
import AuthorCard from "@/Shared/AuthorCard.vue";
import CitationCard from "@/Shared/CitationCard.vue";
import "ontology-elements/dist/index.js";
import Citation from "@/Shared/Citation.vue";
export default {
components: {
ProjectLayout,
AuthorCard,
CitationCard,
Citation,
},
props: ["project", "tab"],
data() {
Expand Down
50 changes: 13 additions & 37 deletions resources/js/Pages/Public/Project/Study.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<div class="text-blue-500">
{{ study.data.name }}
</div>
<div class="text-sm float-left">
<span class="text-gray-400 pt-2">
<img :src="'badge/doi/' + study.data.identifier" />
</span>
<div class="text-sm float-left my-3">
<DOIBadge
:doi="study.data.doi"
color="bg-yellow-300"
></DOIBadge>
</div>
<div class="float-right">
<span class="flex-0.5 self-center">
Expand Down Expand Up @@ -98,6 +99,7 @@
</div>
</h1>
<br />
<br />
<div
v-if="
study.data.description &&
Expand Down Expand Up @@ -331,17 +333,6 @@
>
</option>
</select> -->
<!-- <div v-if="selectedDataset" class="text-sm my-2">
<span class="text-gray-400 pt-2">
<img
:src="
'badge/doi/' +
selectedDataset.identifier
"
/>
</span>
</div>
</div> -->
<div class="mt-3">
<SpectraViewer
ref="spectraViewerREF"
Expand Down Expand Up @@ -403,16 +394,13 @@
></a
>
<p class="text-gray-500">
<img
:src="
'badge/doi/' +
dataset.identifier
"
/>
<DOIBadge
color="bg-green-100"
:doi="dataset.doi"
></DOIBadge>
</p>
</div>
<div class="flex-shrink-0 pr-2">
<!-- {{ dataset.identifier }} -->
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
Expand All @@ -433,21 +421,6 @@
</li>
</ul>
</div>
<!--
<span
:value="dataset"
>
<span class="text-gray-400 float-left mr-1 pt-2">
<img
:src="
'badge/doi/' +
dataset.identifier
"
/>
</span>
</span> -->
</div>
<div>&emsp;</div>
</div>
Expand All @@ -465,6 +438,8 @@ import { ShareIcon, ClipboardDocumentIcon } from "@heroicons/vue/24/solid";
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
import SpectraViewer from "@/Shared/SpectraViewer.vue";
import Depictor2D from "@/Shared/Depictor2D.vue";
import DOIBadge from "@/Shared/DOIBadge.vue";
export default {
components: {
ProjectLayout,
Expand All @@ -476,6 +451,7 @@ export default {
MenuItems,
SpectraViewer,
Depictor2D,
DOIBadge,
},
props: ["project", "tab", "study"],
data() {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Shared/Citation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default {
dataciteURL() {
return this.$page.props.dataciteURL
? String(this.$page.props.dataciteURL) + "/dois/"
: "https://api.test.datacite.org/dois/";
: "https://api.datacite.org/dois/";
},
},
watch: {
Expand Down
57 changes: 57 additions & 0 deletions resources/js/Shared/DOIBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<div>
<div v-if="doi">
<div
class="inline-flex items-center cursor-pointer"
@click.prevent="copyDOIToClipboard"
>
<span
class="inline-flex items-center rounded-l-md border-r bg-gray-800 px-2 py-1 text-sm font-medium text-white"
>DOI:</span
>
<span
:class="[
color ? color : 'bg-blue-100',
'inline-flex items-center rounded-r-md px-2 py-1 text-sm font-medium text-gray-900',
]"
>{{ doi }}</span
>
<input
readonly
type="hidden"
:value="doi"
class="rounded-l-md focus:ring-gray-500 focus:border-gray-500 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300"
@focus="$event.target.select()"
/>
<span v-if="isVisible" class="text-gray-500 text-xs ml-2"
>Copied to clipboard!</span
>
</div>
</div>
</div>
</template>

<script>
export default {
components: {},
props: ["doi", "color"],
data() {
return {
isVisible: false,
};
},
methods: {
copyDOIToClipboard(event) {
let targetInput =
event.target.parentElement.getElementsByTagName("input")[0];
if (targetInput) {
this.isVisible = true;
setTimeout(() => {
this.isVisible = false;
}, 2500);
this.copyToClipboard(this.doi, targetInput);
}
},
},
};
</script>

0 comments on commit ca36ea6

Please sign in to comment.