From c7a94ea890cddfaa36f152fb69903042b268341c Mon Sep 17 00:00:00 2001 From: Nazar Kanaev Date: Wed, 1 Jul 2020 20:28:36 +0100 Subject: [PATCH] show feeds/folders --- .gitignore | 1 + template/static/javascripts/api.js | 5 +++++ template/static/javascripts/app.js | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index c1901cd..28a7e2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ yarr +*.db diff --git a/template/static/javascripts/api.js b/template/static/javascripts/api.js index e145a77..02877bf 100644 --- a/template/static/javascripts/api.js +++ b/template/static/javascripts/api.js @@ -20,6 +20,11 @@ create: function(data) { return api('post', '/api/feeds', data) }, + }, + folders: { + list: function() { + return api('get', '/api/folders') + }, } } })() diff --git a/template/static/javascripts/app.js b/template/static/javascripts/app.js index 78c30bd..600ed5a 100644 --- a/template/static/javascripts/app.js +++ b/template/static/javascripts/app.js @@ -8,23 +8,24 @@ var FILTERS = [ var vm = new Vue({ el: '#app', + created: function() { + var vm = this + Promise + .all([api.folders.list(), api.feeds.list()]) + .then(function(values) { + vm.folders = values[0] + vm.feeds = values[1] + }) + }, data: function() { return { 'filters': FILTERS, 'filterSelected': 'all', - 'folders': [ - {'id': 1, 'title': 'Tech', 'is_expanded': false}, - {'id': 2, 'title': 'News', 'is_expanded': true}, - ], - 'feeds': [ - {'id': '1', 'title': 'news.ycombinator.com', 'folder_id': 1}, - {'id': '2', 'title': 'daringfireball', 'folder_id': 1}, - {'id': '3', 'title': 'BBC', 'folder_id': 2}, - {'id': '4', 'title': 'The Guardian', 'folder_id': 2}, - {'id': '5', 'title': 'Random Stuff', 'folder_id': null}, - ], + 'folders': [], + 'feeds': [], 'feedSelected': null, - 'items': [ + 'items': [], + 'x': [ {'id': '123', 'title': 'Apple Pulls Pocket Casts and Castro From Chinese App Store', 'status': 'unread', 'feed_id': 2, 'date': 1592250298}, {'id': '456', 'title': 'On Apple Announcing the ARM Mac Transition at WWDC This Month', 'status': 'starred', 'feed_id': 2, 'date': 1592250298}, {'id': '789', 'title': 'Marques Brownlee: ‘Reflecting on the Color of My Skin’', 'status': 'read', 'feed_id': 2, 'date': 1592250298},