Simple demo to list alternative broadcasts, this is a bit of a hack but gives a useful demo of the capabilties of the new structure and helps in testing too.

This commit is contained in:
Adam Sutton 2012-05-23 11:18:32 +01:00
parent faafb16097
commit 129a86be20
3 changed files with 83 additions and 1 deletions

View file

@ -773,6 +773,54 @@ extjs_epg(http_connection_t *hc, const char *remain, void *opaque)
return 0;
}
static int
extjs_epgaltbcast(http_connection_t *hc, const char *remain, void *opaque)
{
htsbuf_queue_t *hq = &hc->hc_reply;
htsmsg_t *out, *array, *m;
epg_broadcast_t *e, *ebc;
epg_episode_t *ee = NULL;
channel_t *ch;
uint32_t id;
uint32_t count = 0;
const char *arg;
arg = http_arg_get(&hc->hc_req_args, "id");
// TODO: limit param?
out = htsmsg_create_map();
array = htsmsg_create_list();
pthread_mutex_lock(&global_lock);
if ( arg ) {
if ( arg ) id = atoi(arg);
e = epg_broadcast_find_by_id(id);
if ( e && e->eb_episode ) {
ee = e->eb_episode;
RB_FOREACH(ebc, &ee->ee_broadcasts, eb_elink) {
ch = ebc->eb_channel->ec_channel;
if ( !ch ) continue; // skip something not viewable
if ( ebc == e ) continue; // skip self
count++;
m = htsmsg_create_map();
htsmsg_add_u32(m, "id", ebc->eb_id);
if ( ch->ch_name ) htsmsg_add_str(m, "channel", ch->ch_name);
if ( ch->ch_icon ) htsmsg_add_str(m, "chicon", ch->ch_icon);
htsmsg_add_u32(m, "start", ebc->eb_start);
htsmsg_add_msg(array, NULL, m);
}
}
}
pthread_mutex_unlock(&global_lock);
htsmsg_add_u32(out, "totalCount", count);
htsmsg_add_msg(out, "entries", array);
htsmsg_json_serialize(out, hq, 0);
htsmsg_destroy(out);
http_output_content(hc, "text/x-json; charset=UTF-8");
return 0;
}
/**
*
*/
@ -1573,6 +1621,7 @@ extjs_start(void)
http_path_add("/channeltags", NULL, extjs_channeltags, ACCESS_WEB_INTERFACE);
http_path_add("/confignames", NULL, extjs_confignames, ACCESS_WEB_INTERFACE);
http_path_add("/epg", NULL, extjs_epg, ACCESS_WEB_INTERFACE);
http_path_add("/epgaltbcast", NULL, extjs_epgaltbcast, ACCESS_WEB_INTERFACE);
http_path_add("/dvr", NULL, extjs_dvr, ACCESS_WEB_INTERFACE);
http_path_add("/dvrlist", NULL, extjs_dvrlist, ACCESS_WEB_INTERFACE);
http_path_add("/ecglist", NULL, extjs_ecglist, ACCESS_WEB_INTERFACE);

View file

@ -9,7 +9,6 @@ tvheadend.ContentGroupStore.setDefaultSort('name', 'ASC');
tvheadend.epgDetails = function(event) {
var content = '';
if(event.chicon != null && event.chicon.length > 0)
@ -40,6 +39,8 @@ tvheadend.epgDetails = function(event) {
event.channelid + "')\">Play</a>" + "</div>";
}
content += '<div id="altbcast"></div>';
var confcombo = new Ext.form.ComboBox({
store: tvheadend.configNames,
triggerAction: 'all',
@ -91,6 +92,31 @@ tvheadend.epgDetails = function(event) {
});
}
function showAlternatives (s) {
// TODO: must be a way to constrain this
var e = Ext.get('altbcast')
html = '';
if ( s.getTotalCount() > 0 ) {
html += '<div class="x-epg-subtitle">Alternative Broadcasts</div>';
for ( i = 0; i < s.getTotalCount(); i++ ) {
var ab = s.getAt(i).data;
var dt = Date.parseDate(ab.start, 'U');
html += '<div class="x-epg-desc">' + dt.format('l H:i') + '&nbsp;&nbsp;&nbsp;' + ab.channel + '</div>';
// TODO: record option?
}
}
e.dom.innerHTML = html;
}
var ab = new Ext.data.JsonStore({
root: 'entries',
url: 'epgaltbcast',
autoLoad: true,
id: 'id',
baseParams: { op: 'get', id: event.id },
fields: Ext.data.Record.create([ 'id', 'channel', 'start' ]),
listeners: { 'datachanged': showAlternatives }
});
}
@ -112,6 +138,7 @@ tvheadend.epg = function() {
]
});
var epgStore = new Ext.ux.grid.livegrid.Store({
autoLoad: true,
url: 'epg',

View file

@ -250,6 +250,12 @@
font-weight:bold;
}
.x-epg-subtitle {
margin: 5px;
font:normal 12px arial, tahoma, helvetica, sans-serif;
font-weight:bold;
}
.x-epg-desc {
margin: 5px;
}