From: Adam Sutton Date: Wed, 19 Dec 2012 22:17:18 +0000 (+0000) Subject: webui: add some processing of capabilities for dynamic tab inclusion. X-Git-Tag: v3.5~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=496808bbd496cd013f69e53bb9131f7d312dbb02;p=thirdparty%2Ftvheadend.git webui: add some processing of capabilities for dynamic tab inclusion. --- diff --git a/src/webui/extjs.c b/src/webui/extjs.c index efb79c80f..059417c0b 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -1941,6 +1941,26 @@ extjs_config(http_connection_t *hc, const char *remain, void *opaque) return 0; } +/** + * Capability check + */ +static int +extjs_capabilities(http_connection_t *hc, const char *remain, void *opaque) +{ + htsbuf_queue_t *hq = &hc->hc_reply; + htsmsg_t *l; + int i = 0; + l = htsmsg_create_list(); + while (tvheadend_capabilities[i]) { + htsmsg_add_str(l, NULL, tvheadend_capabilities[i]); + i++; + } + htsmsg_json_serialize(l, hq, 0); + htsmsg_destroy(l); + http_output_content(hc, "text/x-json; charset=UTF-8"); + return 0; +} + /** * WEB user interface */ @@ -1949,6 +1969,7 @@ extjs_start(void) { http_path_add("/about.html", NULL, page_about, ACCESS_WEB_INTERFACE); http_path_add("/extjs.html", NULL, extjs_root, ACCESS_WEB_INTERFACE); + http_path_add("/capabilities", NULL, extjs_capabilities, ACCESS_WEB_INTERFACE); http_path_add("/tablemgr", NULL, extjs_tablemgr, ACCESS_WEB_INTERFACE); http_path_add("/channels", NULL, extjs_channels, ACCESS_WEB_INTERFACE); http_path_add("/epggrab", NULL, extjs_epggrab, ACCESS_WEB_INTERFACE); diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index 3b44f6cad..2a1af2b7e 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -1,3 +1,6 @@ +tvheadend.accessupdate = null; +tvheadend.capabilties = null; + /** * Displays a help popup window */ @@ -27,6 +30,21 @@ tvheadend.help = function(title, pagename) { }); } +/* + * General capabilities + */ +Ext.Ajax.request({ + url: '/capabilities', + success: function(d) + { + if (d && d.responseText) + tvheadend.capabilities = Ext.util.JSON.decode(d.responseText); + if (tvheadend.capabilities && tvheadend.accessupdate) + accessUpdate(tvheadend.accessUpdate); + + } +}); + /** * Displays a mediaplayer using VLC plugin */ @@ -223,6 +241,7 @@ tvheadend.VLC = function(url) { * Obviosuly, access is verified in the server too. */ function accessUpdate(o) { + tvheadend.accessUpdate = o; if (o.dvr == true && tvheadend.dvrpanel == null) { tvheadend.dvrpanel = new tvheadend.dvr; @@ -237,12 +256,22 @@ function accessUpdate(o) { iconCls : 'wrench', items : [ new tvheadend.miscconf, new tvheadend.chconf, new tvheadend.epggrab, new tvheadend.cteditor, - new tvheadend.dvrsettings, new tvheadend.tvadapters, - new tvheadend.iptv, new tvheadend.acleditor, - new tvheadend.cwceditor, new tvheadend.capmteditor ] + new tvheadend.dvrsettings, + new tvheadend.iptv, new tvheadend.acleditor ] }); tvheadend.rootTabPanel.add(tvheadend.confpanel); } + if (tvheadend.capabilities && tvheadend.confpanel) { + if (tvheadend.capabilities.indexOf('linuxdvb') != -1 || + tvheadend.capabilities.indexOf('v4l') != -1) { + tvheadend.confpanel.add(new tvheadend.tvadapters); + } + if (tvheadend.capabilities.indexOf('cwc') != -1) { + tvheadend.confpanel.add(new tvheadend.cwceditor); + tvheadend.confpanel.add(new tvheadend.capmteditor); + } + tvheadend.confpanel.doLayout(); + } if (o.admin == true && tvheadend.statuspanel == null) { tvheadend.statuspanel = new tvheadend.status;