diff --git a/template/static/javascripts/api.js b/template/static/javascripts/api.js index 3044f8d..5ce546a 100644 --- a/template/static/javascripts/api.js +++ b/template/static/javascripts/api.js @@ -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) + }, + }, } })() diff --git a/template/static/javascripts/app.js b/template/static/javascripts/app.js index 943b0e8..05b8b84 100644 --- a/template/static/javascripts/app.js +++ b/template/static/javascripts/app.js @@ -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) {