pull/3183/head
dgtlmoon 2025-05-07 18:54:23 +02:00
rodzic 02de7e36e7
commit 1bd3068449
5 zmienionych plików z 84 dodań i 55 usunięć

Wyświetl plik

@ -103,6 +103,7 @@
{% set checking_now = is_checking_now(watch) %}
<tr id="{{ watch.uuid }}" data-watch-uuid="{{ watch.uuid }}"
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }} processor-{{ watch['processor'] }}
{# socket.js also sets these vars on the row for update #}
{% if watch.last_error is defined and watch.last_error != False %}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 %}
@ -189,11 +190,11 @@
</td>
{% endif %}
{#last_checked becomes fetch-start-time#}
<td class="last-checked" data-timestamp="{{ watch.last_checked }}" {% if checking_now %} data-fetchduration={{ watch.fetch_time }} data-eta_complete="{{ watch.last_checked+watch.fetch_time }}" {% endif %} >
<span style="display:none;" class="spinner"></span><span class="spinner-text" style="display:none;" >&nbsp;Checking now</span>
{{watch|format_last_checked_time|safe}}
<td class="last-checked" data-timestamp="{{ watch.last_checked }}" data-fetchduration={{ watch.fetch_time }} data-eta_complete="{{ watch.last_checked+watch.fetch_time }}" >
<div class="spinner-wrapper" style="display:none;" >
<span class="spinner"></span><span>&nbsp;Checking now</span>
</div>
<span class="innertext">{{watch|format_last_checked_time|safe}}</span>
</td>
@ -204,9 +205,9 @@
{% endif %}
</td>
<td>
<a {% if watch.uuid in queued_uuids %}disabled="true"{% endif %} href="{{ url_for('ui.form_watch_checknow', uuid=watch.uuid, tag=request.args.get('tag')) }}"
class="recheck pure-button pure-button-primary">{% if watch.uuid in queued_uuids %}Queued{% else %}Recheck{% endif %}</a>
<a href="" class="already-in-queue-button recheck pure-button pure-button-primary" style="display: none;" disabled="disabled">Queued</a>
<a href="{{ url_for('ui.form_watch_checknow', uuid=watch.uuid, tag=request.args.get('tag')) }}" class="recheck pure-button pure-button-primary">Recheck</a>
<a href="{{ url_for('ui.ui_edit.edit_page', uuid=watch.uuid, tag=active_tag_uuid)}}#general" class="pure-button pure-button-primary">Edit</a>
{% if watch.history_n >= 2 %}

Wyświetl plik

@ -1,3 +1,4 @@
import timeago
from flask import Flask
from flask_socketio import SocketIO
import threading
@ -94,15 +95,19 @@ class ChangeDetectionSocketIO:
if hasattr(q_item, 'item') and 'uuid' in q_item.item:
queue_list.append(q_item.item['uuid'])
# Create a simplified watch data object to send to clients
watch_data = {
'uuid': watch.get('uuid'),
'last_checked_text': _jinja2_filter_datetime(watch),
'last_checked': watch.get('last_checked'),
'last_changed': watch.get('last_changed'),
'queued': True if watch.get('uuid') in queue_list else False,
'checking_now': True if watch.get('uuid') in running_uuids else False,
'fetch_time': watch.get('fetch_time'),
'has_error': watch.get('last_error') or watch.get('last_notification_error'),
'last_changed': watch.get('last_changed'),
'last_checked': watch.get('last_checked'),
'last_checked_text': _jinja2_filter_datetime(watch),
'last_changed_text': timeago.format(int(watch['last_changed']), time.time()) if watch.history_n >=2 and int(watch.get('last_changed',0)) >0 else 'Not yet',
'queued': True if watch.get('uuid') in queue_list else False,
'unviewed': watch.has_unviewed,
'uuid': watch.get('uuid'),
}
self.socketio.emit("watch_update", watch_data)
logger.debug(f"Socket.IO: Emitted update for watch {watch.get('uuid')}")

Wyświetl plik

@ -1,50 +1,56 @@
// Socket.IO client-side integration for changedetection.io
$(document).ready(function() {
// Try to create the socket connection to port 5005 - if it fails, the site will still work normally
try {
// Connect to the dedicated Socket.IO server on port 5005
const socket = io('http://127.0.0.1:5005');
// Connection status logging
socket.on('connect', function() {
console.log('Socket.IO connected');
});
socket.on('disconnect', function() {
console.log('Socket.IO disconnected');
});
$(document).ready(function () {
// Try to create the socket connection to port 5005 - if it fails, the site will still work normally
try {
// Connect to the dedicated Socket.IO server on port 5005
const socket = io('http://127.0.0.1:5005');
socket.on('checking_now', function(uuid_list) {
console.log("Got checking now update");
// Remove 'checking-now' class where it should no longer be
$('.watch-table tbody tr.checking-now').each(function() {
if (!uuid_list.includes($(this).data('watch-uuid'))) {
$(this).removeClass('checking-now');
}
});
// Connection status logging
socket.on('connect', function () {
console.log('Socket.IO connected');
});
// Add the class on the rows where it should be
uuid_list.forEach(function(uuid) {
$('.watch-table tbody tr[data-watch-uuid="' + uuid + '"]').addClass('checking-now');
});
});
socket.on('disconnect', function () {
console.log('Socket.IO disconnected');
});
// Listen for periodically emitted watch data
socket.on('watch_update', function(watch) {
console.log(`Watch update ${watch.uuid}`);
socket.on('checking_now', function (uuid_list) {
console.log("Got checking now update");
// Remove 'checking-now' class where it should no longer be
$('.watch-table tbody tr.checking-now').each(function () {
if (!uuid_list.includes($(this).data('watch-uuid'))) {
$(this).removeClass('checking-now');
}
});
// Add the class on the rows where it should be
uuid_list.forEach(function (uuid) {
$('.watch-table tbody tr[data-watch-uuid="' + uuid + '"]').addClass('checking-now');
});
});
// Listen for periodically emitted watch data
socket.on('watch_update', function (watch) {
console.log(`Watch update ${watch.uuid}`);
const $watchRow = $('tr[data-watch-uuid="' + watch.uuid + '"]');
if ($watchRow.length) {
$($watchRow).toggleClass('checking-now', watch.checking_now);
$($watchRow).toggleClass('queued', watch.queued);
$($watchRow).toggleClass('unviewed', watch.unviewed);
}
});
const $watchRow = $('tr[data-watch-uuid="' + watch.uuid + '"]');
if ($watchRow.length) {
$($watchRow).toggleClass('checking-now', watch.checking_now);
$($watchRow).toggleClass('queued', watch.queued);
$($watchRow).toggleClass('unviewed', watch.unviewed);
$($watchRow).toggleClass('error', watch.has_error);
$('td.last-changed', $watchRow).text(watch.last_checked_text)
$('td.last-checked .innertext', $watchRow).text(watch.last_checked_text)
$('td.last-checked', $watchRow).data('timestamp', watch.last_checked).data('fetchduration', watch.fetch_time);
$('td.last-checked', $watchRow).data('eta_complete', watch.last_checked + watch.fetch_time);
} catch (e) {
// If Socket.IO fails to initialize, just log it and continue
console.log('Socket.IO initialization error:', e);
}
}
});
} catch (e) {
// If Socket.IO fails to initialize, just log it and continue
console.log('Socket.IO initialization error:', e);
}
});

Wyświetl plik

@ -52,9 +52,20 @@
/* Row with 'checking-now' */
tr.checking-now {
td.last-checked {
.spinner, .spinner-text {
.spinner-wrapper {
display: inline-block !important;
}
.innertext {
display: none !important;
}
}
}
tr.queued {
a.recheck {
display: none !important;
}
a.already-in-queue-button {
display: inline-block !important;
}
}
}

Wyświetl plik

@ -551,7 +551,13 @@ body.preview-text-enabled {
.watch-table .current-diff-url::after {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVR42qXKwQkAIAxDUUdxtO6/RBQkQZvSi8I/pL4BoGw/XPkh4XigPmsUgh0626AjRsgxHTkUThsG2T/sIlzdTsp52kSS1wAAAABJRU5ErkJggg==);
margin: 0 3px 0 5px; }
.watch-table tr.checking-now td.last-checked .spinner, .watch-table tr.checking-now td.last-checked .spinner-text {
.watch-table tr.checking-now td.last-checked .spinner-wrapper {
display: inline-block !important; }
.watch-table tr.checking-now td.last-checked .innertext {
display: none !important; }
.watch-table tr.queued a.recheck {
display: none !important; }
.watch-table tr.queued a.already-in-queue-button {
display: inline-block !important; }
ul#conditions_match_logic {