-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new settings menu for persistence (#2229)
Persistence policies can be configured from the UI. However, it is difficult to find, and one needs to know where to look. Apart from a documentation issue, I think persistence is core enough to merrit its own entry in the settings, so it becomes more prominent. See for example here: https://community.openhab.org/t/after-reboot-string-values-are-empty/152064/16 This adds a persistence entry below transformations to the settings menu. The new persistence config page allows to set the default persistence, and links to defining the policies for each installed persistence add-on. There also is a "add" list entry to install more persistence add-ons. If none is installed, it will explain persistence and link to the docs and the add-on store. The default persistence settings has been removed from the system settings, and the link to the persistence policy config from the add-on settings page has been converted to a button. --------- Also-by: Florian Hotze <florianh_dev@icloud.com> Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
- Loading branch information
Showing
5 changed files
with
181 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
bundles/org.openhab.ui/web/src/pages/settings/persistence/persistence-settings.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<template> | ||
<f7-page @page:afterin="onPageAfterIn" @page:beforeout="onPageBeforeOut"> | ||
<f7-navbar title="Persistence Settings" back-link="Settings" back-link-url="/settings/" back-link-force> | ||
<f7-nav-right v-if="persistenceList.length > 0"> | ||
<f7-link @click="save()" v-if="$theme.md" icon-md="material:save" icon-only /> | ||
<f7-link @click="save()" v-if="!$theme.md"> | ||
Save<span v-if="$device.desktop"> (Ctrl-S)</span> | ||
</f7-link> | ||
</f7-nav-right> | ||
</f7-navbar> | ||
|
||
<f7-block form v-if="ready && persistenceList.length" class="block-narrow"> | ||
<f7-col> | ||
<f7-block-title medium> | ||
General Settings | ||
</f7-block-title> | ||
<config-sheet | ||
:parameter-groups="configDescriptions.parameterGroups" | ||
:parameters="configDescriptions.parameters" | ||
:configuration="config" | ||
:set-empty-config-as-null="true" /> | ||
</f7-col> | ||
</f7-block> | ||
<f7-block v-if="ready && persistenceList.length" class="block-narrow"> | ||
<f7-col> | ||
<f7-block-title medium> | ||
Configure Persistence Policies | ||
</f7-block-title> | ||
<f7-list style="margin-top: 15px"> | ||
<f7-list-item | ||
v-for="persistence in persistenceList" | ||
media-item | ||
:key="persistence.id" | ||
:link="persistence.id" | ||
:title="persistence.label" | ||
:footer="persistence.id" /> | ||
<f7-list-item link="/addons/other/" no-chevron media-item :color="($theme.dark) ? 'black' : 'white'" subtitle="Install more persistence add-ons"> | ||
<f7-icon slot="media" color="green" aurora="f7:plus_circle_fill" ios="f7:plus_circle_fill" md="material:control_point" /> | ||
</f7-list-item> | ||
</f7-list> | ||
</f7-col> | ||
</f7-block> | ||
|
||
<f7-block v-if="ready && !persistenceList.length" class="service-config block-narrow"> | ||
<empty-state-placeholder icon="tray-arrow-down" title="persistence.title" text="persistence.text" /> | ||
<f7-row class="display-flex justify-content-center"> | ||
<f7-button large fill color="blue" external :href="documentationLink" target="_blank" v-t="'home.overview.button.documentation'" /> | ||
<span style="width: 8px" /> | ||
<f7-button large fill color="blue" href="/addons/other/"> | ||
Install a persistence add-on | ||
</f7-button> | ||
</f7-row> | ||
</f7-block> | ||
</f7-page> | ||
</template> | ||
|
||
<script> | ||
import DirtyMixin from '../dirty-mixin' | ||
import ConfigSheet from '@/components/config/config-sheet.vue' | ||
export default { | ||
mixins: [DirtyMixin], | ||
components: { | ||
'empty-state-placeholder': () => import('@/components/empty-state-placeholder.vue'), | ||
ConfigSheet | ||
}, | ||
data () { | ||
return { | ||
loading: false, | ||
ready: false, | ||
serviceId: 'org.openhab.persistence', | ||
persistenceList: [], | ||
configDescriptions: null, | ||
config: null | ||
} | ||
}, | ||
computed: { | ||
documentationLink () { | ||
return `https://${this.$store.state.runtimeInfo.buildString === 'Release Build' ? 'www' : 'next'}.openhab.org/link/persistence` | ||
} | ||
}, | ||
watch: { | ||
config: { | ||
handler: function () { | ||
if (!this.loading) { | ||
this.dirty = true | ||
} | ||
}, | ||
deep: true | ||
} | ||
}, | ||
methods: { | ||
onPageAfterIn () { | ||
if (window) { | ||
window.addEventListener('keydown', this.keyDown) | ||
} | ||
this.load() | ||
}, | ||
onPageBeforeOut () { | ||
if (window) { | ||
window.removeEventListener('keydown', this.keyDown) | ||
} | ||
}, | ||
load () { | ||
if (this.loading) return | ||
this.loading = true | ||
this.$oh.api.get('/rest/persistence').then((data) => { | ||
this.$set(this, 'persistenceList', data) | ||
}) | ||
this.$oh.api.get('/rest/services/' + this.serviceId).then(data => { | ||
if (data.configDescriptionURI) { | ||
this.$oh.api.get('/rest/config-descriptions/' + data.configDescriptionURI).then(data2 => { | ||
this.$set(this, 'configDescriptions', data2) | ||
this.$oh.api.get('/rest/services/' + this.serviceId + '/config').then(data3 => { | ||
this.$set(this, 'config', data3) | ||
this.$nextTick(() => { | ||
this.loading = false | ||
this.ready = true | ||
}) | ||
}) | ||
}) | ||
} | ||
}) | ||
}, | ||
save () { | ||
this.$oh.api.put('/rest/services/' + this.serviceId + '/config', this.config).then(() => { | ||
this.$f7.toast.create({ | ||
text: 'Default persistence setting saved', | ||
destroyOnClose: true, | ||
closeTimeout: 2000 | ||
}).open() | ||
}) | ||
this.dirty = false | ||
}, | ||
keyDown (ev) { | ||
if ((ev.ctrlKey || ev.metaKey) && !(ev.altKey || ev.shiftKey)) { | ||
switch (ev.keyCode) { | ||
case 83: | ||
this.save() | ||
ev.stopPropagation() | ||
ev.preventDefault() | ||
break | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</script> |