improve scheduling screen

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@311 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-08-29 22:34:26 +00:00
parent 981c8312cd
commit 0852c70891
7 changed files with 295 additions and 65 deletions

View File

@ -10,15 +10,10 @@ puts ""
cgi_input
#cgi_dump
set service 0
catch { set service [dict get $_cgi service] }
set event 0
catch { set event [dict get $_cgi event] }
set service [cgi_get service 0]
set event [cgi_get event 0]
if {! [dict exists $_cgi bare]} { header }
#set service 8448
#set event 30843
set record [lindex [epg fetch dump -service $service -event $event] 0]
$record get_channel_info
set others [$record othertimes]

View File

@ -0,0 +1,26 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
set slot [cgi_get slot 0]
set table [cgi_get table TBL_RESERVATION]
set event [rsv slot $table $slot]
if {$table eq "pending"} {
$event remove_pending
exit
}
$event clear_ulslot
$event set_delete
$event insert

View File

@ -0,0 +1,123 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
set table [cgi_get table TBL_RESERVATION]
set slot [cgi_get slot 0]
set event [rsv slot $table $slot]
set rsvicon [$event icon]
if {$rsvicon ne ""} {
set rsvicon "<img src='images/$rsvicon' height=20>
}
set RKIcon [$event RKIcon]
if {$RKIcon ne ""} {
set RKIcon "<img src='images/$RKIcon' height=20>
}
if {[$event get ucRecKind] == 4} {
set series 1
} else {
set series 0
}
puts "
<table class=keyval>
<tr>
<th>Event [$event get ulslot]</th>
<td class=va>$rsvicon $RKIcon</td>
</tr><tr>
<th>Channel</th>
<td class=va>
"
if {[$event get usLcn] ne ""} {
puts "
<img class=va width=50
src=\"/img/channels/[$event channel_name].png\">
- [$event get usLcn] - [$event channel_name]
"
}
puts "
</td>
</tr><tr>
<th>Event Name</th>
<td>[$event name]</td>
</tr><tr>
<th>Start</th>
"
set s [$event get nsttime]
set d [$event get nduration]
set e $($s + $d)
set n [clock seconds]
if { $n > $e } {
puts "<td class=blood nowrap class=va>"
} else {
puts "<td nowrap class=va>"
}
puts "[clock format $s -format "%a %d %b %Y"]
[clock format $s -format "%H:%M %Z"]"
if {$d > 0 && $n > $s && $n < $e} {
puts "<br>"
set perc [expr [expr $n - $s] * 100 / $d]
puts "<img class=va src=/images/745_1_11_Video_1REC.png>"
puts [progressbar $perc]
}
puts "
</td>
</tr><tr>
<th>Duration</th>
<td>[clock format [$event get nduration] -format %T]</td>
</tr>
"
set crid [join [lrange [split [$event get szCRID] /] 1 end]]
if {$crid != ""} {
puts "<tr><th>"
if $series { puts "Series" } else { puts "Event" }
puts " CRID</th><td>"
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
if $series { puts -nonewline "s" }
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
[$event get szCRID]"
puts "</a></td></tr>"
}
puts "<tr><th>Events</th><td>"
set flag 0
foreach ev [split [$event get szEventToRecord] "|"] {
if {$ev eq ""} { continue }
set ev [string range $ev 1 end]
if {$flag} { puts "<br>" }
incr flag
set crid [join [lrange [split $ev /] 1 end]]
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$ev"
puts "</a>"
}
puts "</td></tr>"
puts "<tr><th>Accepted</th><td>"
if {[$event get aulEventToRecordInfo] != ""} {
puts "Yes"
}
puts "</td></tr>"
puts "</table>"

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -4,6 +4,7 @@ source /mod/var/mongoose/lib/setup
require altrow rsv.class progressbar
puts {
<div id=dialogue></div>
<script type=text/javascript>
$.tablesorter.addParser({
@ -38,55 +39,91 @@ $(document).ready(function() {
}
});
});
$(document).ready(function() {
function docancel()
{
var table = $('#dialogue').attr('table');
var slot = $('#dialogue').attr('slot');
if (confirm('Really remove scheduled event?'))
{
$.get('/cgi-bin/sched_cancel.jim?slot=' + slot +
'&table=' + table, function() {
window.location.reload(true);
});
$('#dialogue').dialog('close');
}
}
var $buttons1 = {
"Close" : function() {$(this).dialog('close');}
};
var $buttons2 = $.extend(
{"Cancel Event": function() { docancel() }},
$buttons1);
var $dialog = $('#dialogue').dialog({
title: "Schedule Details",
modal: false, autoOpen: false,
height: 500, width: 700,
show: 'scale', hide: 'fade',
draggable: true, resizable: true,
buttons: $buttons2,
close: function(e,u) { $('#dialogue').empty().html(
'<img src="/img/loading.gif" alt="loading">'); }
});
function schedpopup(e, o)
{
e.preventDefault();
var slot = o.attr('slot');
var table = o.attr('table');
$('#dialogue').attr('slot', slot).attr('table', table);
var url = '/cgi-bin/sched_info.jim?slot=' + slot +
'&table=' + table;
$('#dialogue').load(url);
$dialog.dialog('open');
}
$('a.schedule').click(function(e) { schedpopup(e, $(this)) });
});
</script>
}
proc eventheader {} {
proc eventheader {{table TBL_RESERVATION}} {
puts {
<table class="borders tablesorter">
<thead>
<tr>
}
if {$table eq "pending" } { puts "<th>Action</th>" }
puts {
<th></th>
<th>&nbsp;</th><th>Channel</th>
<th>Programme</th>
<th>Start Time</th>
<th>Duration</th>
<th>Mode</th>
<th>Event/Series ID</th>
<th>Events</th>
</tr>
</thead>
<tbody>
}
}
proc eventrow {event} {
proc eventrow {event {table TBL_RESERVATION}} {
set name [$event name]
altrow
set rsvicon ""
switch [$event get ersvtype] {
1 { set rsvicon "175_1_00_Reservation_Watch.png" }
2 { set rsvicon "175_1_00_Reservation_Watch.png" }
3 { set rsvicon "175_1_11_Reservation_Record.png" }
5 { set rsvicon "745_1_10_Video_2Live.png" }
6 { set rsvicon "745_1_11_Video_1REC.png" }
7 { set rsvicon "345_6_08_ST_Ad_Hoc.png" }
}
set series 0
set rsvicon [$event icon]
set RKIcon [$event RKIcon]
if {[$event get ucRecKind] == 4} {
set RKIcon "175_1_11_Series_Record.png"
set series 1
} else {
switch [$event get erepeat] {
1 {set RKIcon "521_1_00_RP_Daily_C.png"}
2 {set RKIcon "521_1_00_RP_Weekly_C.png"}
3 {set RKIcon "521_1_00_RP_Weekdays_C.png"}
4 {set RKIcon "521_1_00_RP_Weekend_C.png"}
default {set RKIcon ""}
}
set series 0
}
if {$rsvicon ne ""} {
@ -96,6 +133,16 @@ proc eventrow {event} {
set RKIcon "<img src='images/$RKIcon' height=20>
}
if {$table eq "pending"} {
if {[$event get action] == 0} {
set icon "add"
} else {
set icon "close"
}
puts "<td align=center>
<img class=va width=30 src=/img/$icon.png></td>"
}
puts "<td>[$event get ulslot]</td>"
if {[$event get usLcn] ne ""} {
@ -111,7 +158,10 @@ proc eventrow {event} {
puts "<td>&nbsp;<br><br></td><td>&nbsp;</td>"
}
puts "<td nowrap>$name</td>"
puts "<td nowrap>
<a slot=[$event get ulslot] table=$table
href=# class=schedule>$name</a>
</td>"
set s [$event get nsttime]
set d [$event get nduration]
@ -138,36 +188,12 @@ proc eventrow {event} {
puts "<td>[clock format [$event get nduration] -format %T]</td>"
puts "<td nowrap>$rsvicon $RKIcon</td>"
puts "<td nowrap>"
set crid [join [lrange [split [$event get szCRID] /] 1 end]]
if {$crid != ""} {
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
if $series { puts -nonewline "s" }
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
[$event get szCRID]"
puts "</a>"
}
puts "</td>"
puts "<td nowrap>"
set flag 0
foreach ev [split [$event get szEventToRecord] "|"] {
if {$ev eq ""} { continue }
set ev [string range $ev 1 end]
if {$flag} { puts "<br>" }
incr flag
set crid [join [lrange [split $ev /] 1 end]]
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$ev"
puts "</a>"
}
puts "</td>"
if {[$event get aulEventToRecordInfo] != ""} {
puts "<td>*</td>"
puts "<td><img src=/img/lightning.png
alt=\"Accepted by Humax\"
title=\"Accepted by Humax\"></td>"
} else {
puts "<td>&nbsp;</td>"
}
puts "</tr>"
}
@ -178,9 +204,9 @@ proc eventfooter {} {
set events [rsv list pending]
if {[llength $events] > 0} {
puts "<h2>Pending Scheduled Events</h2>"
eventheader
foreach event $events {eventrow $event}
puts "<h2>Pending Schedule Events</h2>"
eventheader pending
foreach event $events {eventrow $event pending}
eventfooter
puts {
<small>

View File

@ -12,6 +12,7 @@ if {![file exists /var/lib/humaxtv/rsvp.db]} {
set tdb [sqlite3.open /var/lib/humaxtv/rsvp.db]
$tdb query {drop table TBL_VERSION}
$tdb query {alter table TBL_RESERVATION rename to pending}
$tdb query {alter table pending add column action int}
$tdb query {delete from pending}
$tdb close
}
@ -47,6 +48,7 @@ class rsv {
szSvcName {}
usLcn 0
sort 0
action 0
}
rsv method clear_ulslot {} {
@ -75,6 +77,42 @@ rsv method channel_name {} {
return [string range $szSvcName 1 end]
}
rsv method icon {} {
set rsvicon ""
switch [$self get ersvtype] {
1 { set rsvicon "175_1_00_Reservation_Watch.png" }
2 { set rsvicon "175_1_00_Reservation_Watch.png" }
3 { set rsvicon "175_1_11_Reservation_Record.png" }
5 { set rsvicon "745_1_10_Video_2Live.png" }
6 { set rsvicon "745_1_11_Video_1REC.png" }
7 { set rsvicon "345_6_08_ST_Ad_Hoc.png" }
}
return $rsvicon
}
rsv method RKIcon {} {
if {[$self get ucRecKind] == 4} {
set RKIcon "175_1_11_Series_Record.png"
} else {
switch [$self get erepeat] {
1 {set RKIcon "521_1_00_RP_Daily_C.png"}
2 {set RKIcon "521_1_00_RP_Weekly_C.png"}
3 {set RKIcon "521_1_00_RP_Weekdays_C.png"}
4 {set RKIcon "521_1_00_RP_Weekend_C.png"}
default {set RKIcon ""}
}
}
return $RKIcon
}
rsv method set_delete {} {
set action 1
}
rsv method remove_pending {} {
$::rsvdb query "delete from pending where ulslot = [$self get ulslot]"
}
rsv method fix_hsvc {} {
global rsvdb
@ -124,6 +162,11 @@ rsv method insert {{table pending}} {
set fields [lreplace $fields $df $df]
}
if {$table ne "pending"} {
set df [lsearch $fields "action"]
set fields [lreplace $fields $df $df]
}
set vals {}
foreach field $fields {
# Escape any quotes embedded in the data.
@ -194,6 +237,21 @@ proc {rsv entry} {{table TBL_RESERVATION} crid svc} {
return 0
}
proc {rsv slot} {{table TBL_RESERVATION} slot} {
set res [$::rsvdb query "
select $table.*,
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn
from $table
left join channel.TBL_SVC
on $table.hSvc = channel.TBL_SVC.hSvc
where ulslot = %s" $slot]
if {[llength $res] > 0} {
return [rsv new [lindex $res 0]]
}
return 0
}
proc {rsv cleanup} {} {
catch {$::rsvdb close}
}
@ -201,9 +259,11 @@ proc {rsv cleanup} {} {
proc {rsv commit} {} {
$::rsvdb query {begin transaction}
foreach rec [rsv list pending] {
if {[$rec get action] == 0} {
$rec clear_ulslot
$rec insert TBL_RESERVATION
}
}
$::rsvdb query {delete from pending}
$::rsvdb query {commit transaction}
}