Basic tag browse buttons

pull/1/head
Leigh Morresi 4 years ago
parent 016937d5de
commit b6e9bb12fb

@ -79,15 +79,23 @@ def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"):
def main_page(): def main_page():
global messages global messages
limit_tag = request.args.get('tag')
# Sort by last_changed and add the uuid which is usually the key.. # Sort by last_changed and add the uuid which is usually the key..
sorted_watches=[] sorted_watches = []
for uuid, watch in datastore.data['watching'].items(): for uuid, watch in datastore.data['watching'].items():
watch['uuid']=uuid if limit_tag != None:
if watch['tag'] == limit_tag:
watch['uuid'] = uuid
sorted_watches.append(watch)
else:
watch['uuid'] = uuid
sorted_watches.append(watch) sorted_watches.append(watch)
sorted_watches.sort(key=lambda x: x['last_changed'], reverse=True) sorted_watches.sort(key=lambda x: x['last_changed'], reverse=True)
output = render_template("watch-overview.html", watches=sorted_watches, messages=messages) existing_tags = datastore.get_all_tags()
output = render_template("watch-overview.html", watches=sorted_watches, messages=messages, tags=existing_tags)
# Show messages but once. # Show messages but once.
messages = [] messages = []

@ -138,6 +138,13 @@ body:after, body:before {
/* this is a green */ /* this is a green */
} }
.button-tag {
background: rgb(99, 99, 99);
/* this is a green */
color: #fff;
font-size: 65%;
}
.button-error { .button-error {
background: rgb(202, 60, 60); background: rgb(202, 60, 60);
/* this is a maroon */ /* this is a maroon */

@ -52,7 +52,14 @@ class ChangeDetectionStore:
self.data['watching'][uuid].update({val: var}) self.data['watching'][uuid].update({val: var})
self.sync_to_json() self.sync_to_json()
def get_all_tags(self):
tags=[]
for uuid, watch in self.data['watching'].items():
if not watch['tag'] in tags:
tags.append(watch['tag'])
return tags
def delete(self, uuid): def delete(self, uuid):
# Probably their should be dict... # Probably their should be dict...

@ -1,6 +1,7 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %} {% block content %}
<div class="box"> <div class="box">
<form class="pure-form" action="/api/add" method="POST"> <form class="pure-form" action="/api/add" method="POST">
@ -13,7 +14,15 @@
<!-- add extra stuff, like do a http POST and send headers --> <!-- add extra stuff, like do a http POST and send headers -->
<!-- user/pass r = requests.get('https://api.github.com/user', auth=('user', 'pass')) --> <!-- user/pass r = requests.get('https://api.github.com/user', auth=('user', 'pass')) -->
</form> </form>
<div>
{% for tag in tags %}
{% if tag == "" %}
<a href="/" class="pure-button button-tag ">All</a>
{% else %}
<a href="/?tag={{ tag}}" class="pure-button button-tag ">{{ tag }}</a>
{% endif %}
{% endfor %}
</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">

Loading…
Cancel
Save