From 55cd243a77eaf60ecb022f8f18b100670e7689dc Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Fri, 9 May 2025 16:34:06 +0200 Subject: [PATCH] Connect up each row buttons --- changedetectionio/blueprint/ui/__init__.py | 6 ++- changedetectionio/blueprint/ui/ajax.py | 35 +++++++++++++++ .../blueprint/watchlist/__init__.py | 44 ++++++++++--------- .../watchlist/templates/watch-overview.html | 16 +++---- changedetectionio/realtime/socket_server.py | 2 + changedetectionio/static/js/socket.js | 36 ++++++++------- .../styles/scss/parts/_watch_table.scss | 20 +++++++++ changedetectionio/static/styles/styles.css | 8 ++++ 8 files changed, 121 insertions(+), 46 deletions(-) create mode 100644 changedetectionio/blueprint/ui/ajax.py diff --git a/changedetectionio/blueprint/ui/__init__.py b/changedetectionio/blueprint/ui/__init__.py index 35b24cbe..a87aaaf6 100644 --- a/changedetectionio/blueprint/ui/__init__.py +++ b/changedetectionio/blueprint/ui/__init__.py @@ -3,6 +3,7 @@ from flask import Blueprint, request, redirect, url_for, flash, render_template, from loguru import logger from functools import wraps +from changedetectionio.blueprint.ui.ajax import constuct_ui_ajax_blueprint from changedetectionio.store import ChangeDetectionStore from changedetectionio.blueprint.ui.edit import construct_blueprint as construct_edit_blueprint from changedetectionio.blueprint.ui.notification import construct_blueprint as construct_notification_blueprint @@ -22,7 +23,10 @@ def construct_blueprint(datastore: ChangeDetectionStore, update_q, running_updat # Register the views blueprint views_blueprint = construct_views_blueprint(datastore, update_q, queuedWatchMetaData, watch_check_completed) ui_blueprint.register_blueprint(views_blueprint) - + + ui_ajax_blueprint = constuct_ui_ajax_blueprint(datastore, update_q, running_update_threads, queuedWatchMetaData, watch_check_completed) + ui_blueprint.register_blueprint(ui_ajax_blueprint) + # Import the login decorator from changedetectionio.auth_decorator import login_optionally_required diff --git a/changedetectionio/blueprint/ui/ajax.py b/changedetectionio/blueprint/ui/ajax.py new file mode 100644 index 00000000..5d2352e3 --- /dev/null +++ b/changedetectionio/blueprint/ui/ajax.py @@ -0,0 +1,35 @@ +import time + +from blinker import signal +from flask import Blueprint, request, redirect, url_for, flash, render_template, session + + +from changedetectionio.store import ChangeDetectionStore + +def constuct_ui_ajax_blueprint(datastore: ChangeDetectionStore, update_q, running_update_threads, queuedWatchMetaData, watch_check_completed): + ui_ajax_blueprint = Blueprint('ajax', __name__, template_folder="templates", url_prefix='/ajax') + + # Import the login decorator + from changedetectionio.auth_decorator import login_optionally_required + + @ui_ajax_blueprint.route("/toggle", methods=['POST']) + @login_optionally_required + def ajax_toggler(): + op = request.values.get('op') + uuid = request.values.get('uuid') + if op and datastore.data['watching'].get(uuid): + if op == 'pause': + datastore.data['watching'][uuid].toggle_pause() + elif op == 'mute': + datastore.data['watching'][uuid].toggle_mute() + elif op == 'recheck': + update_q.put(queuedWatchMetaData.PrioritizedItem(priority=1, item={'uuid': uuid})) + + watch_check_completed = signal('watch_check_completed') + if watch_check_completed: + watch_check_completed.send(watch_uuid=uuid) + + return 'OK' + + + return ui_ajax_blueprint diff --git a/changedetectionio/blueprint/watchlist/__init__.py b/changedetectionio/blueprint/watchlist/__init__.py index 173c50ea..bd3b6c98 100644 --- a/changedetectionio/blueprint/watchlist/__init__.py +++ b/changedetectionio/blueprint/watchlist/__init__.py @@ -72,31 +72,33 @@ def construct_blueprint(datastore: ChangeDetectionStore, update_q, queuedWatchMe per_page=datastore.data['settings']['application'].get('pager_size', 50), css_framework="semantic") sorted_tags = sorted(datastore.data['settings']['application'].get('tags').items(), key=lambda x: x[1]['title']) + output = render_template( "watch-overview.html", - active_tag=active_tag, - active_tag_uuid=active_tag_uuid, - app_rss_token=datastore.data['settings']['application'].get('rss_access_token'), - datastore=datastore, - errored_count=errored_count, - form=form, - guid=datastore.data['app_guid'], - has_proxies=datastore.proxy_list, - has_unviewed=datastore.has_unviewed, - hosted_sticky=os.getenv("SALTED_PASS", False) == False, - now_time_server=round(time.time()), - pagination=pagination, - queued_uuids=[q_uuid.item['uuid'] for q_uuid in update_q.queue], - search_q=request.args.get('q', '').strip(), - sort_attribute=request.args.get('sort') if request.args.get('sort') else request.cookies.get('sort'), - sort_order=request.args.get('order') if request.args.get('order') else request.cookies.get('order'), - system_default_fetcher=datastore.data['settings']['application'].get('fetch_backend'), - tags=sorted_tags, - watches=sorted_watches - ) + active_tag=active_tag, + active_tag_uuid=active_tag_uuid, + app_rss_token=datastore.data['settings']['application'].get('rss_access_token'), + ajax_toggle_url=url_for('ui.ajax.ajax_toggler'), + datastore=datastore, + errored_count=errored_count, + form=form, + guid=datastore.data['app_guid'], + has_proxies=datastore.proxy_list, + has_unviewed=datastore.has_unviewed, + hosted_sticky=os.getenv("SALTED_PASS", False) == False, + now_time_server=round(time.time()), + pagination=pagination, + queued_uuids=[q_uuid.item['uuid'] for q_uuid in update_q.queue], + search_q=request.args.get('q', '').strip(), + sort_attribute=request.args.get('sort') if request.args.get('sort') else request.cookies.get('sort'), + sort_order=request.args.get('order') if request.args.get('order') else request.cookies.get('order'), + system_default_fetcher=datastore.data['settings']['application'].get('fetch_backend'), + tags=sorted_tags, + watches=sorted_watches + ) if session.get('share-link'): - del(session['share-link']) + del (session['share-link']) resp = make_response(output) diff --git a/changedetectionio/blueprint/watchlist/templates/watch-overview.html b/changedetectionio/blueprint/watchlist/templates/watch-overview.html index 7dd6360b..7071801d 100644 --- a/changedetectionio/blueprint/watchlist/templates/watch-overview.html +++ b/changedetectionio/blueprint/watchlist/templates/watch-overview.html @@ -4,6 +4,7 @@ +