Adding checkall

pull/11/head
Leigh Morresi 4 years ago
parent 26c9a6e0fc
commit bbd99c9aa9

@ -199,8 +199,6 @@ def import_page():
messages.append({'class': 'ok', 'message': "{} Imported, {} Skipped.".format(good, len(remaining_urls))}) messages.append({'class': 'ok', 'message': "{} Imported, {} Skipped.".format(good, len(remaining_urls))})
launch_checks()
output = render_template("import.html", output = render_template("import.html",
messages=messages, messages=messages,
remaining="\n".join(remaining_urls) remaining="\n".join(remaining_urls)
@ -314,7 +312,6 @@ def api_watch_add():
# @todo add_watch should throw a custom Exception for validation etc # @todo add_watch should throw a custom Exception for validation etc
datastore.add_watch(url=request.form.get('url').strip(), tag=request.form.get('tag').strip()) datastore.add_watch(url=request.form.get('url').strip(), tag=request.form.get('tag').strip())
messages.append({'class': 'ok', 'message': 'Watch added.'}) messages.append({'class': 'ok', 'message': 'Watch added.'})
launch_checks()
return redirect(url_for('main_page')) return redirect(url_for('main_page'))
@ -332,20 +329,28 @@ def api_delete():
def api_watch_checknow(): def api_watch_checknow():
global messages global messages
uuid = request.args.get('uuid')
update_q.put(uuid)
tag = request.args.get('tag') tag = request.args.get('tag')
return redirect(url_for('main_page', tag=tag)) uuid = request.args.get('uuid')
i=0
if uuid:
update_q.put(uuid)
i = 1
@app.route("/api/recheckall", methods=['GET']) elif tag != None:
def api_watch_recheckall(): for watch_uuid, watch in datastore.data['watching'].items():
if (tag != None and tag in watch['tag']):
i += 1
update_q.put(watch_uuid)
else:
# No tag, no uuid, add everything.
for watch_uuid, watch in datastore.data['watching'].items():
i += 1
update_q.put(watch_uuid)
for uuid, watch in datastore.data['watching'].items(): messages.append({'class': 'ok', 'message': "{} watches are rechecking.".format(i)})
update_q.put(uuid) return redirect(url_for('main_page', tag=tag))
return "Triggered recheck of {} watches.".format(len(datastore.data['watching']))
# Requests for checking on the site use a pool of thread Workers managed by a Queue. # Requests for checking on the site use a pool of thread Workers managed by a Queue.
@ -362,6 +367,8 @@ class Worker(threading.Thread):
while True: while True:
uuid = self.q.get() # Blocking uuid = self.q.get() # Blocking
self.current_uuid = uuid self.current_uuid = uuid
# A little safety protection
if uuid in list( datastore.data['watching'].keys()):
fetch_site_status.perform_site_check(uuid=uuid, datastore=datastore) fetch_site_status.perform_site_check(uuid=uuid, datastore=datastore)
self.current_uuid = None # Done self.current_uuid = None # Done
self.q.task_done() self.q.task_done()

@ -82,7 +82,16 @@ section.content {
margin: 0 3px 0 5px; margin: 0 3px 0 5px;
} }
/* hotovo */ #check-all-button {
text-align:right;
}
#check-all-button a {
border-top-left-radius: initial;
border-top-right-radius: initial;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
body:after { body:after {

@ -26,7 +26,6 @@
</div> </div>
<div id="watch-table-wrapper"> <div id="watch-table-wrapper">
<table class="pure-table pure-table-striped watch-table"> <table class="pure-table pure-table-striped watch-table">
<thead> <thead>
<tr> <tr>
@ -67,6 +66,10 @@
</tbody> </tbody>
</table> </table>
<div id="check-all-button">
<a href="/api/checknow{% if active_tag%}?tag={{active_tag}}{%endif%}" class="pure-button button-tag " >Recheck all {% if active_tag%}in "{{active_tag}}"{%endif%}</a>
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
Loading…
Cancel
Save