Skip to content

Commit

Permalink
Tidy up fields, use placeholder as default so its easier to understand
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtlmoon committed Nov 28, 2024
1 parent 129678f commit 86388cb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion changedetectionio/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ def edit_page(uuid):

form = form_class(formdata=request.form if request.method == 'POST' else None,
data=default,
extra_notification_tokens=default.extra_notification_token_values()
extra_notification_tokens=default.extra_notification_token_values(),
default_system_settings=datastore.data['settings']
)

# For the form widget tag UUID back to "string name" for the field
Expand Down
23 changes: 20 additions & 3 deletions changedetectionio/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ class ScheduleLimitForm(Form):
saturday = FormField(ScheduleLimitDaySubForm, label="")
sunday = FormField(ScheduleLimitDaySubForm, label="")

timezone_offset = StringField("Timezone to run in",
render_kw={"list": "timezones", "placeholder": "Default"},
timezone = StringField("Timezone to run in",
render_kw={"list": "timezones"},
validators=[validateTimeZoneName()]
)
def __init__(
Expand Down Expand Up @@ -522,7 +522,7 @@ def __init__(self, formdata=None, obj=None, prefix="", data=None, meta=None, **k
notification_title = StringField('Notification Title', default='ChangeDetection.io Notification - {{ watch_url }}', validators=[validators.Optional(), ValidateJinja2Template()])
notification_urls = StringListField('Notification URL List', validators=[validators.Optional(), ValidateAppRiseServers(), ValidateJinja2Template()])
processor = RadioField( label=u"Processor - What do you want to achieve?", choices=processors.available_processors(), default="text_json_diff")
timezone = StringField("Timezone to run in", render_kw={"list": "timezones", "placeholder": "Default"}, validators=[validateTimeZoneName()])
timezone = StringField("Timezone to run in", render_kw={"list": "timezones"}, validators=[validateTimeZoneName()])
webdriver_delay = IntegerField('Wait seconds before extracting text', validators=[validators.Optional(), validators.NumberRange(min=1, message="Should contain one or more seconds")])


Expand Down Expand Up @@ -655,6 +655,23 @@ def validate(self, **kwargs):

return result

def __init__(
self,
formdata=None,
obj=None,
prefix="",
data=None,
meta=None,
**kwargs,
):
super().__init__(formdata, obj, prefix, data, meta, **kwargs)

default_tz = kwargs.get('default_system_settings').get('application', {}).get('timezone')
if default_tz:
self.time_schedule_limit.form.timezone.render_kw['placeholder'] = default_tz



class SingleExtraProxy(Form):

# maybe better to set some <script>var..
Expand Down
2 changes: 1 addition & 1 deletion changedetectionio/model/Watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def watch_recheck_is_within_schedule(self, default_tz="UTC"):
time_schedule_limit = self.get('time_schedule_limit')
if time_schedule_limit and time_schedule_limit.get('enabled'):
# Get the timezone the time schedule is in, so we know what day it is there
tz_name = time_schedule_limit.get('timezone_offset', '').strip()
tz_name = time_schedule_limit.get('timezone', '').strip()
if not tz_name:
tz_name = default_tz

Expand Down
8 changes: 6 additions & 2 deletions changedetectionio/static/js/watch-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ function request_textpreview_update() {
$(document).ready(function () {

window.setInterval(function () {
if ($("#time_schedule_limit-timezone_offset").val().length) {
if ($("#time_schedule_limit-timezone").val().length) {
document.getElementById('local-time-in-tz').textContent =
getTimeInTimezone($("#time_schedule_limit-timezone_offset").val());
getTimeInTimezone($("#time_schedule_limit-timezone").val());
} else {
// So maybe use what is in the placeholder (which will be the default settings)
document.getElementById('local-time-in-tz').textContent =
getTimeInTimezone($("#time_schedule_limit-timezone").attr('placeholder'));
}
}, 500);

Expand Down
2 changes: 1 addition & 1 deletion changedetectionio/templates/_helpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
</li>
{% endfor %}
<li id="timezone-info">
{{ render_field(form.time_schedule_limit.timezone_offset) }} <span id="local-time-in-tz"></span>
{{ render_field(form.time_schedule_limit.timezone) }} <span id="local-time-in-tz"></span>
<datalist id="timezones" style="display: none;">
{% for timezone in available_timezones %}
<option value="{{ timezone }}">{{ timezone }}</option>
Expand Down

0 comments on commit 86388cb

Please sign in to comment.