diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index f5a10283..13d576a4 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -355,6 +355,8 @@ class watchForm(commonSettingsForm): filter_failure_notification_send = BooleanField( 'Send a notification when the filter can no longer be found on the page', default=False) + notification_use_default = BooleanField('Use default/system notification settings', default=True) + def validate(self, **kwargs): if not super().validate(): return False diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index c59dd1da..b8e48196 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -35,6 +35,7 @@ class model(dict): 'notification_title': default_notification_title, 'notification_body': default_notification_body, 'notification_format': default_notification_format, + 'notification_use_default': True, # Use default for new 'notification_muted': False, 'css_filter': '', 'last_error': False, diff --git a/changedetectionio/static/js/watch-settings.js b/changedetectionio/static/js/watch-settings.js index b45ca95d..249f2e4c 100644 --- a/changedetectionio/static/js/watch-settings.js +++ b/changedetectionio/static/js/watch-settings.js @@ -1,7 +1,7 @@ -$(document).ready(function() { - function toggle() { +$(document).ready(function () { + function toggle_fetch_backend() { if ($('input[name="fetch_backend"]:checked').val() == 'html_webdriver') { - if(playwright_enabled) { + if (playwright_enabled) { // playwright supports headers, so hide everything else // See #664 $('#requests-override-options #request-method').hide(); @@ -13,12 +13,8 @@ $(document).ready(function() { // selenium/webdriver doesnt support anything afaik, hide it all $('#requests-override-options').hide(); } - - $('#webdriver-override-options').show(); - } else { - $('#requests-override-options').show(); $('#requests-override-options *:hidden').show(); $('#webdriver-override-options').hide(); @@ -26,8 +22,27 @@ $(document).ready(function() { } $('input[name="fetch_backend"]').click(function (e) { - toggle(); + toggle_fetch_backend(); }); - toggle(); + toggle_fetch_backend(); + function toggle_default_notifications() { + var n=$('#notification_urls, #notification_title, #notification_body, #notification_format'); + if ($('#notification_use_default').is(':checked')) { + $('#notification-field-group').fadeOut(); + $(n).each(function (e) { + $(this).attr('readonly', true); + }); + } else { + $('#notification-field-group').show(); + $(n).each(function (e) { + $(this).attr('readonly', false); + }); + } + } + + $('#notification_use_default').click(function (e) { + toggle_default_notifications(); + }); + toggle_default_notifications(); }); diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 80cac7a4..01b40b4d 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -535,4 +535,28 @@ class ChangeDetectionStore: del(watch['last_changed']) except: continue + return + + + def update_5(self): + + from changedetectionio.notification import ( + default_notification_body, + default_notification_format, + default_notification_title, + ) + + for uuid, watch in self.data['watching'].items(): + try: + # If it's all the same to the system settings, then prefer system notification settings + # include \r\n -> \n incase they already hit submit and the browser put \r in + if watch.get('notification_body').replace('\r\n', '\n') == default_notification_body.replace('\r\n', '\n') and \ + watch.get('notification_format') == default_notification_format and \ + watch.get('notification_title').replace('\r\n', '\n') == default_notification_title.replace('\r\n', '\n') and \ + watch.get('notification_urls') == self.__data['settings']['application']['notification_urls']: + watch['notification_use_default'] = True + else: + watch['notification_use_default'] = False + except: + continue return \ No newline at end of file diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 1d18c4d8..47cb7815 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -135,9 +135,11 @@ User-Agent: wonderbra 1.0") }}