Skip to content

Commit

Permalink
Merge pull request #233 from nih-sparc/work-on-adding-github-repos
Browse files Browse the repository at this point in the history
Add ability to view datasets published on GitHub
  • Loading branch information
egauzens authored Nov 20, 2024
2 parents 2c3bc85 + 8d24bae commit 60f50d3
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
8 changes: 8 additions & 0 deletions components/DatasetDetails/DatasetActionBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
Cite Dataset
</el-button>
</template>
<template v-if="hasSourceCode">
<el-button class="secondary" @click="actionButtonClicked('source')">
Open Source Code
</el-button>
</template>
<template v-if="sdsViewer">
<a
:href="sdsViewer"
Expand Down Expand Up @@ -135,6 +140,9 @@ export default {
hasFiles: function() {
return this.fileCount >= 1
},
hasSourceCode: function () {
return propOr(null, 'release', this.datasetInfo) !== null
},
fileCount: function() {
return propOr('0', 'fileCount', this.datasetInfo)
},
Expand Down
40 changes: 40 additions & 0 deletions components/DatasetDetails/SourceCodeInfo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<div>
<div class="heading2 mb-8">
Repository
</div>
<div class="mb-16">
The design and code files for the device are stored in a public repository on GitHUB. Please feel free to clone the repository for your usage.
</div>
<div class="mb-16"><span class="label4">Repository Link: </span><a target="_blank" :href="repoLink">{{ repoLink }}</a></div>
<a
:href="repoLink"
target="_blank"
>
<el-button>
Visit Repository <svgo-icon-open class="icon-open" />
</el-button>
</a>
</div>
</template>

<script>
export default {
name: 'SourceCodeInfo',
props: {
repoLink: {
type: String,
default: () => "",
required: true
},
}
}
</script>

<style lang="scss" scoped>
.icon-open {
height: 1.5rem;
width: 1.5rem;
margin-top: 2px;
}
</style>
20 changes: 20 additions & 0 deletions pages/datasets/[datasetId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
:associated-projects="associatedProjects" />
<citation-details class="body1" v-show="activeTabId === 'cite'" :doi-value="datasetInfo.doi" />
<dataset-files-info class="body1" v-if="hasFiles" v-show="activeTabId === 'files'" />
<source-code-info class="body1" v-if="hasSourceCode" v-show="activeTabId === 'source'" :repoLink="sourceCodeLink"/>
<images-gallery class="body1" :markdown="markdown.markdownTop" v-show="activeTabId === 'images'" />
<dataset-references v-if="hasCitations" class="body1" v-show="activeTabId === 'references'"
:primary-publications="primaryPublications" :associated-publications="associatedPublications" />
Expand Down Expand Up @@ -90,6 +91,7 @@ import DatasetDescriptionInfo from '@/components/DatasetDetails/DatasetDescripti
import DatasetAboutInfo from '@/components/DatasetDetails/DatasetAboutInfo.vue'
import CitationDetails from '@/components/CitationDetails/CitationDetails.vue'
import DatasetFilesInfo from '@/components/DatasetDetails/DatasetFilesInfo.vue'
import SourceCodeInfo from '@/components/DatasetDetails/SourceCodeInfo.vue'
import ImagesGallery from '@/components/ImagesGallery/ImagesGallery.vue'
import DatasetReferences from '~/components/DatasetDetails/DatasetReferences.vue'
import VersionHistory from '@/components/VersionHistory/VersionHistory.vue'
Expand Down Expand Up @@ -210,6 +212,7 @@ export default {
DatasetAboutInfo,
CitationDetails,
DatasetFilesInfo,
SourceCodeInfo,
ImagesGallery,
DatasetReferences,
VersionHistory,
Expand Down Expand Up @@ -494,6 +497,12 @@ export default {
let numAssociated = this.associatedPublications ? this.associatedPublications.length : 0;
return numPrimary + numAssociated;
},
hasSourceCode: function () {
return propOr(null, 'release', this.datasetInfo) !== null
},
sourceCodeLink: function () {
return pathOr(null, ['release','repoUrl'], this.datasetInfo)
},
numDownloads: function () {
let numDownloads = 0;
this.downloadsSummary.filter(download => download.datasetId == this.datasetId).forEach(item => {
Expand Down Expand Up @@ -558,6 +567,17 @@ export default {
},
immediate: true
},
hasSourceCode: {
handler: function (newValue) {
if (newValue && !this.hasError) {
const hasSourceCodeTab = this.tabs.find(tab => tab.id === 'source') !== undefined
if (!hasSourceCodeTab) {
this.tabs.splice(4, 0, { label: 'Source Code', id: 'source' })
}
}
},
immediate: true
},
canViewVersions: {
handler: function (newValue) {
if (newValue && !this.hasError) {
Expand Down
2 changes: 1 addition & 1 deletion static/js/license-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const licenseData = [
},
{
label: 'MIT license (MIT)',
value: 'MIT',
value: 'MIT License',
abbr: 'MIT',
link: 'https://opensource.org/licenses/MIT'
},
Expand Down

0 comments on commit 60f50d3

Please sign in to comment.