diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 52aa491c..7b25a5c8 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -417,9 +417,10 @@ def changedetection_app(config=None, datastore_o=None): return make_response({'error': 'No Notification URLs set'}, 400) for server_url in request.form['notification_urls'].splitlines(): - if not apobj.add(server_url): - message = '{} is not a valid AppRise URL.'.format(server_url) - return make_response({'error': message}, 400) + if len(server_url.strip()): + if not apobj.add(server_url): + message = '{} is not a valid AppRise URL.'.format(server_url) + return make_response({'error': message}, 400) try: n_object = {'watch_url': request.form['window_url'], @@ -620,7 +621,8 @@ def changedetection_app(config=None, datastore_o=None): watch=datastore.data['watching'][uuid], form=form, using_default_minutes=using_default_minutes, - current_base_url = datastore.data['settings']['application']['base_url'] + current_base_url=datastore.data['settings']['application']['base_url'], + emailprefix=os.getenv('NOTIFICATION_MAIL_BUTTON_PREFIX', False) ) return output @@ -685,7 +687,8 @@ def changedetection_app(config=None, datastore_o=None): output = render_template("settings.html", form=form, current_base_url = datastore.data['settings']['application']['base_url'], - hide_remove_pass=os.getenv("SALTED_PASS", False)) + hide_remove_pass=os.getenv("SALTED_PASS", False), + emailprefix=os.getenv('NOTIFICATION_MAIL_BUTTON_PREFIX', False)) return output diff --git a/changedetectionio/static/js/notifications.js b/changedetectionio/static/js/notifications.js index 2dd09dec..4f43f286 100644 --- a/changedetectionio/static/js/notifications.js +++ b/changedetectionio/static/js/notifications.js @@ -1,4 +1,15 @@ $(document).ready(function() { + + $('#add-email-helper').click(function (e) { + e.preventDefault(); + email = prompt("Destination email"); + if(email) { + var n = $("#notification_urls"); + var p=email_notification_prefix; + $(n).val( $.trim( $(n).val() )+"\n"+email_notification_prefix+email ); + } + }); + $('#send-test-notification').click(function (e) { e.preventDefault(); diff --git a/changedetectionio/templates/_common_fields.jinja b/changedetectionio/templates/_common_fields.jinja index c4ae0506..b18e30b4 100644 --- a/changedetectionio/templates/_common_fields.jinja +++ b/changedetectionio/templates/_common_fields.jinja @@ -1,7 +1,7 @@ {% from '_helpers.jinja' import render_field %} -{% macro render_common_settings_form(form, current_base_url) %} +{% macro render_common_settings_form(form, current_base_url, emailprefix) %}
{{ render_field(form.notification_urls, rows=5, placeholder="Examples: @@ -20,6 +20,10 @@

Send test notification +{% if emailprefix %} + Add email + +{% endif %}
diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index c82fff21..7229c52f 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -4,10 +4,13 @@ {% from '_helpers.jinja' import render_button %} {% from '_common_fields.jinja' import render_common_settings_form %} - +
@@ -96,7 +99,7 @@ User-Agent: wonderbra 1.0") }} Note: These settings override the global settings for this watch.
- {{ render_common_settings_form(form, current_base_url) }} + {{ render_common_settings_form(form, current_base_url, emailprefix) }}
diff --git a/changedetectionio/templates/settings.html b/changedetectionio/templates/settings.html index 8e0bd48c..fac9da3a 100644 --- a/changedetectionio/templates/settings.html +++ b/changedetectionio/templates/settings.html @@ -3,13 +3,16 @@ {% block content %} {% from '_helpers.jinja' import render_field, render_button %} {% from '_common_fields.jinja' import render_common_settings_form %} - + - +
    @@ -65,7 +68,7 @@
    - {{ render_common_settings_form(form, current_base_url) }} + {{ render_common_settings_form(form, current_base_url, emailprefix) }}
    Notification debug logs