Permalink
Browse files

Make scheduler more flexible

Schedules can now be set for any aribtary group of days of the week.

Sorry about the css; I couldnt work out where the un-minified version
lived.
  • Loading branch information...
1 parent b73570f commit 2da37016854afc816dbdd3be60bbf59f413c2c02 @lparry committed Jun 4, 2012
@@ -31,16 +31,14 @@ $T('hour'):<br>
<!--#end for#-->
</select>
<br>$T('sch-frequency'): <br>
-<select name="dayofweek">
-<option value="*" selected>$T('daily')
-<option value="1">$T('monday')
-<option value="2">$T('tuesday')
-<option value="3">$T('wednesday')
-<option value="4">$T('thursday')
-<option value="5">$T('friday')
-<option value="6">$T('saturday')
-<option value="7">$T('sunday')
-</select>
+<input type="checkbox" name="daysofweek" value="1">$T('monday')<br/>
+<input type="checkbox" name="daysofweek" value="2">$T('tuesday')<br/>
+<input type="checkbox" name="daysofweek" value="3">$T('wednesday')<br/>
+<input type="checkbox" name="daysofweek" value="4">$T('thursday')<br/>
+<input type="checkbox" name="daysofweek" value="5">$T('friday')<br/>
+<input type="checkbox" name="daysofweek" value="6">$T('saturday')<br/>
+<input type="checkbox" name="daysofweek" value="7">$T('sunday')<br/>
+
<br>$T('sch-action'):<br>
<select name="action">
<!--#for $action in $actions#-->
@@ -34,17 +34,16 @@ else:
</select>
</div>
<div class="field-pair">
- <label class="config" for="dayofweek">$T('sch-frequency')</label>
- <select name="dayofweek" id="dayofweek">
- <option value="*" selected="selected">$T('daily')</option>
- <option value="1">$T('monday')</option>
- <option value="2">$T('tuesday')</option>
- <option value="3">$T('wednesday')</option>
- <option value="4">$T('thursday')</option>
- <option value="5">$T('friday')</option>
- <option value="6">$T('saturday')</option>
- <option value="7">$T('sunday')</option>
- </select>
+ <label class="config" for="daysofweek">$T('sch-frequency')</label>
+ <div class="checkbox-days">
+ <p><input type="checkbox" name="daysofweek" value="1"><label>$T('monday')</label></p>
+ <p><input type="checkbox" name="daysofweek" value="2"><label>$T('tuesday')</label></p>
+ <p><input type="checkbox" name="daysofweek" value="3"><label>$T('wednesday')</label></p>
+ <p><input type="checkbox" name="daysofweek" value="4"><label>$T('thursday')</label></p>
+ <p><input type="checkbox" name="daysofweek" value="5"><label>$T('friday')</label></p>
+ <p><input type="checkbox" name="daysofweek" value="6"><label>$T('saturday')</label></p>
+ <p><input type="checkbox" name="daysofweek" value="7"><label>$T('sunday')</label></p>
+ </div>
</div>
<div class="field-pair alt">
<label class="config" for="action">$T('sch-action')</label>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -36,18 +36,15 @@ else:
</label>
</div>
<div class="field-pair alt">
- <label class="nocheck clearfix" for="dayofweek">
+ <label class="nocheck clearfix" for="daysofweek">
<span class="component-title">$T('sch-frequency')</span>
- <select name="dayofweek" id="dayofweek">
- <option value="*" selected>$T('daily')</option>
- <option value="1">$T('monday')</option>
- <option value="2">$T('tuesday')</option>
- <option value="3">$T('wednesday')</option>
- <option value="4">$T('thursday')</option>
- <option value="5">$T('friday')</option>
- <option value="6">$T('saturday')</option>
- <option value="7">$T('sunday')</option>
- </select>
+ <input type="checkbox" name="daysofweek" value="1">$T('monday')<br/>
+ <input type="checkbox" name="daysofweek" value="2">$T('tuesday')<br/>
+ <input type="checkbox" name="daysofweek" value="3">$T('wednesday')<br/>
+ <input type="checkbox" name="daysofweek" value="4">$T('thursday')<br/>
+ <input type="checkbox" name="daysofweek" value="5">$T('friday')<br/>
+ <input type="checkbox" name="daysofweek" value="6">$T('saturday')<br/>
+ <input type="checkbox" name="daysofweek" value="7">$T('sunday')<br/>
</label>
</div>
<div class="field-pair">
@@ -26,17 +26,14 @@ else:
<!--#end for#-->
</select>
<br class="clear" />
-<label class="label">$T('sch-frequency'):</label>
-<select name="dayofweek">
-<option value="*" selected>$T('daily')
-<option value="1">$T('monday')
-<option value="2">$T('tuesday')
-<option value="3">$T('wednesday')
-<option value="4">$T('thursday')
-<option value="5">$T('friday')
-<option value="6">$T('saturday')
-<option value="7">$T('sunday')
-</select>
+<label class="label" for="daysofweek">$T('sch-frequency'):</label>
+<input type="checkbox" name="daysofweek" value="1">$T('monday')<br/>
+<input type="checkbox" name="daysofweek" value="2">$T('tuesday')<br/>
+<input type="checkbox" name="daysofweek" value="3">$T('wednesday')<br/>
+<input type="checkbox" name="daysofweek" value="4">$T('thursday')<br/>
+<input type="checkbox" name="daysofweek" value="5">$T('friday')<br/>
+<input type="checkbox" name="daysofweek" value="6">$T('saturday')<br/>
+<input type="checkbox" name="daysofweek" value="7">$T('sunday')<br/>
<br class="clear" />
<label class="label">$T('sch-action'):</label>
<select name="action">
View
@@ -1901,15 +1901,15 @@ def get_days():
actions = []
actions.extend(_SCHED_ACTIONS)
- days = get_days()
+ day_names = get_days()
conf['schedlines'] = []
snum = 1
conf['taskinfo'] = []
for ev in scheduler.sort_schedules(forward=True):
line = ev[3]
conf['schedlines'].append(line)
try:
- m, h, day, action = line.split(' ', 3)
+ m, h, day_numbers, action = line.split(' ', 3)
except:
continue
action = action.strip()
@@ -1929,7 +1929,10 @@ def get_days():
act = ''
if act in ('enable_server', 'disable_server'):
action = Ttemplate("sch-" + act) + ' ' + server
- item = (snum, '%02d' % int(h), '%02d' % int(m), days.get(day, '**'), '%s %s' % (action, value))
+
+ days_of_week = ", ".join([day_names.get(i, "**") for i in day_numbers])
+ item = (snum, '%02d' % int(h), '%02d' % int(m), days_of_week, '%s %s' % (action, value))
+
conf['taskinfo'].append(item)
snum += 1
@@ -1954,7 +1957,7 @@ def addSchedule(self, **kwargs):
minute = kwargs.get('minute')
hour = kwargs.get('hour')
- dayofweek = kwargs.get('dayofweek')
+ days_of_week = ''.join([str(x) for x in kwargs.get('daysofweek')])
action = kwargs.get('action')
arguments = kwargs.get('arguments')
@@ -1964,7 +1967,7 @@ def addSchedule(self, **kwargs):
elif arguments in ('off','disable'):
arguments = '0'
- if minute and hour and dayofweek and action:
+ if minute and hour and days_of_week and action:
if action == 'speedlimit':
if not (arguments and arguments.isdigit()):
action = '0'
@@ -1983,7 +1986,7 @@ def addSchedule(self, **kwargs):
if action:
sched = cfg.schedules()
sched.append('%s %s %s %s %s' %
- (minute, hour, dayofweek, action, arguments))
+ (minute, hour, days_of_week, action, arguments))
cfg.schedules.set(sched)
config.save_config()
View
@@ -82,7 +82,7 @@ def init():
continue
if d.isdigit():
- d = [int(d)]
+ d = [int(i) for i in d]
else:
d = range(1, 8)

2 comments on commit 2da3701

you can just provide me the css and i can runt he build script to make it all nice and pretty

Owner

lparry replied Jun 5, 2012

It's just those 4 lines at the bottom, the extra line shows up in the diff because of the extra newline on the end.

.checkbox-days{float: left}
.checkbox-days p{margin: 0 0 5px 0}
.checkbox-days input {vertical-align:middle; margin-top: -1px;}
.checkbox-days label{padding-left: 20px}

I'm no css wizard so I'm happy to concede there's probably a better way to style this

Please sign in to comment.