Compare commits

..

5 Commits

Author SHA1 Message Date
dgtlmoon
51a0306d05 Add diff view option for JSON compare (comparing the fields defined on each. The order of fields, etc does not matter in this comparison.) 2022-11-19 15:15:25 +01:00
dgtlmoon
216f93edf5 Fix time handling 2022-11-19 14:47:58 +01:00
dgtlmoon
1efb001a63 Make checkbox work 2022-11-19 14:44:51 +01:00
dgtlmoon
2a15365e30 Move diff handler to its own JS to make it easier to manage 2022-11-19 14:17:30 +01:00
dgtlmoon
7d29c4799c Update and rename diff.js 2022-11-19 13:42:52 +01:00
10 changed files with 24 additions and 39 deletions

View File

@@ -375,7 +375,6 @@ class watchForm(commonSettingsForm):
'Send a notification when the filter can no longer be found on the page', default=False)
notification_muted = BooleanField('Notifications Muted / Off', default=False)
notification_screenshot = BooleanField('Attach screenshot to notification (where possible)', default=False)
def validate(self, **kwargs):
if not super().validate():

View File

@@ -38,7 +38,6 @@ class model(dict):
'notification_format': default_notification_format_for_watch,
'notification_muted': False,
'notification_title': None,
'notification_screenshot': False, # Include the latest screenshot if available and supported by the apprise URL
'notification_urls': [], # List of URLs to add to the notification Queue (Usually AppRise)
'paused': False,
'previous_md5': False,

View File

@@ -101,10 +101,7 @@ def process_notification(n_object, datastore):
apobj.notify(
title=n_title,
body=n_body,
body_format=n_format,
# False is not an option for AppRise, must be type None
attach=None if not n_object.get('screenshot') else n_object.get('screenshot')
)
body_format=n_format)
apobj.clear()

View File

@@ -13,7 +13,7 @@ $(document).ready(function() {
// redline highlight context
var ctx;
var current_default_xpath=[];
var current_default_xpath;
var x_scale=1;
var y_scale=1;
var selector_image;
@@ -57,6 +57,7 @@ $(document).ready(function() {
bootstrap_visualselector();
function bootstrap_visualselector() {
if ( 1 ) {
// bootstrap it, this will trigger everything else
@@ -67,11 +68,7 @@ $(document).ready(function() {
xctx = c.getContext("2d");
// redline highlight context
ctx = c.getContext("2d");
if ($("#include_filters").val().trim().length) {
current_default_xpath =$("#include_filters").val().split(/\r?\n/g);
} else {
current_default_xpath = [];
}
fetch_data();
$('#selector-canvas').off("mousemove mousedown");
// screenshot_url defined in the edit.html template

View File

@@ -141,9 +141,6 @@ User-Agent: wonderbra 1.0") }}
<div class="pure-control-group inline-radio">
{{ render_checkbox_field(form.notification_muted) }}
</div>
<div class="pure-control-group inline-radio">
{{ render_checkbox_field(form.notification_screenshot) }}
</div>
<div class="field-group" id="notification-field-group">
{% if has_default_notification_urls %}
<div class="inline-warning">

View File

@@ -19,7 +19,6 @@ def test_basic_auth(client, live_server):
follow_redirects=True
)
assert b"1 Imported" in res.data
time.sleep(1)
# Check form validation
res = client.post(
@@ -29,6 +28,8 @@ def test_basic_auth(client, live_server):
)
assert b"Updated watch." in res.data
# Trigger a check
client.get(url_for("form_watch_checknow"), follow_redirects=True)
time.sleep(1)
res = client.get(
url_for("preview_page", uuid="first"),

View File

@@ -89,6 +89,9 @@ def test_check_markup_include_filters_restriction(client, live_server):
)
assert b"1 Imported" in res.data
# Trigger a check
client.get(url_for("form_watch_checknow"), follow_redirects=True)
# Give the thread time to pick it up
time.sleep(sleep_time_for_fetch_thread)
@@ -100,13 +103,16 @@ def test_check_markup_include_filters_restriction(client, live_server):
follow_redirects=True
)
assert b"Updated watch." in res.data
time.sleep(1)
# Check it saved
res = client.get(
url_for("edit_page", uuid="first"),
)
assert bytes(include_filters.encode('utf-8')) in res.data
# Trigger a check
client.get(url_for("form_watch_checknow"), follow_redirects=True)
# Give the thread time to pick it up
time.sleep(sleep_time_for_fetch_thread)
# Make a change

View File

@@ -70,6 +70,9 @@ def test_check_encoding_detection_missing_content_type_header(client, live_serve
follow_redirects=True
)
# Trigger a check
client.get(url_for("form_watch_checknow"), follow_redirects=True)
# Give the thread time to pick it up
time.sleep(2)

View File

@@ -3,9 +3,7 @@ import time
import re
from flask import url_for
from . util import set_original_response, set_modified_response, set_more_modified_response, live_server_setup
from . util import extract_UUID_from_client
import logging
import base64
from changedetectionio.notification import (
default_notification_body,
@@ -70,14 +68,6 @@ def test_check_notification(client, live_server):
# Give the thread time to pick up the first version
time.sleep(3)
testimage = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
# Write the last screenshot png
uuid = extract_UUID_from_client(client)
datastore = 'test-datastore'
with open(os.path.join(datastore, str(uuid), 'last-screenshot.png'), 'wb') as f:
f.write(base64.b64decode(testimage))
# Goto the edit page, add our ignore text
# Add our URL to the import page
@@ -96,7 +86,6 @@ def test_check_notification(client, live_server):
"Diff: {diff}\n"
"Diff Full: {diff_full}\n"
":-)",
"notification_screenshot": True,
"notification_format": "Text"}
notification_form_data.update({
@@ -153,7 +142,6 @@ def test_check_notification(client, live_server):
assert "preview/" in notification_submission
assert ":-)" in notification_submission
assert "New ChangeDetection.io Notification - {}".format(test_url) in notification_submission
assert testimage in notification_submission
if env_base_url:
# Re #65 - did we see our BASE_URl ?

View File

@@ -74,7 +74,6 @@ class update_worker(threading.Thread):
n_object.update({
'watch_url': watch['url'],
'uuid': watch_uuid,
'screenshot': watch.get_screenshot() if watch.get('notification_screenshot') else False,
'current_snapshot': snapshot_contents.decode('utf-8'),
'diff': diff.render_diff(watch_history[dates[-2]], watch_history[dates[-1]], line_feed_sep=line_feed_sep),
'diff_full': diff.render_diff(watch_history[dates[-2]], watch_history[dates[-1]], True, line_feed_sep=line_feed_sep)
@@ -107,8 +106,7 @@ class update_worker(threading.Thread):
if 'notification_urls' in n_object:
n_object.update({
'watch_url': watch['url'],
'uuid': watch_uuid,
'screenshot': False
'uuid': watch_uuid
})
self.notification_q.put(n_object)
print("Sent filter not found notification for {}".format(watch_uuid))