WIP
This commit is contained in:
@@ -105,8 +105,7 @@
|
|||||||
<tr id="{{ watch.uuid }}" data-watch-uuid="{{ watch.uuid }}"
|
<tr id="{{ watch.uuid }}" data-watch-uuid="{{ watch.uuid }}"
|
||||||
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }} processor-{{ watch['processor'] }}
|
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }} processor-{{ watch['processor'] }}
|
||||||
{# socket.js also sets these vars on the row for update #}
|
{# socket.js also sets these vars on the row for update #}
|
||||||
{% if watch.render_errors_as_text %}has-error{% endif %}
|
{% if watch.compile_error_texts()|length >2 %}has-error{% endif %}
|
||||||
{% if watch.last_notification_error is defined and watch.last_notification_error != False %}error{% endif %}
|
|
||||||
{% if watch.paused is defined and watch.paused != False %}paused{% endif %}
|
{% if watch.paused is defined and watch.paused != False %}paused{% endif %}
|
||||||
{% if watch.has_unviewed %}unviewed{% endif %}
|
{% if watch.has_unviewed %}unviewed{% endif %}
|
||||||
{% if watch.has_restock_info %} has-restock-info {% if watch['restock']['in_stock'] %}in-stock{% else %}not-in-stock{% endif %} {% else %}no-restock-info{% endif %}
|
{% if watch.has_restock_info %} has-restock-info {% if watch['restock']['in_stock'] %}in-stock{% else %}not-in-stock{% endif %} {% else %}no-restock-info{% endif %}
|
||||||
@@ -133,10 +132,10 @@
|
|||||||
<img class="status-icon" src="{{url_for('static_content', group='images', filename='google-chrome-icon.png')}}" alt="Using a Chrome browser" title="Using a Chrome browser" >
|
<img class="status-icon" src="{{url_for('static_content', group='images', filename='google-chrome-icon.png')}}" alt="Using a Chrome browser" title="Using a Chrome browser" >
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%if watch.is_pdf %}<img class="status-icon" src="{{url_for('static_content', group='images', filename='pdf-icon.svg')}}" alt="Converting PDF to text" >{% endif %}
|
{% if watch.is_pdf %}<img class="status-icon" src="{{url_for('static_content', group='images', filename='pdf-icon.svg')}}" alt="Converting PDF to text" >{% endif %}
|
||||||
{% if watch.has_browser_steps %}<img class="status-icon status-browsersteps" src="{{url_for('static_content', group='images', filename='steps.svg')}}" alt="Browser Steps is enabled" >{% endif %}
|
{% if watch.has_browser_steps %}<img class="status-icon status-browsersteps" src="{{url_for('static_content', group='images', filename='steps.svg')}}" alt="Browser Steps is enabled" >{% endif %}
|
||||||
|
|
||||||
<div class="error-text">{{ watch.compile_error_texts(has_proxies=datastore.proxy_list)|safe }}</div>
|
<div class="error-text" style="display:none;">{{ watch.compile_error_texts(has_proxies=datastore.proxy_list)|safe }}</div>
|
||||||
|
|
||||||
{% if watch['processor'] == 'text_json_diff' %}
|
{% if watch['processor'] == 'text_json_diff' %}
|
||||||
{% if watch['has_ldjson_price_data'] and not watch['track_ldjson_price_data'] %}
|
{% if watch['has_ldjson_price_data'] and not watch['track_ldjson_price_data'] %}
|
||||||
|
|||||||
@@ -669,15 +669,28 @@ class model(watch_base):
|
|||||||
|
|
||||||
output = [] # Initialize as list since we're using append
|
output = [] # Initialize as list since we're using append
|
||||||
last_error = self.get('last_error','')
|
last_error = self.get('last_error','')
|
||||||
|
from flask import has_app_context, current_app
|
||||||
|
|
||||||
if last_error and '403' in last_error:
|
# has app+request context, we can use url_for()
|
||||||
if has_proxies:
|
if has_app_context:
|
||||||
output.append(str(Markup(f"{last_error} - <a href=\"{url_for('settings.settings_page', uuid=self.get('uuid'))}\">Try other proxies/location</a> '")))
|
if last_error:
|
||||||
else:
|
if '403' in last_error:
|
||||||
output.append(str(Markup(f"{last_error} - <a href=\"{url_for('settings.settings_page', uuid=self.get('uuid'))}\">Try adding external proxies/locations</a> '")))
|
if has_proxies:
|
||||||
|
output.append(str(Markup(f"{last_error} - <a href=\"{url_for('settings.settings_page', uuid=self.get('uuid'))}\">Try other proxies/location</a> '")))
|
||||||
|
else:
|
||||||
|
output.append(str(Markup(f"{last_error} - <a href=\"{url_for('settings.settings_page', uuid=self.get('uuid'))}\">Try adding external proxies/locations</a> '")))
|
||||||
|
else:
|
||||||
|
output.append(str(Markup(last_error)))
|
||||||
|
|
||||||
if self.get('last_notification_error'):
|
if self.get('last_notification_error'):
|
||||||
output.append(str(Markup(f"<div class=\"notification-error\"><a href=\"{url_for('settings.notification_logs')}\">{ self.get('last_notification_error') }</a></div>")))
|
output.append(str(Markup(f"<div class=\"notification-error\"><a href=\"{url_for('settings.notification_logs')}\">{ self.get('last_notification_error') }</a></div>")))
|
||||||
|
|
||||||
|
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)
|
res = "\n".join(output)
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import timeago
|
import timeago
|
||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
from flask import has_app_context, current_app
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
@@ -88,12 +87,11 @@ def handle_watch_update(socketio, **kwargs):
|
|||||||
queue_list.append(q_item.item['uuid'])
|
queue_list.append(q_item.item['uuid'])
|
||||||
|
|
||||||
error_texts = ""
|
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
|
# 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():
|
# with app.app_context():
|
||||||
# watch_check_update.send(app_context=app, watch_uuid=uuid)
|
# 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
|
# Create a simplified watch data object to send to clients
|
||||||
watch_data = {
|
watch_data = {
|
||||||
@@ -114,7 +112,7 @@ def handle_watch_update(socketio, **kwargs):
|
|||||||
}
|
}
|
||||||
|
|
||||||
socketio.emit("watch_update", watch_data)
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Socket.IO error in handle_watch_update: {str(e)}")
|
logger.error(f"Socket.IO error in handle_watch_update: {str(e)}")
|
||||||
|
|||||||
@@ -2,21 +2,24 @@
|
|||||||
// @todo only bind ajax if the socket server attached success.
|
// @todo only bind ajax if the socket server attached success.
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('.ajax-op').click(function (e) {
|
|
||||||
e.preventDefault();
|
function bindAjaxHandlerButtonsEvents() {
|
||||||
$.ajax({
|
$('.ajax-op').on('click.ajaxHandlerNamespace', function (e) {
|
||||||
type: "POST",
|
e.preventDefault();
|
||||||
url: ajax_toggle_url,
|
$.ajax({
|
||||||
data: {'op': $(this).data('op'), 'uuid': $(this).closest('tr').data('watch-uuid')},
|
type: "POST",
|
||||||
statusCode: {
|
url: ajax_toggle_url,
|
||||||
400: function () {
|
data: {'op': $(this).data('op'), 'uuid': $(this).closest('tr').data('watch-uuid')},
|
||||||
// More than likely the CSRF token was lost when the server restarted
|
statusCode: {
|
||||||
alert("There was a problem processing the request, please reload the page.");
|
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
|
// Only try to connect if authentication isn't required or user is authenticated
|
||||||
@@ -35,10 +38,12 @@ $(document).ready(function () {
|
|||||||
// Connection status logging
|
// Connection status logging
|
||||||
socket.on('connect', function () {
|
socket.on('connect', function () {
|
||||||
console.log('Socket.IO connected');
|
console.log('Socket.IO connected');
|
||||||
|
bindAjaxHandlerButtonsEvents();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('disconnect', function () {
|
socket.on('disconnect', function () {
|
||||||
console.log('Socket.IO disconnected');
|
console.log('Socket.IO disconnected');
|
||||||
|
$('.ajax-op').off('.ajaxHandlerNamespace')
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('queue_size', function (data) {
|
socket.on('queue_size', function (data) {
|
||||||
@@ -56,11 +61,11 @@ $(document).ready(function () {
|
|||||||
$($watchRow).toggleClass('checking-now', watch.checking_now);
|
$($watchRow).toggleClass('checking-now', watch.checking_now);
|
||||||
$($watchRow).toggleClass('queued', watch.queued);
|
$($watchRow).toggleClass('queued', watch.queued);
|
||||||
$($watchRow).toggleClass('unviewed', watch.unviewed);
|
$($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('notification_muted', watch.notification_muted);
|
||||||
$($watchRow).toggleClass('paused', watch.paused);
|
$($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)
|
$('td.last-changed', $watchRow).text(watch.last_checked_text)
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,6 @@
|
|||||||
&.unviewed {
|
&.unviewed {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.error {
|
|
||||||
color: var(--color-watch-table-error);
|
|
||||||
}
|
|
||||||
|
|
||||||
color: var(--color-watch-table-row-text);
|
color: var(--color-watch-table-row-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,9 +107,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.error {
|
|
||||||
.fetch-error {
|
tr.has-error {
|
||||||
display: inline-block !important;
|
color: var(--color-watch-table-error);
|
||||||
|
.error-text {
|
||||||
|
display: block !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,8 +532,6 @@ body.preview-text-enabled {
|
|||||||
color: var(--color-watch-table-row-text); }
|
color: var(--color-watch-table-row-text); }
|
||||||
.watch-table tr.unviewed {
|
.watch-table tr.unviewed {
|
||||||
font-weight: bold; }
|
font-weight: bold; }
|
||||||
.watch-table tr.error {
|
|
||||||
color: var(--color-watch-table-error); }
|
|
||||||
.watch-table td {
|
.watch-table td {
|
||||||
white-space: nowrap; }
|
white-space: nowrap; }
|
||||||
.watch-table td.title-col {
|
.watch-table td.title-col {
|
||||||
@@ -577,8 +575,10 @@ body.preview-text-enabled {
|
|||||||
display: inline !important; }
|
display: inline !important; }
|
||||||
.watch-table tr.notification_muted a.mute-toggle.state-off {
|
.watch-table tr.notification_muted a.mute-toggle.state-off {
|
||||||
display: none !important; }
|
display: none !important; }
|
||||||
.watch-table tr.error .fetch-error {
|
.watch-table tr.has-error {
|
||||||
display: inline-block !important; }
|
color: var(--color-watch-table-error); }
|
||||||
|
.watch-table tr.has-error .error-text {
|
||||||
|
display: block !important; }
|
||||||
|
|
||||||
ul#conditions_match_logic {
|
ul#conditions_match_logic {
|
||||||
list-style: none; }
|
list-style: none; }
|
||||||
|
|||||||
Reference in New Issue
Block a user