Compare commits

..

6 Commits

Author SHA1 Message Date
dgtlmoon
08c9b55e0f Attempt to save last data retrieved- WIP 2022-08-24 09:33:14 +02:00
dgtlmoon
67d2441334 0.39.18 2022-08-19 11:37:26 +02:00
dgtlmoon
3c30bc02d5 More data saving pre-checks (#863) 2022-08-18 23:25:23 +02:00
dgtlmoon
dcb54117d5 Update screenshot 2022-08-18 15:29:34 +02:00
dgtlmoon
b1e32275dc Checkbox operations - reorder buttons for safety 2022-08-18 15:10:05 +02:00
dgtlmoon
e2a6865932 UI feature - Basic checkbox/group operations (#861) 2022-08-18 14:48:21 +02:00
6 changed files with 24 additions and 4 deletions

View File

@@ -44,7 +44,7 @@ from flask_wtf import CSRFProtect
from changedetectionio import html_tools
from changedetectionio.api import api_v1
__version__ = '0.39.17.2'
__version__ = '0.39.18'
datastore = None

View File

@@ -15,6 +15,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
class perform_site_check():
screenshot = None
xpath_data = None
fetched_response = None
def __init__(self, *args, datastore, **kwargs):
super().__init__(*args, **kwargs)
@@ -131,6 +132,7 @@ class perform_site_check():
self.screenshot = fetcher.screenshot
self.xpath_data = fetcher.xpath_data
self.fetched_response = fetcher.content
# Fetching complete, now filters
# @todo move to class / maybe inside of fetcher abstract base?

View File

@@ -341,6 +341,8 @@ class ChangeDetectionStore:
# Save as PNG, PNG is larger but better for doing visual diff in the future
def save_screenshot(self, watch_uuid, screenshot: bytes, as_error=False):
if not self.data['watching'].get(watch_uuid):
return
if as_error:
target_path = os.path.join(self.datastore_path, watch_uuid, "last-error-screenshot.png")
@@ -354,14 +356,16 @@ class ChangeDetectionStore:
f.close()
def save_error_text(self, watch_uuid, contents):
if not self.data['watching'].get(watch_uuid):
return
target_path = os.path.join(self.datastore_path, watch_uuid, "last-error.txt")
with open(target_path, 'w') as f:
f.write(contents)
def save_xpath_data(self, watch_uuid, data, as_error=False):
if not self.data['watching'].get(watch_uuid):
return
if as_error:
target_path = os.path.join(self.datastore_path, watch_uuid, "elements-error.json")
else:
@@ -371,6 +375,17 @@ class ChangeDetectionStore:
f.write(json.dumps(data))
f.close()
# Save whatever was returned from the fetcher
def save_last_response(self, watch_uuid, data):
if not self.data['watching'].get(watch_uuid):
return
target_path = os.path.join(self.datastore_path, watch_uuid, "last-response.bin")
# mimetype? binary? text? @todo
# gzip if its non-binary? auto get encoding?
with open(target_path, 'wb') as f:
f.write(data)
f.close()
def sync_to_json(self):
logging.info("Saving JSON..")

View File

@@ -28,9 +28,9 @@
<form class="pure-form" action="{{ url_for('form_watch_list_checkbox_operations') }}" method="POST" id="watch-list-form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<div id="checkbox-operations">
<button class="pure-button button-secondary button-xsmall" style="background: #dd4242; font-size: 70%" name="op" value="delete">Delete</button>
<button class="pure-button button-secondary button-xsmall" style="font-size: 70%" name="op" value="pause">Pause</button>
<button class="pure-button button-secondary button-xsmall" style="font-size: 70%" name="op" value="unpause">UnPause</button>
<button class="pure-button button-secondary button-xsmall" style="background: #dd4242; font-size: 70%" name="op" value="delete">Delete</button>
</div>
<div>
<a href="{{url_for('index')}}" class="pure-button button-tag {{'active' if not active_tag }}">All</a>

View File

@@ -286,6 +286,9 @@ class update_worker(threading.Thread):
self.datastore.save_screenshot(watch_uuid=uuid, screenshot=update_handler.screenshot)
if update_handler.xpath_data:
self.datastore.save_xpath_data(watch_uuid=uuid, data=update_handler.xpath_data)
if update_handler.fetched_response:
# @todo mimetype?
self.datastore.save_last_response(watch_uuid=uuid, data=update_handler.fetched_response)
self.current_uuid = None # Done

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 209 KiB