store & retrieve settings

This commit is contained in:
Nazar Kanaev 2020-07-06 13:25:27 +01:00
parent 0761da85e7
commit e7bbf0c9bc
2 changed files with 20 additions and 1 deletions

View File

@ -55,6 +55,14 @@
update: function(id, data) {
return api('put', '/api/items/' + id, data)
}
}
},
settings: {
get: function() {
return api('get', '/api/settings').then(json)
},
update: function(data) {
return api('put', '/api/settings', data)
},
},
}
})()

View File

@ -4,6 +4,12 @@ var vm = new Vue({
el: '#app',
created: function() {
this.refresh()
var vm = this
api.settings.get().then(function(data) {
console.log(1)
vm.filterSelected = data.filter
console.log(1)
})
},
data: function() {
return {
@ -42,6 +48,11 @@ var vm = new Vue({
},
},
watch: {
'filterSelected': function(newVal) {
api.settings.update({filter: newVal}).then(function() {
this.$emit('refresh:items')
}.bind(this))
},
'feedSelected': function(newVal, oldVal) {
var promise = null
if (newVal === null) {