Skip to content

Commit

Permalink
Add option to disable checking for updates (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Jun 26, 2020
1 parent 79e8e34 commit 3575c5b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 deletions.
4 changes: 4 additions & 0 deletions config/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
"title": "Settings",
"language": "Interface Language",
"languageContribution": "To contribute to the translation of Cocoda, see these <a href='https://gbv.github.io/cocoda/#translation' target='_blank'>instructions in the documentation</a>.",
"checkForUpdates": "Automatically Check for Application Updates",
"checkForUpdatesExplanation": "When turned on, Cocoda will check every {0} seconds whether it was updated to a newer version and show an alert if necessary.",
"resetSizes": "reset sizes",
"creator": "Name",
"creatorUrl": "Homepage (optional)",
Expand Down Expand Up @@ -419,6 +421,8 @@
"title": "Einstellungen",
"language": "Sprache der Oberfläche",
"languageContribution": "Um zur Übersetzung von Cocoda beizutragen, siehe diese <a href='https://gbv.github.io/cocoda/#translation' target='_blank'>Anweisungen in der Dokumentation</a> (Englisch).",
"checkForUpdates": "Automatisch nach Updates für die Anwendung suchen",
"checkForUpdatesExplanation": "Falls eingeschaltet, prüft Cocoda jede {0} Sekunden, ob es ein neues Update gibt, und zeigt diesbezüglich eine Meldung falls notwendig.",
"resetSizes": "Größen zurücksetzen",
"creator": "Name",
"creatorUrl": "Homepage (optional)",
Expand Down
45 changes: 28 additions & 17 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,14 @@ export default {
this.repeatLoadBuildInfo && this.repeatLoadBuildInfo.stop()
}
},
"$settings.checkForUpdates"(enabled) {
if (enabled) {
this.enableUpdateCheck()
} else {
this.repeatLoadBuildInfo && this.repeatLoadBuildInfo.stop()
this.repeatLoadBuildInfo = null
}
},
},
created() {
// Load application
Expand Down Expand Up @@ -498,23 +506,8 @@ export default {
// TODO: Should this be finished before loaded is set?
this.loadFromParametersOnce(true)
// Check for update every 60 seconds
if (this.config.autoRefresh.update) {
this.repeatLoadBuildInfo = cdk.loadBuildInfo({
url: "./build-info.json",
buildInfo: this.config.buildInfo,
interval: this.config.autoRefresh.update,
callImmediately: false,
callback: (error, buildInfo, previousBuildInfo) => {
// ? Should a new build (not only a newer commit) also be shown as an update?
if (!error && previousBuildInfo && buildInfo.gitCommit != previousBuildInfo.gitCommit) {
this.alert(this.$t("alerts.newVersionText"), 0, "info", this.$t("alerts.newVersionLink"), () => {
location.reload(true)
})
this.repeatLoadBuildInfo && this.repeatLoadBuildInfo.stop()
this.repeatLoadBuildInfo = null
}
},
})
if (this.config.autoRefresh.update && this.$settings.checkForUpdates) {
this.enableUpdateCheck()
}
// Set schemes in registries to objects from Cocoda
for (let registry of this.config.registries) {
Expand All @@ -524,6 +517,24 @@ export default {
}
this.$log.log(`Application loaded in ${((new Date()) - time)/1000} seconds.`)
},
enableUpdateCheck() {
this.repeatLoadBuildInfo = cdk.loadBuildInfo({
url: "./build-info.json",
buildInfo: this.config.buildInfo,
interval: this.config.autoRefresh.update,
callImmediately: false,
callback: (error, buildInfo, previousBuildInfo) => {
// ? Should a new build (not only a newer commit) also be shown as an update?
if (!error && previousBuildInfo && buildInfo.gitCommit != previousBuildInfo.gitCommit) {
this.alert(this.$t("alerts.newVersionText"), 0, "info", this.$t("alerts.newVersionLink"), () => {
location.reload(true)
})
this.repeatLoadBuildInfo && this.repeatLoadBuildInfo.stop()
this.repeatLoadBuildInfo = null
}
},
})
},
insertPrefLabel(isLeft) {
if (!this.$settings.components.ConceptSchemeSelection.insertPrefLabel[!isLeft]) {
return
Expand Down
20 changes: 16 additions & 4 deletions src/components/TheSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<tab
:title="$t('settingsTabs')[2]">
<div class="settingsModal-componentSettings-component">
<p
<div
v-if="localSettings"
class="form-inline">
<label style="padding-right: 0.5em">{{ $t("settings.language") }}:</label>
Expand All @@ -177,9 +177,21 @@
{{ $t(`languages.${language}`) }}
</option>
</b-form-select>
<span
class="form-text text-muted"
v-html="$t('settings.languageContribution')" />
</div>
<span
class="fontSize-small text-lightGrey"
v-html="$t('settings.languageContribution')" />
</div>
<div
v-if="localSettings && config.autoRefresh.update"
class="settingsModal-componentSettings-component">
<b-form-checkbox
v-model="localSettings.checkForUpdates">
{{ $t('settings.checkForUpdates') }}
</b-form-checkbox>
<p
class="fontSize-small text-lightGrey">
{{ $t('settings.checkForUpdatesExplanation', [Math.floor(config.autoRefresh.update/1000)]) }}
</p>
</div>
<div class="settingsModal-componentSettings-component">
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let defaultSettings = {
[false]: 0,
},
components: {},
checkForUpdates: true,
}

// prepare component settings
Expand Down

0 comments on commit 3575c5b

Please sign in to comment.