Skip to content

Commit

Permalink
Set auto refresh in configuration (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Jun 2, 2020
1 parent df86952 commit 46d8100
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
10 changes: 5 additions & 5 deletions config/cocoda.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
{
"provider": "LocalMappings",
"uri": "http://coli-conc.gbv.de/registry/local-mappings",
"autoRefresh": 5000,
"notation": [
"L"
],
Expand All @@ -179,7 +178,6 @@
"provider": "MappingsApi",
"uri": "http://coli-conc.gbv.de/registry/coli-conc-mappings",
"status": "https://coli-conc.gbv.de/api/status",
"autoRefresh": 10000,
"notation": [
"C"
],
Expand All @@ -200,7 +198,6 @@
"provider": "MappingsApi",
"uri": "http://coli-conc.gbv.de/registry/wikidata-mappings",
"status": "https://coli-conc.gbv.de/services/wikidata/status",
"autoRefresh": 10000,
"notation": [
"W"
],
Expand Down Expand Up @@ -456,7 +453,6 @@
"http://uri.gbv.de/terminology/dfg/"
]
}

],
"favoriteSchemes": [
"http://uri.gbv.de/terminology/bk/",
Expand Down Expand Up @@ -632,5 +628,9 @@
"url": "https://github.com/gbv/cocoda/wiki/Wikidata-GND"
}
],
"conceptLists": []
"conceptLists": [],
"autoRefresh": {
"mappings": 15000,
"update": 60000
}
}
32 changes: 16 additions & 16 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,22 @@ export default {
if (loaded) {
// Set page title
document.title = this.config.title
// Check for update every 60 seconds
let updateMessageShown = false
setInterval(() => {
axios.get("./build-info.json", {
headers: {
"Cache-Control": "no-cache",
},
}).then(response => response.data).then(buildInfo => {
if (buildInfo.gitCommit != this.config.buildInfo.gitCommit && !updateMessageShown) {
this.alert(this.$t("alerts.newVersionText"), 0, "info", this.$t("alerts.newVersionLink"), () => {
location.reload(true)
})
updateMessageShown = true
}
}).catch(() => null)
}, this.config.autoRefresh.update)
}
},
settingsLoaded() {
Expand Down Expand Up @@ -476,22 +492,6 @@ export default {
y: event.pageY,
})
}
// Check for update every 60 seconds
let updateMessageShown = false
setInterval(() => {
axios.get("./build-info.json", {
headers: {
"Cache-Control": "no-cache",
},
}).then(response => response.data).then(buildInfo => {
if (buildInfo.gitCommit != this.config.buildInfo.gitCommit && !updateMessageShown) {
this.alert(this.$t("alerts.newVersionText"), 0, "info", this.$t("alerts.newVersionLink"), () => {
location.reload(true)
})
updateMessageShown = true
}
}).catch(() => null)
}, 60000)
// Create a debounced internal setName method
// TODO: Move to mixin?
this.setName_ = _.debounce(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/MappingBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,12 @@ export default {
},
scheduleAutoRefresh(registry) {
// Auto refresh stored registries
// TODO: Configure via config or settings?
// TODO: Configure via settings?
if (this.$jskos.mappingRegistryIsStored(registry)) {
this.clearAutoRefresh(registry)
this.refreshTimers[registry.uri] = setInterval(() => {
this.$store.commit("mapping/setRefresh", { registry: registry.uri })
}, 10000)
}, this.config.autoRefresh.mappings)
}
},
showMappingsForConcordance(concordance) {
Expand Down
3 changes: 3 additions & 0 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ export default {

config.conceptLists = await dispatch("loadConceptLists", config.conceptLists)

// Set autoRefresh with default values
config.autoRefresh = Object.assign(defaultConfig.autoRefresh, config.autoRefresh || {})

// Save config
commit({
type: "setConfig",
Expand Down

0 comments on commit 46d8100

Please sign in to comment.