From b1dd71f7e7897c2c45b60b969b2e8a267c018af8 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 18 Aug 2022 14:33:09 +0200 Subject: [PATCH] Basic checkbox/group operations --- changedetectionio/__init__.py | 30 +++++++++++++++++++ changedetectionio/static/js/watch-overview.js | 13 ++++++++ changedetectionio/static/styles/styles.css | 10 +++++++ changedetectionio/static/styles/styles.scss | 12 ++++++++ .../templates/watch-overview.html | 13 ++++++-- 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 594747ef..1ba329d5 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -1186,6 +1186,36 @@ def changedetection_app(config=None, datastore_o=None): flash("{} watches are queued for rechecking.".format(i)) return redirect(url_for('index', tag=tag)) + @app.route("/form/checkbox-operations", methods=['POST']) + @login_required + def form_watch_list_checkbox_operations(): + op = request.form['op'] + uuids = request.form.getlist('uuids') + + if (op == 'delete'): + for uuid in uuids: + uuid = uuid.strip() + if datastore.data['watching'].get(uuid): + datastore.delete(uuid.strip()) + flash("{} watches deleted".format(len(uuids))) + + if (op == 'pause'): + for uuid in uuids: + uuid = uuid.strip() + if datastore.data['watching'].get(uuid): + datastore.data['watching'][uuid.strip()]['paused'] = True + + flash("{} watches paused".format(len(uuids))) + + if (op == 'unpause'): + for uuid in uuids: + uuid = uuid.strip() + if datastore.data['watching'].get(uuid): + datastore.data['watching'][uuid.strip()]['paused'] = False + flash("{} watches unpaused".format(len(uuids))) + + return redirect(url_for('index')) + @app.route("/api/share-url", methods=['GET']) @login_required def form_share_put_watch(): diff --git a/changedetectionio/static/js/watch-overview.js b/changedetectionio/static/js/watch-overview.js index a06034b1..4b747c14 100644 --- a/changedetectionio/static/js/watch-overview.js +++ b/changedetectionio/static/js/watch-overview.js @@ -22,5 +22,18 @@ $(function () { }); }); + // checkboxes - check all + $("#check-all").click(function (e) { + $('input[type=checkbox]').not(this).prop('checked', this.checked); + }); + // checkboxes - show/hide buttons + $("input[type=checkbox]").click(function (e) { + if ($('input[type=checkbox]:checked').length) { + $('#checkbox-operations').slideDown(); + } else { + $('#checkbox-operations').slideUp(); + } + }); + }); diff --git a/changedetectionio/static/styles/styles.css b/changedetectionio/static/styles/styles.css index 61b1fbb1..0444da7a 100644 --- a/changedetectionio/static/styles/styles.css +++ b/changedetectionio/static/styles/styles.css @@ -555,3 +555,13 @@ ul { .snapshot-age.error { background-color: #ff0000; color: #fff; } + +#checkbox-operations { + background: rgba(0, 0, 0, 0.05); + padding: 1em; + border-radius: 10px; + margin-bottom: 1em; + display: none; } + +.checkbox-uuid > * { + vertical-align: middle; } diff --git a/changedetectionio/static/styles/styles.scss b/changedetectionio/static/styles/styles.scss index 1801a0e0..4839aec1 100644 --- a/changedetectionio/static/styles/styles.scss +++ b/changedetectionio/static/styles/styles.scss @@ -774,3 +774,15 @@ ul { } } +#checkbox-operations { + background: rgba(0, 0, 0, 0.05); + padding: 1em; + border-radius: 10px; + margin-bottom: 1em; + display: none; +} +.checkbox-uuid { + > * { + vertical-align: middle; + } +} diff --git a/changedetectionio/templates/watch-overview.html b/changedetectionio/templates/watch-overview.html index b5e962c2..a6d8d752 100644 --- a/changedetectionio/templates/watch-overview.html +++ b/changedetectionio/templates/watch-overview.html @@ -24,6 +24,14 @@ Tip: You can also add 'shared' watches. More info + +
+ +
+ + + +
All {% for tag in tags %} @@ -41,7 +49,7 @@ - + {% set link_order = "desc" if sort_order else "asc" %} {% set arrow_span = "" %} @@ -66,7 +74,7 @@ {% if watch.paused is defined and watch.paused != False %}paused{% endif %} {% if watch.newest_history_key| int > watch.last_viewed and watch.history_n>=2 %}unviewed{% endif %} {% if watch.uuid in queued_uuids %}queued{% endif %}"> - +
# # {{ loop.index }} {{ loop.index }} Pause checks Mute notifications @@ -129,5 +137,6 @@ #} + {% endblock %}