Visual Selector - Small fix, Improving elements fetcher reliability (#1947)

pull/1956/head
dgtlmoon 1 year ago committed by GitHub
parent f9f69bf0dd
commit 99246d3e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1208,8 +1208,7 @@ def changedetection_app(config=None, datastore_o=None):
# These files should be in our subdirectory # These files should be in our subdirectory
try: try:
# set nocache, set content-type # set nocache, set content-type
watch_dir = datastore_o.datastore_path + "/" + filename response = make_response(send_from_directory(os.path.join(datastore_o.datastore_path, filename), "elements.json"))
response = make_response(send_from_directory(filename="elements.json", directory=watch_dir, path=watch_dir + "/elements.json"))
response.headers['Content-type'] = 'application/json' response.headers['Content-type'] = 'application/json'
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
response.headers['Pragma'] = 'no-cache' response.headers['Pragma'] = 'no-cache'

@ -54,6 +54,13 @@ def test_visual_selector_content_ready(client, live_server):
with open(os.path.join('test-datastore', uuid, 'elements.json'), 'r') as f: with open(os.path.join('test-datastore', uuid, 'elements.json'), 'r') as f:
json.load(f) json.load(f)
# Attempt to fetch it via the web hook that the browser would use
res = client.get(url_for('static_content', group='visual_selector_data', filename=uuid))
json.loads(res.data)
assert res.mimetype == 'application/json'
assert res.status_code == 200
# Some options should be enabled # Some options should be enabled
# @todo - in the future, the visibility should be toggled by JS from the request type setting # @todo - in the future, the visibility should be toggled by JS from the request type setting
res = client.get( res = client.get(

Loading…
Cancel
Save