manual scheduling

git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2384 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2015-04-14 00:09:47 +00:00
parent 2e3ce0aed1
commit 0a91878fd5
12 changed files with 391 additions and 9 deletions

View File

@ -1,8 +1,17 @@
#!/mod/bin/jimsh
set file [lindex $argv 0]
source /mod/webif/lib/setup
require lock
set file [lindex $argv 0]
set dir [file dirname $file]
# Wait up to 10 minutes for any existing auto process to finish...
if {![acquire_lock webif_auto 600]} {
puts "Cannot acquire exclusive lock, terminating."
exit
}
release_lock webif_auto
exec /mod/webif/lib/bin/auto -single $dir

22
webif/cgi-bin/chanlist.jim Executable file
View File

@ -0,0 +1,22 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require epg.class
httpheader "application/json"
puts "{"
set flag 0
lmap i [$channeldb query "
select usLcn, szSvcName
from TBL_SVC
order by 1
"] {
if {$::flag} { puts "," } else { incr ::flag }
lassign $i x lcn x name
puts -nonewline " \"$lcn\": \"[system strip $name]\""
}
puts "\n}"

View File

@ -280,6 +280,12 @@ tr.blueshade > td, .blueshade
text-decoration: line-through;
}
.error
{
background: #ffcccc;
color: black;
}
.greenshade
{
background: #e4faa8;

View File

@ -3,11 +3,11 @@
package require cgi
package require sqlite3
source /mod/webif/lib/setup
require ts.class pretty_size
require system.class ts.class pretty_size
header
#append dmsfile ".rr"
set dmsfile [system dlnadb]
set vars {
object.container 0

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,72 @@
.ui-timepicker-wrapper {
overflow-y: auto;
height: 150px;
width: 6.5em;
background: #fff;
border: 1px solid #ddd;
-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);
-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);
box-shadow:0 5px 10px rgba(0,0,0,0.2);
outline: none;
z-index: 10001;
margin: 0;
}
.ui-timepicker-wrapper.ui-timepicker-with-duration {
width: 13em;
}
.ui-timepicker-wrapper.ui-timepicker-with-duration.ui-timepicker-step-30,
.ui-timepicker-wrapper.ui-timepicker-with-duration.ui-timepicker-step-60 {
width: 11em;
}
.ui-timepicker-list {
margin: 0;
padding: 0;
list-style: none;
}
.ui-timepicker-duration {
margin-left: 5px; color: #888;
}
.ui-timepicker-list:hover .ui-timepicker-duration {
color: #888;
}
.ui-timepicker-list li {
padding: 3px 0 3px 5px;
cursor: pointer;
white-space: nowrap;
color: #000;
list-style: none;
margin: 0;
}
.ui-timepicker-list:hover .ui-timepicker-selected {
background: #fff; color: #000;
}
li.ui-timepicker-selected,
.ui-timepicker-list li:hover,
.ui-timepicker-list .ui-timepicker-selected:hover {
background: #1980EC; color: #fff;
}
li.ui-timepicker-selected .ui-timepicker-duration,
.ui-timepicker-list li:hover .ui-timepicker-duration {
color: #ccc;
}
.ui-timepicker-list li.ui-timepicker-disabled,
.ui-timepicker-list li.ui-timepicker-disabled:hover,
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
color: #888;
cursor: default;
}
.ui-timepicker-list li.ui-timepicker-disabled:hover,
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
background: #f2f2f2;
}

File diff suppressed because one or more lines are too long

View File

@ -76,5 +76,74 @@ puts {
</form>
</div>
<div id=manrsv title="Manual Event" style="display: none">
<form id=mrform>
<table border=0>
<tr>
<th>
<b>Create</b>
</th>
<td>
<select id=mrrepeat name=repeat
class="ui-widget-content ui-corner-all">
<option value=0 selected>One-off</option>
<option value=1>Daily</option>
<option value=2>Weekly</option>
<option value=3>Weekday</option>
<option value=4>Weekend</option>
</select>
&nbsp;
<select id=mrtype name=type
class="ui-widget-content ui-corner-all">
<option value=4 selected>Recording</option>
<option value=2>Reminder</option>
</select>
</td>
</tr><tr>
<th>
<b>From</b>
</th>
<td>
<input type=text id=mrsdate size=15
placeholder="dd/mm/yyyy"
class="date start text ui-widget-content ui-corner-all">
<input type=text id=mrstime size=10
placeholder="hh:mm"
class="time start text ui-widget-content ui-corner-all">
<b>to</b>
<input type=text id=mredate size=15
placeholder="dd/mm/yyyy"
class="date end text ui-widget-content ui-corner-all">
<input type=text id=mretime size=10
placeholder="hh:mm"
class="time end text ui-widget-content ui-corner-all">
</td>
</tr><tr>
<th>
<b>Channel</b>
</th>
<td>
<select id=mrlcn tabindex=1 name=lcn
class="ui-widget-content ui-corner-all blood">
<option>Loading channel list...</option>
</select>
</td>
</tr><tr>
<th>
<b>Event title</b>
</th>
<td>
<input type=text id=mrtitle size=73 name=mrtitle
placeholder="Defaults to channel name"
class="text ui-widget-content ui-corner-all">
</td>
</tr><tr>
</td>
</tr>
</table>
</form>
<div id=mrerr class=blood></div>
</div>
}

View File

@ -4,7 +4,8 @@ package require cgi
source /mod/webif/lib/setup
require altrow rsv.class progressbar epg.class system.class
jqplugin tablesorter2 contextMenu form blockui confirmAction
jqplugin tablesorter2 contextMenu form blockui confirmAction \
timepicker datepair
jscss script.js
header
@ -84,7 +85,8 @@ proc eventrow {event {table TBL_RESERVATION} {pending 0}} {
if {$pending} {
append attrs " class=\"blueshade strike\""
}
puts "<tr $attrs>"
altrow $attrs
#puts "<tr $attrs>"
# Checkbox
puts "<td><input type=checkbox class=schedselect></td>";
@ -225,9 +227,9 @@ proc eventfooter {rawlink} {
}
puts "
<button class=\"delselected red\">Delete Selected
<span class=delselcnt></span></button>
"
puts "
<span class=delselcnt></span>
</button>
<button class=\"manual_rsv blue\">Manual Event</button>
<button class=rawview
path=\"$rawlink\"
>Raw Database</button>

46
webif/html/sched/manual.jim Executable file
View File

@ -0,0 +1,46 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require system.class rsv.class
httpheader "application/json"
set fields {start end lcn type repeat}
set errfields {}
foreach var $fields {
if {[set $var [cgi_get $var -]] eq "-"} {
lappend errfields $var
}
}
set title [cgi_get mrtitle ""]
puts "{"
if {[llength $errfields]} {
puts "\"status\" : 0,"
puts "\"errfields\": \["
set flag 0
foreach e $errfields {
if {$flag} { puts "," } else { incr flag }
puts -nonewline "\"$e\""
}
puts ""
puts "]"
} else {
if {[catch {
set r [rsv manual $start $end $lcn $type $repeat $title]
} msg]} {
puts "\"status\": 0,"
puts "\"err\": \"$msg\""
} elseif {[catch {$r insert} msg]} {
puts "\"status\": 0,"
puts "\"err\": \"$msg\""
} else {
puts "\"status\": 1"
system restartpending
}
}
puts "}"

View File

@ -76,7 +76,6 @@ function schedpopup(e, o)
}
$('a.schedule').click(function(e) { schedpopup(e, $(this)) });
$('.schedselect:checked').prop('checked', false);
$('button.delselected').button({icons:{primary:"ui-icon-trash"}})
@ -287,5 +286,120 @@ $('#schedule_cleanup').bind('click', function(e) {
});
});
// Manual reservation
$('#manrsv').dialog({
autoOpen: false,
height: 'auto', width: 'auto',
modal: true,
buttons: {
"Create event": function() {
var data = $('#mrform').serializeArray();
var s = $('#mrstime').timepicker('getTime',
$('#mrsdate').datepicker('getDate'));
if (s)
data.push({ name: "start", value: s.getTime() / 1000});
var s = $('#mretime').timepicker('getTime',
$('#mredate').datepicker('getDate'));
if (s)
data.push({ name: "end", value: s.getTime() / 1000});
$('#mrerr')
.html('<img src=/img/loading.gif> Creating event...');
$.getJSON('manual.jim', data, function(d) {
if (d.status)
window.location.reload(true);
else if (d.errfields)
{
d.errfields.forEach(function(item) {
$('#mrform input[name=' + item + ']')
.addClass('error');
});
$('#mrerr').html('The start and end times '
+ 'must be provided.');
}
else if (d.err)
$('#mrerr').html(d.err);
});
},
"Cancel": function() {
$(this).dialog('close');
}
}
});
$('button.manual_rsv').button({icons:{primary:"ui-icon-clock"}})
.on('click', function() {
$('#mrform').get(0).reset();
$('#mrform input.date').datepicker('setDate', null);
$('#mrform input.time').timepicker('setTime', null);
$('#manrsv').dialog('open');
// $("#manrsv .ui-dialog-buttonpane button:contains('Create')")
// .button('disable')
if ($('#mrlcn').hasClass('blood'))
{
var $s = $('#mrlcn');
$.getJSON('/cgi-bin/chanlist.jim', function(data) {
$s.find('option').remove();
$.each(data, function(lcn, name) {
$('<option>')
.val(lcn)
.text(lcn + ' - ' + name)
.appendTo($s);
});
$('#mrlcn').removeClass('blood');
});
}
});
$('#mrform input.time').timepicker({
showDuration: true,
timeFormat: 'g:ia',
step:5
});
$('#mrsdate').datepicker({
defaultDate: 0,
minDate: 0,
maxDate: "+1Y",
dateFormat: "D, dd/mm/yy",
autoclose: true,
onClose: function(s) {
var dat = $(this).datepicker('getDate');
if (dat)
dat.setDate(dat.getDate() + 1);
$('#mredate')
.datepicker('setDate', s)
.datepicker('option', 'minDate', s)
.datepicker('option', 'maxDate', dat);
}
});
$('#mredate').datepicker({
defaultDate: 0,
minDate: 0,
maxDate: "+1Y",
autoclose: true,
dateFormat: "D, dd/mm/yy",
});
$('#mrform').datepair({
defaultDateDelta: null,
defaultTimeDelta: 3600000,
parseDate: function (el) {
var utc = new Date($(el).datepicker('getDate'));
return utc && new Date(utc.getTime() +
(utc.getTimezoneOffset() * 60000));
},
updateDate: function (el, v) {
$(el).datepicker('setDate', v);
}
});
});

View File

@ -537,6 +537,34 @@ proc {rsv construct} {event type} {
return [rsv new $args]
}
proc {rsv manual} {start end lcn type repeat {title ""}} {
require findhsvc
set args {}
set args(ersvtype) $type
set args(erepeat) $repeat
set args(nsttime) $start
set args(szsttime) [clock format $args(nsttime) \
-format {%Y%m%d%H%M%S}]
set args(nduration) $($end - $start)
set args(hsvc) [get_channel_attr_bylcn $lcn]
if {$title eq ""} {
set title [system strip [\
get_channel_attr_bylcn $lcn szSvcName]]
}
set args(szevtname) $title
set args(ucRecKind) 0
set args(usevtid) 0
set args(eReady) 30
return [rsv new $args]
}
proc {rsv backup} {file} {
global rsvdb