From 129a86be208f90a0259c6a0512081bf4ff1731ac Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Wed, 23 May 2012 11:18:32 +0100 Subject: [PATCH] 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. --- src/webui/extjs.c | 49 ++++++++++++++++++++++++++++++++++++ src/webui/static/app/epg.js | 29 ++++++++++++++++++++- src/webui/static/app/ext.css | 6 +++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/webui/extjs.c b/src/webui/extjs.c index 61da08f0..f1d9a830 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -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); diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 471565ae..af0fdf12 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -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" + ""; } + content += '
'; + 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 += '
Alternative Broadcasts
'; + for ( i = 0; i < s.getTotalCount(); i++ ) { + var ab = s.getAt(i).data; + var dt = Date.parseDate(ab.start, 'U'); + html += '
' + dt.format('l H:i') + '   ' + ab.channel + '
'; + // 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', diff --git a/src/webui/static/app/ext.css b/src/webui/static/app/ext.css index 8501c884..d0b93e96 100644 --- a/src/webui/static/app/ext.css +++ b/src/webui/static/app/ext.css @@ -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; }