diff --git a/changedetectionio/.gitignore b/changedetectionio/.gitignore index 1d463784..0d3c1d4e 100644 --- a/changedetectionio/.gitignore +++ b/changedetectionio/.gitignore @@ -1 +1,2 @@ test-datastore +package-lock.json diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 2b10ace3..da08d12e 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -580,6 +580,9 @@ def changedetection_app(config=None, datastore_o=None): if request.method == 'POST' and form.validate(): extra_update_obj = {} + if request.args.get('unpause_on_save'): + extra_update_obj['paused'] = False + # Re #110, if they submit the same as the default value, set it to None, so we continue to follow the default # Assume we use the default value, unless something relevant is different, then use the form value # values could be None, 0 etc. @@ -619,7 +622,10 @@ def changedetection_app(config=None, datastore_o=None): datastore.data['watching'][uuid].update(form.data) datastore.data['watching'][uuid].update(extra_update_obj) - flash("Updated watch.") + if request.args.get('unpause_on_save'): + flash("Updated watch - unpaused!.") + else: + flash("Updated watch.") # Re #286 - We wait for syncing new data to disk in another thread every 60 seconds # But in the case something is added we should save straight away @@ -1063,9 +1069,9 @@ def changedetection_app(config=None, datastore_o=None): except FileNotFoundError: abort(404) - @app.route("/api/add", methods=['POST']) + @app.route("/form/add/quickwatch", methods=['POST']) @login_required - def form_watch_add(): + def form_quick_watch_add(): from changedetectionio import forms form = forms.quickWatchForm(request.form) @@ -1078,13 +1084,19 @@ def changedetection_app(config=None, datastore_o=None): flash('The URL {} already exists'.format(url), "error") return redirect(url_for('index')) - # @todo add_watch should throw a custom Exception for validation etc - new_uuid = datastore.add_watch(url=url, tag=request.form.get('tag').strip()) - if new_uuid: + add_paused = request.form.get('edit_and_watch_submit_button') != None + new_uuid = datastore.add_watch(url=url, tag=request.form.get('tag').strip(), extras={'paused': add_paused}) + + + if not add_paused and new_uuid: # Straight into the queue. update_q.put(new_uuid) flash("Watch added.") + if add_paused: + flash('Watch added in Paused state, saving will unpause.') + return redirect(url_for('edit_page', uuid=new_uuid, unpause_on_save=1)) + return redirect(url_for('index')) diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 9d29c5c1..7a307a5b 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -308,6 +308,9 @@ class ValidateCSSJSONXPATHInput(object): class quickWatchForm(Form): url = fields.URLField('URL', validators=[validateURL()]) tag = StringField('Group tag', [validators.Optional()]) + watch_submit_button = SubmitField('Watch', render_kw={"class": "pure-button pure-button-primary"}) + edit_and_watch_submit_button = SubmitField('Edit > Watch', render_kw={"class": "pure-button pure-button-primary"}) + # Common to a single watch and the global settings class commonSettingsForm(Form): diff --git a/changedetectionio/static/styles/styles.css b/changedetectionio/static/styles/styles.css index 0acbbd9c..f3878fb6 100644 --- a/changedetectionio/static/styles/styles.css +++ b/changedetectionio/static/styles/styles.css @@ -1,9 +1,7 @@ /* * -- BASE STYLES -- * Most of these are inherited from Base, but I want to change a few. - * nvm use v14.18.1 - * npm install - * npm run build + * nvm use v14.18.1 && npm install && npm run build * or npm run watch */ body { @@ -203,13 +201,18 @@ body:after, body:before { border-radius: 10px; margin-bottom: 1em; } #new-watch-form input { - width: auto !important; - display: inline-block; } + display: inline-block; + margin-bottom: 5px; } #new-watch-form .label { display: none; } #new-watch-form legend { color: #fff; font-weight: bold; } + #new-watch-form #watch-add-wrapper-zone > div { + display: inline-block; } + @media only screen and (max-width: 760px) { + #new-watch-form #watch-add-wrapper-zone #url { + width: 100%; } } #diff-col { padding-left: 40px; } diff --git a/changedetectionio/static/styles/styles.scss b/changedetectionio/static/styles/styles.scss index 76e33b22..761235fe 100644 --- a/changedetectionio/static/styles/styles.scss +++ b/changedetectionio/static/styles/styles.scss @@ -1,9 +1,7 @@ /* * -- BASE STYLES -- * Most of these are inherited from Base, but I want to change a few. - * nvm use v14.18.1 - * npm install - * npm run build + * nvm use v14.18.1 && npm install && npm run build * or npm run watch */ body { @@ -269,8 +267,8 @@ body:after, body:before { border-radius: 10px; margin-bottom: 1em; input { - width: auto !important; display: inline-block; + margin-bottom: 5px; } .label { display: none; @@ -279,6 +277,17 @@ body:after, body:before { color: #fff; font-weight: bold; } + + #watch-add-wrapper-zone { + > div { + display: inline-block; + } + @media only screen and (max-width: 760px) { + #url { + width: 100%; + } + } + } } diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 7b5d0c4a..8675928a 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -33,7 +33,7 @@
+ action="{{ url_for('edit_page', uuid=uuid, next = request.args.get('next'), unpause_on_save = request.args.get('unpause_on_save')) }}" method="POST">
diff --git a/changedetectionio/templates/watch-overview.html b/changedetectionio/templates/watch-overview.html index 5ac0eef8..0b20f3c3 100644 --- a/changedetectionio/templates/watch-overview.html +++ b/changedetectionio/templates/watch-overview.html @@ -1,18 +1,25 @@ {% extends 'base.html' %} {% block content %} -{% from '_helpers.jinja' import render_simple_field %} +{% from '_helpers.jinja' import render_simple_field, render_field %}
- +
Add a new change detection watch - {{ render_simple_field(form.url, placeholder="https://...", required=true) }} - {{ render_simple_field(form.tag, value=active_tag if active_tag else '', placeholder="watch group") }} - +
+
+ {{ render_simple_field(form.url, placeholder="https://...", required=true) }} + {{ render_simple_field(form.tag, value=active_tag if active_tag else '', placeholder="watch group") }} +
+
+ {{ render_simple_field(form.watch_submit_button, title="Watch this URL!" ) }} + {{ render_simple_field(form.edit_and_watch_submit_button, title="Edit first then Watch") }} +
+
Tip: You can also add 'shared' watches. More info