Skip to content

Commit

Permalink
Merge pull request #505 from Duke-MatSci/xml_input
Browse files Browse the repository at this point in the history
XML Curation
  • Loading branch information
tholulomo authored Jul 28, 2024
2 parents 804f549 + 1e1114d commit aeed7f9
Show file tree
Hide file tree
Showing 19 changed files with 650 additions and 158 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ package-lock.json
**/**/*.log

# Fuseki
mockDB/old-fuseki/
mockDB/fuseki/shiro.ini
mockDB/fuseki/backups/
mockDB/fuseki/databases/
Expand All @@ -38,6 +39,7 @@ mockDB/fuseki/templates/
mockDB/fuseki/log4j2.properties
mockDB/materialsmine_backup/
mockDB/fuseki/files/
mockDB/fuseki/

#Sync DB
mockDB/restore/mongodump/
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/ChartGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="section_loader" v-if="loading">
<spinner :loading="loading" text="Loading Charts" />
</div>
<div class="utility-roverflow" v-else>
<div class="" v-else>
<div class="u_content__result">
<!-- TODO TIME TO RESULT -->
<span class="u_color utility-navfont" id="css-adjust-navfont">
Expand Down
13 changes: 9 additions & 4 deletions app/src/components/LoginRequired.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<template>
<div class="page-not-found">
<i class="material-icons page-not-found-header u--padding-zero" >lock_person</i>
<i class="material-icons page-not-found-header u--padding-zero"
>lock_person</i
>
<h2 class="u_margin-bottom-small">Login required</h2>
<p>The page you are trying to access requires authentication.
Would you like to <a>log in</a> or return to the
<router-link to=""><a @click="$router.go(-1)">previous page</a></router-link>?
<p>
The page you are trying to access requires authentication. Would you like
to <a href="/secure">log in</a> or return to the
<router-link to=""
><a @click="$router.go(-1)">previous page</a></router-link
>?
</p>
</div>
</template>
10 changes: 7 additions & 3 deletions app/src/components/nanomine/HeroHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@
</li>
<li class="u_margin-right-small">
<div class="nav_menu--container">
<a class="u--default-size nav_menu--handler" href="#">Curate</a>
<div class="nav_menu--siblings">
<a
class="u--default-size nav_menu--handler"
href="/explorer/curate"
>Curate</a
>
<!-- <div class="nav_menu--siblings">
<a
href="/explorer/curate/spreadsheet"
class="nav_menu--siblings-lists"
Expand All @@ -95,7 +99,7 @@
class="nav_menu--siblings-lists"
><a>Create Chart</a></router-link
>
</div>
</div> -->
</div>
</li>
<li class="u_margin-right-small">
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/vega-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ async function loadChart (chartUri) {
const rows = results.bindings

if (rows.length < 1) {
throw new Error(`No chart found for uri: ${chartUrl}`)
throw new Error(`No data found for the specified chart URI: ${chartUrl}`)
}

return await readChartSparqlRow(rows[0])
Expand Down
23 changes: 20 additions & 3 deletions app/src/pages/explorer/Curate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,32 @@
<md-icon class="explorer_page-nav-card_icon"
>done_outline</md-icon
>
<span class="explorer_page-nav-card_text"
>Submit with SDD</span
>
<span class="explorer_page-nav-card_text">Submit SDD</span>
<p class="md-layout-item_para md-layout-item_para_fl">
Submit files that use a semantic data dictionary (SDD).
</p>
</div>
</router-link>
</div>
<div class="md-layout-item md-layout-item_card">
<router-link
to="/explorer/curate/xml"
v-slot="{ navigate, href }"
custom
>
<div
class="teams_container explorer_page-nav-card md-layout-item_card"
:href="href"
@click="navigate"
>
<md-icon class="explorer_page-nav-card_icon">upload</md-icon>
<span class="explorer_page-nav-card_text">Upload an XML</span>
<p class="md-layout-item_para md-layout-item_para_fl">
Directly upload XML files.
</p>
</div>
</router-link>
</div>
<!-- Extra Div causes misalignment and has no known use -->
<!-- <div class="md-layout-item md-layout-item_card">
</div> -->
Expand Down
12 changes: 7 additions & 5 deletions app/src/pages/explorer/chart/editor/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ export default {
querySparql(vm.chart.query)
.then(this.onQuerySuccess)
.then((this.loading = false))
.catch((this.loading = false))
},
onQuerySuccess (results) {
this.results = results
},
onSpecJsonError () {
// console.log('bad', arguments)
},
async onNewVegaView (view) {
const blob = await view
Expand Down Expand Up @@ -215,10 +215,12 @@ export default {
this.actionType = 'Restore Chart'
this.reloadRestored()
}
getChartPromise.then((chart) => {
this.chart = chart
return this.getSparqlData()
})
getChartPromise
.then((chart) => {
this.chart = chart
return this.getSparqlData()
})
.catch((this.loading = false))
},
async reloadRestored () {
// 1. Fetch backup from mongo
Expand Down
191 changes: 191 additions & 0 deletions app/src/pages/explorer/curate/xml/xmlUpload.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<template>
<div class="section_teams">
<div>
<CurateNavBar active="New XML Upload" :navRoutes="navRoutes" />
</div>
<div class="curate">
<LoginReq v-if="!isAuth" />
<div v-else-if="loading" class="section_loader">
<spinner :text="uploadInProgress" />
</div>
<div v-else-if="submitted" class="section_loader">
<h2 class="visualize_header-h1">XML Samples Submitted</h2>
</div>
<div v-else>
<h2 class="visualize_header-h1">Upload XML Samples</h2>
<md-steppers
md-vertical
md-linear
:md-active-step.sync="active"
class="form__stepper"
>
<md-step id="first" md-label="Upload Xml File" :md-done.sync="first">
<DropZone class="form__drop-area" @files-dropped="addXmlFile">
<label for="xml-file-input">
<div class="form__drop-area_label">
<div class="explorer_page-nav-card_text">
Drag prepared xml files here
</div>
<div
class="md-layout-item_para md-layout-item_para_fl"
style="text-align: center"
>
or click to browse. Accepts .xml files
</div>
<input
type="file"
id="xml-file-input"
multiple
@change="onInputChange"
accept=".xml"
/>
</div>
</label>
</DropZone>
<div class="u--margin-posmd u--color-primary teams_header">
<strong>Note:</strong> Title, Author, Citation Type and
Publication Year, are required entry in the XML.
</div>
<div class="md-layout" v-show="xmlFiles.length">
<md-list class="md-layout utility-transparentbg md-theme-default">
<FilePreview
v-for="file in xmlFiles"
:key="file.id"
:file="file"
tag="div"
classname="md-layout-item"
@remove="removeXmlFile"
/>
</md-list>
</div>
<md-button
type="submit"
:disabled="xmlFiles.length < 1"
class="md-button_next u--margin-toplg"
@click="goToStep('first', 'second')"
>
Next
</md-button>
</md-step>
<md-step
id="second"
md-label="Confirm and submit"
:md-done.sync="second"
>
<div class="u--color-primary teams_header">
<strong>Are you sure?</strong> Select
<strong>Save & Submit</strong> to confirm or
<strong>Go Back</strong> to cancel
</div>
<div class="md-layout">
<md-button
type="submit"
class="md-layout-item md-button_prev md-size-40"
@click="goToStep('second', 'first')"
>
<md-icon>arrow_back</md-icon>Go Back
</md-button>
<md-button
id="submit"
type="submit"
:disabled="xmlFiles.length < 1"
class="md-layout-item md-button_next md-size-40"
@click="submitXmlFiles"
>
Save and Submit
</md-button>
</div>
</md-step>
</md-steppers>
</div>
</div>
</div>
</template>

<script>
import DropZone from '@/components/curate/FileDrop.vue'
import FilePreview from '@/components/curate/FilePreview.vue'
import LoginRequired from '@/components/LoginRequired.vue'
import CurateNavBar from '@/components/curate/CurateNavBar.vue'
import Spinner from '@/components/Spinner.vue'
import useFileList from '@/modules/file-list'
import { mapGetters, mapActions } from 'vuex'
const xmlFilesFn = useFileList()
export default {
name: 'XmlUpload',
components: {
DropZone,
FilePreview,
CurateNavBar,
Spinner,
LoginReq: LoginRequired
},
data () {
return {
active: 'first',
first: false,
second: false,
xmlFiles: xmlFilesFn.files,
loading: false,
uploadInProgress: null,
submitted: false,
navRoutes: [
{
label: 'Curate',
path: '/explorer/curate'
}
]
}
},
methods: {
addXmlFile: xmlFilesFn.addFiles,
removeXmlFile: xmlFilesFn.removeFile,
modStatXml: xmlFilesFn.modifyStatus,
...mapActions({
submitXML: 'explorer/curation/submitXmlFiles'
}),
goToStep (id, index) {
// this.clearSnackbar();
this[id] = true
if (index) {
this.active = index
}
},
filterXml (files) {
this.renameXlsx = false
const newFiles = [...files]
const filteredFiles = []
const regex = /.xml$/gi
for (let i = 0; i < newFiles.length; i++) {
if (!regex.test(newFiles[i].name)) {
this.renameXlsx = true
} else filteredFiles.push(newFiles[i])
}
return filteredFiles
},
onInputChange (e) {
// TODO: Remove the if statement below and check that everything works correctly
if (e.target.id === 'xml-file-input') {
const uploadedXmlFiles = this.filterXml(e.target.files)
this.addXmlFile(uploadedXmlFiles)
}
// reset so that selecting the same file again will still cause it to fire this change
e.target.value = null
},
async submitXmlFiles () {
this.uploadInProgress = 'Uploading...'
this.loading = true
await this.submitXML(this.xmlFiles)
this.loading = false
this.submitted = true
this.uploadInProgress = null
}
},
computed: {
...mapGetters({
isAuth: 'auth/isAuthenticated'
})
}
}
</script>
5 changes: 4 additions & 1 deletion app/src/pages/explorer/xml/XmlLoader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</md-button>

<md-button
@click="approveCuration(xmlViewer)"
@click="approveCuration({ xmlViewer, reloadXml })"
v-if="isAuth && isAdmin && xmlViewer.curationState !== 'Completed'"
class="md-fab md-dense md-primary btn--primary"
>
Expand Down Expand Up @@ -194,6 +194,9 @@ export default {
query: { isNew: isNew, id: id }
})
}
},
async reloadXml () {
return await this.$apollo.queries.xmlFinder.refetch()
}
},
mounted () {
Expand Down
4 changes: 4 additions & 0 deletions app/src/router/module/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ const explorerRoutes = [
component: () =>
import('@/pages/explorer/curate/form/CurationForm.vue'),
meta: { requiresAuth: true }
},
{
path: 'xml',
component: () => import('@/pages/explorer/curate/xml/xmlUpload.vue')
}
]
},
Expand Down
Loading

0 comments on commit aeed7f9

Please sign in to comment.