From b6e9bb12fb48683ae0ccd6eefe591fdbd88d3894 Mon Sep 17 00:00:00 2001 From: Leigh Morresi <275001+dgtlmoon@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:51:30 +0100 Subject: [PATCH] Basic tag browse buttons --- backend/backend.py | 16 ++++++++++++---- backend/static/css/styles.css | 7 +++++++ backend/store.py | 7 +++++++ backend/templates/watch-overview.html | 11 ++++++++++- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/backend/backend.py b/backend/backend.py index f53c2157..34194426 100644 --- a/backend/backend.py +++ b/backend/backend.py @@ -79,15 +79,23 @@ def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"): def main_page(): global messages + limit_tag = request.args.get('tag') + # 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(): - watch['uuid']=uuid - sorted_watches.append(watch) + 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.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. messages = [] diff --git a/backend/static/css/styles.css b/backend/static/css/styles.css index 5218ab74..a9fb36be 100644 --- a/backend/static/css/styles.css +++ b/backend/static/css/styles.css @@ -138,6 +138,13 @@ body:after, body:before { /* this is a green */ } +.button-tag { + background: rgb(99, 99, 99); + /* this is a green */ +color: #fff; + font-size: 65%; +} + .button-error { background: rgb(202, 60, 60); /* this is a maroon */ diff --git a/backend/store.py b/backend/store.py index 63bfc707..4f509de2 100644 --- a/backend/store.py +++ b/backend/store.py @@ -52,8 +52,15 @@ class ChangeDetectionStore: self.data['watching'][uuid].update({val: var}) 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): # Probably their should be dict... del(self.data['watching'][uuid]) diff --git a/backend/templates/watch-overview.html b/backend/templates/watch-overview.html index e93a325f..ee498e21 100644 --- a/backend/templates/watch-overview.html +++ b/backend/templates/watch-overview.html @@ -1,6 +1,7 @@ {% extends 'base.html' %} {% block content %} +