diff --git a/backend/__init__.py b/backend/__init__.py index 47b3a5a8..8293a2ba 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -97,9 +97,20 @@ def changedetection_app(config=None, datastore_o=None): @app.route("/", methods=['GET']) def index(): global messages - limit_tag = request.args.get('tag') + pause_uuid = request.args.get('pause') + + if pause_uuid: + try: + datastore.data['watching'][pause_uuid]['paused'] ^= True + datastore.needs_write = True + + return redirect(url_for('index', limit_tag = limit_tag)) + except KeyError: + pass + + # Sort by last_changed and add the uuid which is usually the key.. sorted_watches = [] for uuid, watch in datastore.data['watching'].items(): @@ -489,15 +500,17 @@ def changedetection_app(config=None, datastore_o=None): # Items that have this current tag for watch_uuid, watch in datastore.data['watching'].items(): if (tag != None and tag in watch['tag']): - i += 1 - if watch_uuid not in running_uuids: + if watch_uuid not in running_uuids and not datastore.data['watching'][watch_uuid]['paused']: update_q.put(watch_uuid) + i += 1 + else: # No tag, no uuid, add everything. for watch_uuid, watch in datastore.data['watching'].items(): - i += 1 - if watch_uuid not in running_uuids: + + if watch_uuid not in running_uuids and not datastore.data['watching'][watch_uuid]['paused']: update_q.put(watch_uuid) + i += 1 messages.append({'class': 'ok', 'message': "{} watches are rechecking.".format(i)}) return redirect(url_for('index', tag=tag)) @@ -561,7 +574,6 @@ class Worker(threading.Thread): self.current_uuid = uuid if uuid in list(datastore.data['watching'].keys()): - try: changed_detected, result, contents = update_handler.run(uuid) @@ -569,7 +581,6 @@ class Worker(threading.Thread): app.logger.error("File permission error updating", uuid, str(s)) else: if result: - datastore.update_watch(uuid=uuid, update_obj=result) if changed_detected: # A change was detected diff --git a/backend/static/css/styles.css b/backend/static/css/styles.css index da504eef..f2413c00 100644 --- a/backend/static/css/styles.css +++ b/backend/static/css/styles.css @@ -266,3 +266,7 @@ footer { #new-version-text a{ color: #e07171; } + +.paused-state.state-False img { + opacity: 0.3; +} diff --git a/backend/static/images/pause.svg b/backend/static/images/pause.svg new file mode 100644 index 00000000..f19206c5 --- /dev/null +++ b/backend/static/images/pause.svg @@ -0,0 +1,84 @@ + + diff --git a/backend/store.py b/backend/store.py index c44a4070..6aace3c0 100644 --- a/backend/store.py +++ b/backend/store.py @@ -47,6 +47,7 @@ class ChangeDetectionStore: 'tag': None, 'last_checked': 0, 'last_changed': 0, + 'paused': False, 'last_viewed': 0, # history key value of the last viewed via the [diff] link 'newest_history_key': "", 'title': None, @@ -134,6 +135,10 @@ class ChangeDetectionStore: def update_watch(self, uuid, update_obj): + # Skip if 'paused' state + if self.__data['watching'][uuid]['paused']: + return + with self.lock: # In python 3.9 we have the |= dict operator, but that still will lose data on nested structures... diff --git a/backend/templates/watch-overview.html b/backend/templates/watch-overview.html index e17c4ffa..ee9f43b0 100644 --- a/backend/templates/watch-overview.html +++ b/backend/templates/watch-overview.html @@ -29,6 +29,7 @@