kopia lustrzana https://github.com/dgtlmoon/changedetection.io
UI - Conditions - Offer some information about what the filter/condition/trigger saw (#3062)
rodzic
6c1b687cd1
commit
54b7c070f7
|
@ -116,8 +116,7 @@ def execute_ruleset_against_all_plugins(current_watch_uuid: str, application_dat
|
||||||
if not jsonLogic(logic=ruleset, data=EXECUTE_DATA, operations=CUSTOM_OPERATIONS):
|
if not jsonLogic(logic=ruleset, data=EXECUTE_DATA, operations=CUSTOM_OPERATIONS):
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
return result
|
return {'executed_data': EXECUTE_DATA, 'result': result}
|
||||||
|
|
||||||
|
|
||||||
# Load plugins dynamically
|
# Load plugins dynamically
|
||||||
for plugin in plugin_manager.get_plugins():
|
for plugin in plugin_manager.get_plugins():
|
||||||
|
|
|
@ -67,7 +67,8 @@ def construct_blueprint(datastore):
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'success',
|
'status': 'success',
|
||||||
'result': result,
|
'result': result.get('result'),
|
||||||
|
'data': result.get('executed_data'),
|
||||||
'message': 'Condition passes' if result else 'Condition does not pass'
|
'message': 'Condition passes' if result else 'Condition does not pass'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -334,12 +334,14 @@ class perform_site_check(difference_detection_processor):
|
||||||
|
|
||||||
# And check if 'conditions' will let this pass through
|
# And check if 'conditions' will let this pass through
|
||||||
if watch.get('conditions') and watch.get('conditions_match_logic'):
|
if watch.get('conditions') and watch.get('conditions_match_logic'):
|
||||||
if not execute_ruleset_against_all_plugins(current_watch_uuid=watch.get('uuid'),
|
conditions_result = execute_ruleset_against_all_plugins(current_watch_uuid=watch.get('uuid'),
|
||||||
application_datastruct=self.datastore.data,
|
application_datastruct=self.datastore.data,
|
||||||
ephemeral_data={
|
ephemeral_data={
|
||||||
'text': stripped_text_from_html
|
'text': stripped_text_from_html
|
||||||
}
|
}
|
||||||
):
|
)
|
||||||
|
|
||||||
|
if not conditions_result.get('result'):
|
||||||
# Conditions say "Condition not met" so we block it.
|
# Conditions say "Condition not met" so we block it.
|
||||||
blocked = True
|
blocked = True
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
|
|
||||||
// Create a rule object
|
// Create a rule object
|
||||||
const rule = {
|
let rule = {
|
||||||
field: field,
|
field: field,
|
||||||
operator: operator,
|
operator: operator,
|
||||||
value: value
|
value: value
|
||||||
|
@ -96,6 +96,10 @@ $(document).ready(function () {
|
||||||
contentType: false, // Let the browser set the correct content type
|
contentType: false, // Let the browser set the correct content type
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
if (response.status === "success") {
|
if (response.status === "success") {
|
||||||
|
if(rule['field'] !== "page_filtered_text") {
|
||||||
|
// A little debug helper for the user
|
||||||
|
$('#verify-state-text').text(`${rule['field']} was value "${response.data[rule['field']]}"`)
|
||||||
|
}
|
||||||
if (response.result) {
|
if (response.result) {
|
||||||
alert("✅ Condition PASSES verification against current snapshot!");
|
alert("✅ Condition PASSES verification against current snapshot!");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -305,8 +305,8 @@ Math: {{ 1 + 1 }}") }}
|
||||||
{{ render_field(form.conditions_match_logic) }}
|
{{ render_field(form.conditions_match_logic) }}
|
||||||
{{ render_fieldlist_of_formfields_as_table(form.conditions) }}
|
{{ render_fieldlist_of_formfields_as_table(form.conditions) }}
|
||||||
<div class="pure-form-message-inline">
|
<div class="pure-form-message-inline">
|
||||||
<br>
|
|
||||||
Use the verify (✓) button to test if a condition passes against the current snapshot.<br><br>
|
<p id="verify-state-text">Use the verify (✓) button to test if a condition passes against the current snapshot.</p>
|
||||||
Did you know that <strong>conditions</strong> can be extended with your own custom plugin? tutorials coming soon!<br>
|
Did you know that <strong>conditions</strong> can be extended with your own custom plugin? tutorials coming soon!<br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -75,7 +75,7 @@ class TestTriggerConditions(unittest.TestCase):
|
||||||
ephemeral_data={'text': "I saw 500 people at a rock show"})
|
ephemeral_data={'text': "I saw 500 people at a rock show"})
|
||||||
|
|
||||||
# @todo - now we can test that 'Extract number' increased more than X since last time
|
# @todo - now we can test that 'Extract number' increased more than X since last time
|
||||||
self.assertTrue(result)
|
self.assertTrue(result.get('result'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Ładowanie…
Reference in New Issue