Skip to content

Commit

Permalink
Merge pull request #517 from Duke-MatSci/MM-508C
Browse files Browse the repository at this point in the history
FEAT(#508): Dataset Fixes
  • Loading branch information
tholulomo authored Nov 30, 2024
2 parents 1bc79df + d588d09 commit dca1b31
Show file tree
Hide file tree
Showing 9 changed files with 1,059 additions and 531 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
TestBuild:
if: github.event_name != 'push'
runs-on: ubuntu-latest
needs: [BuildFrontend, BuildRESTFUL, BuildProxy, BuildWhyis]
env:
Expand Down
1,333 changes: 886 additions & 447 deletions app/src/pages/explorer/curate/sdd/SddForm.vue

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions app/src/pages/explorer/dataset/Dataset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ export default {
dataset: 'explorer/getCurrentDataset',
thumbnail: 'explorer/getDatasetThumbnail',
orcidData: 'explorer/curation/getOrcidData',
rorData: 'explorer/curation/getRorData'
rorData: 'explorer/curation/getRorData',
routeInfo: 'getRouteInfo'
}),
doi () {
if (this.dataset?.[this.datasetFields.doi]) {
Expand Down Expand Up @@ -436,7 +437,13 @@ export default {
})
},
navBack () {
this.$router.back()
// Note: A check to go back to gallery after curating a dataset
const { from } = this.routeInfo
if (from.name === 'CurateSDD') {
this.$router.push('/explorer/curate')
} else {
this.$router.back()
}
},
nav_to_tab (e) {
Object.keys(this.tabbed_content).forEach((el) => {
Expand Down
184 changes: 109 additions & 75 deletions app/src/pages/explorer/dataset/DatasetGallery.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
<template>
<div class="gallery">
<div class="section_loader" v-if="loading">
<spinner
:loading="loading"
text='Loading Datasets'
/>
<spinner :loading="loading" text="Loading Datasets" />
</div>
<div
class="utility-roverflow"
v-else
>

<div class="utility-roverflow u--margin-toplg">
<div class="search_box card-icon-container u--margin-toplg">
<form class="form">
<div class="search_box_form">
<div class="form__group search_box_form-item-1">
<input type="text" ref="search_input" class="form__input form__input--flat"
placeholder="Search Datasets" name="search" id="search"
required v-model.lazy="searchWord" />
<label htmlFor="search" class="form__label search_box_form_label">Search Datasets</label>
<div class="utility-roverflow" v-else>
<div class="utility-roverflow u--margin-toplg">
<div class="search_box card-icon-container u--margin-toplg">
<form class="form">
<div class="search_box_form">
<div class="form__group search_box_form-item-1">
<input
type="text"
ref="search_input"
class="form__input form__input--flat"
placeholder="Search Datasets"
name="search"
id="search"
required
v-model.lazy="searchWord"
/>
<label
htmlFor="search"
class="form__label search_box_form_label"
>Search Datasets</label
>
</div>
</div>
</div>
<div class="form__group search_box_form-item-2 explorer_page-nav u--margin-neg">
<!-- <div class="form__field md-field">
<div
class="form__group search_box_form-item-2 explorer_page-nav u--margin-neg"
>
<!-- <div class="form__field md-field">
<select class="form__select"
v-model="filter" name="filter" id="filter">
<option value="" disabled selected hidden>Filter by...</option>
Expand All @@ -34,36 +40,31 @@
<option value="user">Curating User</option>
</select>
</div> -->
<button
type="submit"
class="btn btn--primary btn--noradius search_box_form_btn mid-first-li display-text u--margin-pos"
@click.prevent="submitSearch()"
>
Search Datasets
</button>
<button v-if="searchEnabled"
type="submit"
class="btn btn--primary btn--noradius search_box_form_btn mid-first-li display-text u--margin-pos"
@click.prevent="customReset()"
>
Clear Search
</button>
</div>
</form>
<button
type="submit"
class="btn btn--primary btn--noradius search_box_form_btn mid-first-li display-text u--margin-pos"
@click.prevent="submitSearch()"
>
Search Datasets
</button>
<button
v-if="searchEnabled"
type="submit"
class="btn btn--primary btn--noradius search_box_form_btn mid-first-li display-text u--margin-pos"
@click.prevent="customReset()"
>
Clear Search
</button>
</div>
</form>
</div>
</div>
</div>
<div class="u_content__result">
<!-- TODO TIME TO RESULT -->
<span class="u_color utility-navfont" id="css-adjust-navfont">
<span v-if="total === 0">
No results
</span>
<span v-else-if="total === 1">
1 result
</span>
<span v-else>
About {{total}} results
</span>
<span v-if="total === 0"> No results </span>
<span v-else-if="total === 1"> 1 result </span>
<span v-else> About {{ total }} results </span>
</span>
</div>
<template v-if="!!items && !!items.length">
Expand All @@ -74,25 +75,39 @@
class="btn--animated gallery-item"
>
<div class="u_gridicon u_gridbg">
<a download :href="(optionalChaining(() => result.distribution))">
<md-icon class="u_color_white" style="font-size: 14px !important"
<a download :href="optionalChaining(() => result.distribution)">
<md-icon
class="u_color_white"
style="font-size: 14px !important"
>
download</md-icon
>
download</md-icon>
</a>
<div v-if="isAuth && isAdmin" @click.prevent="editDataset(result)">
<div
v-if="isAuth && isAdmin"
@click.prevent="editDataset(result)"
>
<md-icon class="u_color_white">edit</md-icon>
</div>
<div v-if="isAuth && isAdmin" @click.prevent="renderDialog('Delete Dataset?', 'delete', result, 80)">
<div
v-if="isAuth && isAdmin"
@click.prevent="
renderDialog('Delete Dataset?', 'delete', result, 80)
"
>
<md-icon class="u_color_white">delete_outline</md-icon>
</div>
</div>
<router-link v-if="result.identifier" :to="{ name: 'DatasetVisualizer', params: { id: getDatasetId(result) }}">
<router-link
v-if="result.identifier"
:to="{
name: 'DatasetVisualizer',
params: { id: getDatasetId(result) }
}"
>
<md-card-media-cover md-solid>
<md-card-media v-if="result.thumbnail" md-ratio="4:3">
<img
:src="result.thumbnail"
:alt="result.label"
>
<img :src="result.thumbnail" :alt="result.label" />
</md-card-media>
<md-card-media v-else md-ratio="4:3" class="u--bg-grey">
</md-card-media>
Expand All @@ -101,7 +116,9 @@
<span class="md-subheading">
<strong>{{ result.label }}</strong>
</span>
<span class="md-body-1">{{ reduceDescription(result.description, 15) }}</span>
<span class="md-body-1">{{
reduceDescription(result.description, 15)
}}</span>
</md-card-header>
</md-card-area>
</md-card-media-cover>
Expand All @@ -114,43 +131,53 @@
@go-to-page="loadPrevNextImage($event)"
/>
</template>
<div class="utility-roverflow u_centralize_text u_margin-top-med"
<div
class="utility-roverflow u_centralize_text u_margin-top-med"
v-else-if="page > totalPages && totalPages > 0"
>
<h3 class="visualize_header-h3 u_margin-top-med">Invalid page number,
<a @click.prevent=loadPrevNextImage(totalPages)>return to page {{totalPages}}?</a>
<h3 class="visualize_header-h3 u_margin-top-med">
Invalid page number,
<a @click.prevent="loadPrevNextImage(totalPages)"
>return to page {{ totalPages }}?</a
>
</h3>
</div>
<div class="utility-roverflow u_centralize_text u_margin-top-med section_loader" v-else>
<div
class="utility-roverflow u_centralize_text u_margin-top-med section_loader"
v-else
>
<h1 class="visualize_header-h1 u_margin-top-med">No Datasets Found</h1>
</div>
</div>
<dialogbox :active="dialogBoxActive" :minWidth="dialog.minWidth">
<template v-slot:title>{{dialog.title}}</template>
<template v-slot:title>{{ dialog.title }}</template>
<template v-slot:content>
<div v-if="dialog.type=='delete'">
<div v-if="dialog.type == 'delete'">
<md-content v-if="dialog.dataset">
<div> This will permanently remove the dataset <b>{{dialog.dataset.label}}</b> </div>
with identifier <b>{{dialog.dataset.identifier}}</b> and any associated files.
<div>
This will permanently remove the dataset
<b>{{ dialog.dataset.label }}</b>
</div>
with identifier <b>{{ dialog.dataset.identifier }}</b> and any
associated files.
</md-content>
</div>
<div v-if="dialogLoading">
<spinner
:loading="dialogLoading"
text='Deleting Chart'
/>
<spinner :loading="dialogLoading" text="Deleting Chart" />
</div>
</template>
<template v-slot:actions>
<span v-if="dialog.type=='delete' && dialog.dataset">
<span v-if="dialog.type == 'delete' && dialog.dataset">
<md-button @click.native.prevent="toggleDialogBox">
No, cancel
</md-button>
<md-button @click.native.prevent="deleteDataset(dialog.dataset)">
Yes, delete.
</md-button>
</span>
<md-button v-else @click.native.prevent="toggleDialogBox">Close</md-button>
<md-button v-else @click.native.prevent="toggleDialogBox"
>Close</md-button
>
</template>
</dialogbox>
</div>
Expand Down Expand Up @@ -221,7 +248,10 @@ export default {
async deleteDataset (dataset) {
if (!this.isAdmin) return // temporary safeguard
this.dialogLoading = true
await this.$store.dispatch('explorer/curation/deleteEntityNanopub', dataset.identifier)
await this.$store.dispatch(
'explorer/curation/deleteEntityNanopub',
dataset.identifier
)
await this.$store.dispatch('explorer/curation/deleteEntityES', {
identifier: dataset.identifier,
type: 'datasets'
Expand All @@ -231,7 +261,9 @@ export default {
await this.loadItems()
},
editDataset (dataset) {
return this.$router.push(`/explorer/curate/sdd/edit/${this.getDatasetId(dataset)}`)
return this.$router.push(
`/explorer/curate/sdd/edit/${this.getDatasetId(dataset)}`
)
},
downloadFiles (item) {
if (item.distribution) {
Expand All @@ -250,7 +282,9 @@ export default {
async loadItems (page = 1) {
this.loading = true
try {
await this.$store.dispatch('explorer/sddDatasets/loadDatasets', { page })
await this.$store.dispatch('explorer/sddDatasets/loadDatasets', {
page
})
} catch (error) {
this.$store.commit('setSnackbar', {
message: error || 'Something went wrong',
Expand Down
4 changes: 3 additions & 1 deletion app/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const router = new VueRouter({
}
})

router.beforeEach(async function (to, _, next) {
router.beforeEach(async function (to, from, next) {
if (to.meta.requiresAuth && !store.getters['auth/isAuthenticated']) {
if (!store.getters['auth/isAuthenticated']) {
store.commit(
Expand All @@ -96,12 +96,14 @@ router.beforeEach(async function (to, _, next) {

await store.dispatch('auth/tryLogin')
if (store.getters['auth/isAuthenticated']) {
store.commit('setRouteInfo', { to, from })
return next()
}
}
next('')
} else if (to.meta.requiresUnauth && store.getters.auth.isAuthenticated) {
next()
store.commit('setRouteInfo', { to, from })
} else {
next()
}
Expand Down
48 changes: 43 additions & 5 deletions app/src/store/modules/explorer/curation/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ export default {
]?.map((org) => {
return org?.['http://xmlns.com/foaf/0.1/name']?.['@value']
}),
distribution: datasetObject['http://www.w3.org/ns/dcat#distribution']?.map(
(dist) => {
return dist?.['@id']
}
)
distribution: datasetObject[
'http://www.w3.org/ns/dcat#distribution'
]?.map((dist) => {
return dist?.['@id']
})
}
},

Expand Down Expand Up @@ -627,5 +627,43 @@ export default {
{ root: true }
)
}
},
async deleteEntityFiles ({ _, __, rootGetters }, payload) {
const { distribution, thumbnail } = payload
if (!distribution.length && !thumbnail) return

const token = rootGetters['auth/token']
if (thumbnail) {
// Enable this url definition below for local testing
// const url = thumbnail.replace(
// 'http://restful:3001',
// 'http://localhost/api'
// );
// await fetch(url, {
await fetch(thumbnail, {
method: 'DELETE',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token
}
})
}

if (distribution.length) {
for (const dist of distribution) {
// Enable this url definition below for local testing
// const url = dist.replace('http://restful:3001', 'http://localhost/api');
// await fetch(url, {
await fetch(dist, {
method: 'DELETE',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token
}
})
}
}
}
}
Loading

0 comments on commit dca1b31

Please sign in to comment.