mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
show feed errors
This commit is contained in:
parent
99684a4b2f
commit
d7ddcc04b5
1
assets/graphicarts/alert-circle.svg
Normal file
1
assets/graphicarts/alert-circle.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
|
After Width: | Height: | Size: 356 B |
@ -337,6 +337,11 @@
|
||||
<span class="icon mr-2" v-else><img v-lazy="'/api/feeds/'+feed.id+'/icon'" alt=""></span>
|
||||
{{ feed.title }}
|
||||
</div>
|
||||
<span class="icon flex-shrink-0 mx-2"
|
||||
v-b-tooltip.hover.top="feed_errors[feed.id]"
|
||||
v-if="feed_errors[feed.id]">
|
||||
{% inline "alert-circle.svg" %}
|
||||
</span>
|
||||
<div class="flex-shrink-0">
|
||||
<b-dropdown right no-caret lazy variant="link" class="settings-dropdown" toggle-class="text-decoration-none">
|
||||
<template v-slot:button-content>
|
||||
|
@ -43,6 +43,9 @@
|
||||
refresh: function() {
|
||||
return api('post', '/api/feeds/refresh')
|
||||
},
|
||||
list_errors: function() {
|
||||
return api('get', '/api/feeds/errors').then(json)
|
||||
},
|
||||
},
|
||||
folders: {
|
||||
list: function() {
|
||||
|
@ -177,6 +177,7 @@ var vm = new Vue({
|
||||
},
|
||||
'refreshRate': undefined,
|
||||
'authenticated': authenticated(),
|
||||
'feed_errors': {},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -529,6 +530,12 @@ var vm = new Vue({
|
||||
showSettings: function(settings) {
|
||||
this.settings = settings
|
||||
this.$bvModal.show('settings-modal')
|
||||
|
||||
if (settings === 'manage') {
|
||||
api.feeds.list_errors().then(function(errors) {
|
||||
vm.feed_errors = errors
|
||||
})
|
||||
}
|
||||
},
|
||||
resizeFeedList: function(width) {
|
||||
this.feedListWidth = Math.min(Math.max(200, width), 700)
|
||||
|
@ -31,6 +31,7 @@ var routes []Route = []Route{
|
||||
p("/api/feeds", FeedListHandler),
|
||||
p("/api/feeds/find", FeedHandler),
|
||||
p("/api/feeds/refresh", FeedRefreshHandler),
|
||||
p("/api/feeds/errors", FeedErrorsHandler),
|
||||
p("/api/feeds/:id/icon", FeedIconHandler),
|
||||
p("/api/feeds/:id", FeedHandler),
|
||||
p("/api/items", ItemListHandler),
|
||||
@ -229,6 +230,11 @@ func FeedRefreshHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func FeedErrorsHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
errors := db(req).GetFeedErrors()
|
||||
writeJSON(rw, errors)
|
||||
}
|
||||
|
||||
func FeedIconHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
id, err := strconv.ParseInt(Vars(req)["id"], 10, 64)
|
||||
if err != nil {
|
||||
|
@ -150,3 +150,23 @@ func (s *Storage) SetFeedError(feedID int64, lastError error) {
|
||||
s.log.Print(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Storage) GetFeedErrors() map[int64]string {
|
||||
errors := make(map[int64]string)
|
||||
|
||||
rows, err := s.db.Query(`select feed_id, error from feed_errors`)
|
||||
if err != nil {
|
||||
s.log.Print(err)
|
||||
return errors
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
var id int64
|
||||
var error string
|
||||
if err = rows.Scan(&id, &error); err != nil {
|
||||
s.log.Print(err)
|
||||
}
|
||||
errors[id] = error
|
||||
}
|
||||
return errors
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user