From 9066a3b6a31b6412b246b38f67a5ee6fc488ca48 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 5 May 2025 15:39:43 +0200 Subject: [PATCH] Abstarct ui watchlist cleanup --- .../blueprint/watchlist/templates/_macro.html | 128 ++++++++++++++++++ .../watchlist/templates/watch-overview.html | 126 +---------------- 2 files changed, 130 insertions(+), 124 deletions(-) create mode 100644 changedetectionio/blueprint/watchlist/templates/_macro.html diff --git a/changedetectionio/blueprint/watchlist/templates/_macro.html b/changedetectionio/blueprint/watchlist/templates/_macro.html new file mode 100644 index 000000000..8ac75fa9b --- /dev/null +++ b/changedetectionio/blueprint/watchlist/templates/_macro.html @@ -0,0 +1,128 @@ + + +{% macro render_watchlist_watch_as_tablerow(pagination, loop, datastore, watch) %} +{% set is_unviewed = watch.newest_history_key| int > watch.last_viewed and watch.history_n>=2 %} +{% set checking_now = is_checking_now(watch) %} + + {{ loop.index+pagination.skip }} + + {% if not watch.paused %} + Pause checks + {% else %} + UnPause checks + {% endif %} + {% set mute_label = 'UnMute notification' if watch.notification_muted else 'Mute notification' %} + {{ mute_label }} + + {{watch.title if watch.title is not none and watch.title|length > 0 else watch.url}} + + + + {% if watch.get_fetch_backend == "html_webdriver" + or ( watch.get_fetch_backend == "system" and system_default_fetcher == 'html_webdriver' ) + or "extra_browser_" in watch.get_fetch_backend + %} + Using a Chrome browser + {% endif %} + + {%if watch.is_pdf %}{% endif %} + {% if watch.has_browser_steps %}{% endif %} + {% if watch.last_error is defined and watch.last_error != False %} +
{{ watch.last_error }} + + {% if '403' in watch.last_error %} + {% if has_proxies %} + Try other proxies/location  + {% endif %} + Try adding external proxies/locations + + {% endif %} + {% if 'empty result or contain only an image' in watch.last_error %} + more help here. + {% endif %} +
+ {% endif %} + {% if watch.last_notification_error is defined and watch.last_notification_error != False %} +
{{ watch.last_notification_error }}
+ {% endif %} + + {% if watch['processor'] == 'text_json_diff' %} + {% if watch['has_ldjson_price_data'] and not watch['track_ldjson_price_data'] %} +
Switch to Restock & Price watch mode? Yes No
+ {% endif %} + {% endif %} + {% if watch['processor'] == 'restock_diff' %} + Price + {% endif %} + {% for watch_tag_uuid, watch_tag in datastore.get_all_tags_for_watch(watch['uuid']).items() %} + {{ watch_tag.title }} + {% endfor %} + + +{% if any_has_restock_price_processor %} + + {% if watch['processor'] == 'restock_diff' %} + {% if watch.has_restock_info %} + + + {% if watch['restock']['in_stock'] %} In stock {% else %} Not in stock {% endif %} + + {% endif %} + + {% if watch.get('restock') and watch['restock']['price'] != None %} + {% if watch['restock']['price'] != None %} + + {{ watch['restock']['price']|format_number_locale }} {{ watch['restock']['currency'] }} + + {% endif %} + {% elif not watch.has_restock_info %} + No information + {% endif %} + {% endif %} + +{% endif %} +{#last_checked becomes fetch-start-time#} + + {% if checking_now %} + Checking now + {% else %} + {{watch|format_last_checked_time|safe}} + {% endif %} + + {% if watch.history_n >=2 and watch.last_changed >0 %} + {{watch.last_changed|format_timestamp_timeago}} + {% else %} + Not yet + {% endif %} + + + {% if watch.uuid in queued_uuids %}Queued{% else %}Recheck{% endif %} + Edit + {% if watch.history_n >= 2 %} + + {% set open_diff_in_new_tab = datastore.data['settings']['application']['ui'].get('open_diff_in_new_tab') %} + {% set target_attr = ' target="' ~ watch.uuid ~ '"' if open_diff_in_new_tab else '' %} + + {% if is_unviewed %} + History + {% else %} + History + {% endif %} + + {% else %} + {% if watch.history_n == 1 or (watch.history_n ==0 and watch.error_text_ctime )%} + Preview + {% endif %} + {% endif %} + +{% endmacro %} \ No newline at end of file diff --git a/changedetectionio/blueprint/watchlist/templates/watch-overview.html b/changedetectionio/blueprint/watchlist/templates/watch-overview.html index e78965050..a9e226c19 100644 --- a/changedetectionio/blueprint/watchlist/templates/watch-overview.html +++ b/changedetectionio/blueprint/watchlist/templates/watch-overview.html @@ -1,6 +1,7 @@ {% extends 'base.html' %} {% block content %} {% from '_helpers.html' import render_simple_field, render_field, render_nolabel_field, sort_by_title %} +{% from '_macro.html' import render_watchlist_watch_as_tablerow %} @@ -100,130 +101,7 @@ {% endif %} {% for watch in (watches|sort(attribute=sort_attribute, reverse=sort_order == 'asc'))|pagination_slice(skip=pagination.skip) %} - {% set is_unviewed = watch.newest_history_key| int > watch.last_viewed and watch.history_n>=2 %} - {% set checking_now = is_checking_now(watch) %} - - {{ loop.index+pagination.skip }} - - {% if not watch.paused %} - Pause checks - {% else %} - UnPause checks - {% endif %} - {% set mute_label = 'UnMute notification' if watch.notification_muted else 'Mute notification' %} - {{ mute_label }} - - {{watch.title if watch.title is not none and watch.title|length > 0 else watch.url}} - - - - {% if watch.get_fetch_backend == "html_webdriver" - or ( watch.get_fetch_backend == "system" and system_default_fetcher == 'html_webdriver' ) - or "extra_browser_" in watch.get_fetch_backend - %} - Using a Chrome browser - {% endif %} - - {%if watch.is_pdf %}{% endif %} - {% if watch.has_browser_steps %}{% endif %} - {% if watch.last_error is defined and watch.last_error != False %} -
{{ watch.last_error }} - - {% if '403' in watch.last_error %} - {% if has_proxies %} - Try other proxies/location  - {% endif %} - Try adding external proxies/locations - - {% endif %} - {% if 'empty result or contain only an image' in watch.last_error %} - more help here. - {% endif %} -
- {% endif %} - {% if watch.last_notification_error is defined and watch.last_notification_error != False %} -
{{ watch.last_notification_error }}
- {% endif %} - - {% if watch['processor'] == 'text_json_diff' %} - {% if watch['has_ldjson_price_data'] and not watch['track_ldjson_price_data'] %} -
Switch to Restock & Price watch mode? Yes No
- {% endif %} - {% endif %} - {% if watch['processor'] == 'restock_diff' %} - Price - {% endif %} - {% for watch_tag_uuid, watch_tag in datastore.get_all_tags_for_watch(watch['uuid']).items() %} - {{ watch_tag.title }} - {% endfor %} - - -{% if any_has_restock_price_processor %} - - {% if watch['processor'] == 'restock_diff' %} - {% if watch.has_restock_info %} - - - {% if watch['restock']['in_stock'] %} In stock {% else %} Not in stock {% endif %} - - {% endif %} - - {% if watch.get('restock') and watch['restock']['price'] != None %} - {% if watch['restock']['price'] != None %} - - {{ watch['restock']['price']|format_number_locale }} {{ watch['restock']['currency'] }} - - {% endif %} - {% elif not watch.has_restock_info %} - No information - {% endif %} - {% endif %} - -{% endif %} - {#last_checked becomes fetch-start-time#} - - {% if checking_now %} - Checking now - {% else %} - {{watch|format_last_checked_time|safe}} - {% endif %} - - {% if watch.history_n >=2 and watch.last_changed >0 %} - {{watch.last_changed|format_timestamp_timeago}} - {% else %} - Not yet - {% endif %} - - - {% if watch.uuid in queued_uuids %}Queued{% else %}Recheck{% endif %} - Edit - {% if watch.history_n >= 2 %} - - {% set open_diff_in_new_tab = datastore.data['settings']['application']['ui'].get('open_diff_in_new_tab') %} - {% set target_attr = ' target="' ~ watch.uuid ~ '"' if open_diff_in_new_tab else '' %} - - {% if is_unviewed %} - History - {% else %} - History - {% endif %} - - {% else %} - {% if watch.history_n == 1 or (watch.history_n ==0 and watch.error_text_ctime )%} - Preview - {% endif %} - {% endif %} - + {{ render_watchlist_watch_as_tablerow(pagination, loop, datastore, watch) }} {% endfor %}