Commit 6679d439 authored by Markus Opolka's avatar Markus Opolka
Browse files

Add endpoint and button for refresh

parent a0f1dc41
......@@ -139,6 +139,7 @@ app.use(function (req, res, next) {
next()
})
// Load static site at this endpoint, so we don't a webserver
app.use('/', express.static('dist'))
app.get('/api/search/:letter?', function (req, res, next) {
......@@ -228,6 +229,16 @@ app.get('/api/metadata/table', function (req, res) {
res.send(lib.table(loadDocuments(DIR)))
})
app.get('/api/metadata/reload', function (req, res) {
// Document Metadata Endpoint in Table Format
try {
loadDocumentsToCache(DIR)
res.status(200).send({})
} catch (err) {
res.status(500).send({ error: 'Error while reloading cache' })
}
})
// Loading all documents to cache
loadDocumentsToCache(DIR)
......
......@@ -2,7 +2,12 @@
<v-container grid-list-md>
<v-layout row wrap>
<v-flex xs12>
<h3>{{header}}</h3>
<h3>{{header}}
<v-btn flat icon color="green" @click="reload">
<v-progress-circular v-if="reloading" indeterminate color="grey" v-bind:size="20"></v-progress-circular>
<v-icon v-else>cached</v-icon>
</v-btn>
</h3>
</v-flex>
<!-- List of all Letters -->
......@@ -47,13 +52,28 @@ export default {
data () {
return {
header: 'Letters',
letters: null
letters: null,
reloading: false
}
},
methods: {
reload () {
// Trigger Backend to reload cache
this.reloading = true
this.$http.get('http://localhost:3000/api/metadata/reload').then(function (data) {
this.load()
})
},
load () {
// Initial load of metadata
this.$http.get('http://localhost:3000/api/metadata/table').then(function (data) {
this.letters = data.body
this.reloading = false
})
}
},
created () {
this.$http.get('http://localhost:3000/api/metadata/table').then(function (data) {
this.letters = data.body
})
this.load()
}
}
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment