diff --git a/changedetectionio/blueprint/watchlist/templates/watch-overview.html b/changedetectionio/blueprint/watchlist/templates/watch-overview.html index 59f2f5b6..f8db25c8 100644 --- a/changedetectionio/blueprint/watchlist/templates/watch-overview.html +++ b/changedetectionio/blueprint/watchlist/templates/watch-overview.html @@ -105,8 +105,7 @@ {% endif %} - {%if watch.is_pdf %}Converting PDF to text{% endif %} + {% if watch.is_pdf %}Converting PDF to text{% endif %} {% if watch.has_browser_steps %}Browser Steps is enabled{% endif %} -
{{ watch.compile_error_texts(has_proxies=datastore.proxy_list)|safe }}
+ {% if watch['processor'] == 'text_json_diff' %} {% if watch['has_ldjson_price_data'] and not watch['track_ldjson_price_data'] %} diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index 65fa6af9..693dd18d 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -669,15 +669,28 @@ class model(watch_base): output = [] # Initialize as list since we're using append last_error = self.get('last_error','') + from flask import has_app_context, current_app - if last_error and '403' in last_error: - if has_proxies: - output.append(str(Markup(f"{last_error} - Try other proxies/location '"))) - else: - output.append(str(Markup(f"{last_error} - Try adding external proxies/locations '"))) + # has app+request context, we can use url_for() + if has_app_context: + if last_error: + if '403' in last_error: + if has_proxies: + output.append(str(Markup(f"{last_error} - Try other proxies/location '"))) + else: + output.append(str(Markup(f"{last_error} - Try adding external proxies/locations '"))) + else: + output.append(str(Markup(last_error))) - if self.get('last_notification_error'): - output.append(str(Markup(f"
{ self.get('last_notification_error') }
"))) + if self.get('last_notification_error'): + output.append(str(Markup(f"
{ self.get('last_notification_error') }
"))) + + else: + # Lo_Fi version + if last_error: + output.append(str(Markup(last_error))) + if self.get('last_notification_error'): + output.append(str(Markup(self.get('last_notification_error')))) res = "\n".join(output) return res diff --git a/changedetectionio/realtime/socket_server.py b/changedetectionio/realtime/socket_server.py index b5bb2376..38af70ba 100644 --- a/changedetectionio/realtime/socket_server.py +++ b/changedetectionio/realtime/socket_server.py @@ -1,6 +1,5 @@ import timeago from flask_socketio import SocketIO -from flask import has_app_context, current_app import time import os @@ -88,12 +87,11 @@ def handle_watch_update(socketio, **kwargs): queue_list.append(q_item.item['uuid']) error_texts = "" - if has_app_context(): # So anything with 'url_for' etc needs to be triggered with app_context of the current app when sending the signal # with app.app_context(): # watch_check_update.send(app_context=app, watch_uuid=uuid) - error_texts = watch.compile_error_texts() + error_texts = watch.compile_error_texts() # Create a simplified watch data object to send to clients watch_data = { @@ -114,7 +112,7 @@ def handle_watch_update(socketio, **kwargs): } socketio.emit("watch_update", watch_data) - logger.debug(f"Socket.IO: Emitted update for watch {watch.get('uuid')}, Checking now: {watch_data['checking_now']}") + logger.trace(f"Socket.IO: Emitted update for watch {watch.get('uuid')}, Checking now: {watch_data['checking_now']}") except Exception as e: logger.error(f"Socket.IO error in handle_watch_update: {str(e)}") diff --git a/changedetectionio/static/js/socket.js b/changedetectionio/static/js/socket.js index 91ce33df..ca3acc53 100644 --- a/changedetectionio/static/js/socket.js +++ b/changedetectionio/static/js/socket.js @@ -2,21 +2,24 @@ // @todo only bind ajax if the socket server attached success. $(document).ready(function () { - $('.ajax-op').click(function (e) { - e.preventDefault(); - $.ajax({ - type: "POST", - url: ajax_toggle_url, - data: {'op': $(this).data('op'), 'uuid': $(this).closest('tr').data('watch-uuid')}, - statusCode: { - 400: function () { - // More than likely the CSRF token was lost when the server restarted - alert("There was a problem processing the request, please reload the page."); + + function bindAjaxHandlerButtonsEvents() { + $('.ajax-op').on('click.ajaxHandlerNamespace', function (e) { + e.preventDefault(); + $.ajax({ + type: "POST", + url: ajax_toggle_url, + data: {'op': $(this).data('op'), 'uuid': $(this).closest('tr').data('watch-uuid')}, + statusCode: { + 400: function () { + // More than likely the CSRF token was lost when the server restarted + alert("There was a problem processing the request, please reload the page."); + } } - } + }); + return false; }); - return false; - }); + } // Only try to connect if authentication isn't required or user is authenticated @@ -35,10 +38,12 @@ $(document).ready(function () { // Connection status logging socket.on('connect', function () { console.log('Socket.IO connected'); + bindAjaxHandlerButtonsEvents(); }); socket.on('disconnect', function () { console.log('Socket.IO disconnected'); + $('.ajax-op').off('.ajaxHandlerNamespace') }); socket.on('queue_size', function (data) { @@ -56,11 +61,11 @@ $(document).ready(function () { $($watchRow).toggleClass('checking-now', watch.checking_now); $($watchRow).toggleClass('queued', watch.queued); $($watchRow).toggleClass('unviewed', watch.unviewed); - $($watchRow).toggleClass('error', watch.has_error); + $($watchRow).toggleClass('has-error', watch.has_error); $($watchRow).toggleClass('notification_muted', watch.notification_muted); $($watchRow).toggleClass('paused', watch.paused); - $('td.error-text', $watchRow).text(watch.error_text) + $('td.title-col .error-text', $watchRow).html(watch.error_text) $('td.last-changed', $watchRow).text(watch.last_checked_text) diff --git a/changedetectionio/static/styles/scss/parts/_watch_table.scss b/changedetectionio/static/styles/scss/parts/_watch_table.scss index 7552b558..bce774c0 100644 --- a/changedetectionio/static/styles/scss/parts/_watch_table.scss +++ b/changedetectionio/static/styles/scss/parts/_watch_table.scss @@ -7,11 +7,6 @@ &.unviewed { font-weight: bold; } - - &.error { - color: var(--color-watch-table-error); - } - color: var(--color-watch-table-row-text); } @@ -112,9 +107,11 @@ } } - tr.error { - .fetch-error { - display: inline-block !important; + + tr.has-error { + color: var(--color-watch-table-error); + .error-text { + display: block !important; } } } diff --git a/changedetectionio/static/styles/styles.css b/changedetectionio/static/styles/styles.css index 6af67500..380c6478 100644 --- a/changedetectionio/static/styles/styles.css +++ b/changedetectionio/static/styles/styles.css @@ -532,8 +532,6 @@ body.preview-text-enabled { color: var(--color-watch-table-row-text); } .watch-table tr.unviewed { font-weight: bold; } - .watch-table tr.error { - color: var(--color-watch-table-error); } .watch-table td { white-space: nowrap; } .watch-table td.title-col { @@ -577,8 +575,10 @@ body.preview-text-enabled { display: inline !important; } .watch-table tr.notification_muted a.mute-toggle.state-off { display: none !important; } - .watch-table tr.error .fetch-error { - display: inline-block !important; } + .watch-table tr.has-error { + color: var(--color-watch-table-error); } + .watch-table tr.has-error .error-text { + display: block !important; } ul#conditions_match_logic { list-style: none; }