From e3997201329f69302a16c3d190adaecf9ed9dbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sun, 19 Jul 2009 21:19:23 +0000 Subject: [PATCH] * Add support for merging one channel into another. Useful if you have multiple providers offering the same DVB service but with different names. --- debian/changelog | 4 ++ src/webui/extjs.c | 50 +++++++++++++++++ src/webui/static/app/chconf.js | 74 +++++++++++++++++++++++++- src/webui/static/app/ext.css | 4 ++ src/webui/static/icons/arrow_join.png | Bin 0 -> 626 bytes 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 src/webui/static/icons/arrow_join.png diff --git a/debian/changelog b/debian/changelog index e2f0b2e3..7804a3d8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,10 @@ hts-tvheadend (2.4) hts; urgency=low * Make sure channel <> service mappings are saved when edited from DVB service grid + * Add support for merging one channel into another. + Useful if you have multiple providers offering the same DVB service + but with different names. + hts-tvheadend (2.3) hts; urgency=low * A simple web interface has been added. To access it, visit diff --git a/src/webui/extjs.c b/src/webui/extjs.c index e9677e33..f6265251 100644 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -1472,6 +1472,53 @@ extjs_dvb_addmux(http_connection_t *hc, const char *remain, void *opaque) return 0; } + +/** + * + */ +static int +extjs_mergechannel(http_connection_t *hc, const char *remain, void *opaque) +{ + htsbuf_queue_t *hq = &hc->hc_reply; + const char *target = http_arg_get(&hc->hc_req_args, "targetID"); + htsmsg_t *out; + channel_t *src, *dst; + + if(remain == NULL || target == NULL) + return 400; + + pthread_mutex_lock(&global_lock); + + src = channel_find_by_identifier(atoi(remain)); + dst = channel_find_by_identifier(atoi(target)); + + if(src == NULL || dst == NULL) { + pthread_mutex_unlock(&global_lock); + return 404; + } + + out = htsmsg_create_map(); + + if(src != dst) { + channel_merge(dst, src); + htsmsg_add_u32(out, "success", 1); + } else { + + htsmsg_add_u32(out, "success", 0); + htsmsg_add_str(out, "msg", "Target same as source"); + } + + pthread_mutex_unlock(&global_lock); + + htsmsg_json_serialize(out, hq, 0); + htsmsg_destroy(out); + http_output_content(hc, "text/x-json; charset=UTF-8"); + return 0; + + +} + + /** * WEB user interface */ @@ -1490,6 +1537,9 @@ extjs_start(void) http_path_add("/dvrlist", NULL, extjs_dvrlist, ACCESS_WEB_INTERFACE); http_path_add("/ecglist", NULL, extjs_ecglist, ACCESS_WEB_INTERFACE); + http_path_add("/mergechannel", + NULL, extjs_mergechannel, ACCESS_ADMIN); + http_path_add("/dvb/adapter", NULL, extjs_dvbadapter, ACCESS_ADMIN); diff --git a/src/webui/static/app/chconf.js b/src/webui/static/app/chconf.js index a23902f5..26a9bc90 100644 --- a/src/webui/static/app/chconf.js +++ b/src/webui/static/app/chconf.js @@ -39,6 +39,61 @@ tvheadend.comet.on('channels', function(m) { }); +/** +* +*/ +tvheadend.mergeChannel = function(chan) { + + function doMerge() { + panel.getForm().submit({ + url:'mergechannel/' + chan.chid, + success: function() { + win.close(); + } + }); + } + + var panel = new Ext.FormPanel({ + frame:true, + border:true, + bodyStyle:'padding:5px', + labelAlign: 'right', + labelWidth: 110, + defaultType: 'textfield', + items: [ + new Ext.form.ComboBox({ + store: tvheadend.channels, + fieldLabel: 'Target channel', + name: 'targetchannel', + hiddenName: 'targetID', + editable: false, + allowBlank: false, + triggerAction: 'all', + mode: 'remote', + displayField:'name', + valueField:'chid', + emptyText: 'Select a channel...' + }) + ], + buttons: [{ + text: 'Merge', + handler: doMerge + }] + }); + + win = new Ext.Window({ + title: 'Merge channel ' + chan.name + ' into...', + layout: 'fit', + width: 500, + height: 120, + modal: true, + plain: true, + items: panel + }); + win.show(); + +} + /** * @@ -57,6 +112,22 @@ tvheadend.chconf = function() var fm = Ext.form; + var actions = new Ext.ux.grid.RowActions({ + header:'', + dataIndex: 'actions', + width: 45, + actions: [ + { + iconCls:'merge', + qtip:'Merge this channel with another channel', + cb: function(grid, record, action, row, col) { + tvheadend.mergeChannel(record.data); + } + } + ] + }); + + var cm = new Ext.grid.ColumnModel([ { header: "Name", @@ -108,7 +179,7 @@ tvheadend.chconf = function() valueField: 'identifier', displayField: 'name' }) - } + }, actions ]); @@ -206,6 +277,7 @@ tvheadend.chconf = function() title: 'Channels', iconCls: 'television', store: tvheadend.channels, + plugins: [actions], clicksToEdit: 2, cm: cm, viewConfig: { diff --git a/src/webui/static/app/ext.css b/src/webui/static/app/ext.css index c4e3e9de..2151cc42 100644 --- a/src/webui/static/app/ext.css +++ b/src/webui/static/app/ext.css @@ -181,6 +181,10 @@ background-image:url(../icons/wand.png) !important; } +.merge { + background-image:url(../icons/arrow_join.png) !important; +} + .x-smallhdr { float:left; diff --git a/src/webui/static/icons/arrow_join.png b/src/webui/static/icons/arrow_join.png new file mode 100644 index 0000000000000000000000000000000000000000..a128413d8892dede67a722b755a0e5a241e22cef GIT binary patch literal 626 zcmV-&0*(ENP)rYsPY01;xw|q+1XP62ZKNNf0i}lORw#-+^ z#eWjGI5)D~*%m(1>5Uva|KRl7dV8+T7A`G}x7k6Q#1cL#?^nclzafIHF=frdfxTM;5eU`G(t3ZL>h zq%#>uD8p~AzniHE4Br`SCb{0b_i(V?*A7x4Yp)<*$j^%sM0Q8xU9lJpTqqXT@nX^1 z5K1V0^Sv}x0%NoVtwF!n4+^nruOj~?pIo^7eBkL7YanOml9_B4qKQB-fL6CVNJ_L8 zqEZAEp`_BgUC2WzPE>s=#fe