From 0fa4c91b5c48a0a5b79b458e53424655c2d8d4f0 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 2 Sep 2014 20:57:07 +0200 Subject: [PATCH] WEBUI JS: root panel cleanups, ancient file removal --- src/webui/extjs.c | 4 - src/webui/static/app/acleditor.js | 7 +- src/webui/static/app/capmteditor.js | 7 +- src/webui/static/app/config.js | 8 +- src/webui/static/app/cwceditor.js | 4 +- src/webui/static/app/dvr.js | 14 +- src/webui/static/app/epggrab.js | 4 +- src/webui/static/app/idnode.js | 17 +- src/webui/static/app/iptv.js | 318 --------------------------- src/webui/static/app/mpegts.js | 16 +- src/webui/static/app/timeshift.js | 4 +- src/webui/static/app/tvadapters.js | 8 +- src/webui/static/app/tvheadend.js | 129 ++++++----- src/webui/static/app/tvhlog.js | 4 +- src/webui/static/app/v4l.js | 321 ---------------------------- 15 files changed, 118 insertions(+), 747 deletions(-) delete mode 100644 src/webui/static/app/iptv.js delete mode 100644 src/webui/static/app/v4l.js diff --git a/src/webui/extjs.c b/src/webui/extjs.c index 07713144..586aaa33 100755 --- a/src/webui/extjs.c +++ b/src/webui/extjs.c @@ -153,10 +153,6 @@ extjs_root(http_connection_t *hc, const char *remain, void *opaque) extjs_load(hq, "static/app/esfilter.js"); #if ENABLE_MPEGTS extjs_load(hq, "static/app/mpegts.js"); -#endif - extjs_load(hq, "static/app/iptv.js"); -#if ENABLE_V4L - extjs_load(hq, "static/app/v4l.js"); #endif #if ENABLE_TIMESHIFT extjs_load(hq, "static/app/timeshift.js"); diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index dffc28c1..c9c514ac 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -2,16 +2,19 @@ * Access Control */ -tvheadend.acleditor = function(panel) +tvheadend.acleditor = function(panel, index) { - panel = new Ext.TabPanel({ + panel2 = new Ext.TabPanel({ activeTab: 0, autoScroll: true, title: 'Access Control', iconCls: 'group', + tabIndex: index, items: [] }); + tvheadend.paneladd(panel, panel2, index); + var list = 'enabled,username,password,prefix,streaming,adv_streaming,' + 'dvr,dvr_config,webui,admin,channel_min,channel_max,channel_tag,' + 'comment'; diff --git a/src/webui/static/app/capmteditor.js b/src/webui/static/app/capmteditor.js index 90141b5a..96599795 100644 --- a/src/webui/static/app/capmteditor.js +++ b/src/webui/static/app/capmteditor.js @@ -1,4 +1,5 @@ -tvheadend.capmteditor = function() { +tvheadend.capmteditor = function(panel, index) { + var fm = Ext.form; function setMetaAttr(meta, record) { @@ -104,6 +105,8 @@ tvheadend.capmteditor = function() { } }); - return new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec, + var p = new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec, [], store, 'config_capmt.html', 'key'); + + tvheadend.paneladd(panel, p, index); }; diff --git a/src/webui/static/app/config.js b/src/webui/static/app/config.js index cd92fc58..04daff73 100644 --- a/src/webui/static/app/config.js +++ b/src/webui/static/app/config.js @@ -31,7 +31,7 @@ tvheadend.comet.on('config', function(m) { } }); -tvheadend.miscconf = function() { +tvheadend.miscconf = function(panel, index) { /* * Basic Config @@ -240,7 +240,7 @@ tvheadend.miscconf = function() { if (imagecache_form) _items.push(imagecache_form); - var panel = new Ext.Panel({ + var mpanel = new Ext.Panel({ title: 'General', iconCls: 'wrench', border: false, @@ -251,6 +251,8 @@ tvheadend.miscconf = function() { tbar: [saveButton, '->', helpButton] }); + tvheadend.paneladd(panel, mpanel, index); + /* **************************************************************** * Load/Save * ***************************************************************/ @@ -297,6 +299,4 @@ tvheadend.miscconf = function() { } }); } - - return panel; }; diff --git a/src/webui/static/app/cwceditor.js b/src/webui/static/app/cwceditor.js index 62b88749..662b84a9 100644 --- a/src/webui/static/app/cwceditor.js +++ b/src/webui/static/app/cwceditor.js @@ -1,4 +1,4 @@ -tvheadend.cwceditor = function() { +tvheadend.cwceditor = function(panel, index) { var fm = Ext.form; function setMetaAttr(meta, record) { @@ -125,5 +125,5 @@ tvheadend.cwceditor = function() { } }); - return grid; + tvheadend.paneladd(panel, grid, index); }; diff --git a/src/webui/static/app/dvr.js b/src/webui/static/app/dvr.js index 17f15b44..90f8f089 100644 --- a/src/webui/static/app/dvr.js +++ b/src/webui/static/app/dvr.js @@ -263,17 +263,17 @@ tvheadend.autorec_editor = function(panel, index) { /** * */ -tvheadend.dvr = function() { - var panel = new Ext.TabPanel({ +tvheadend.dvr = function(panel, index) { + var p = new Ext.TabPanel({ activeTab: 0, autoScroll: true, title: 'Digital Video Recorder', iconCls: 'drive', items: [], }); - tvheadend.dvr_upcoming(panel, 0); - tvheadend.dvr_finished(panel, 1); - tvheadend.dvr_failed(panel, 2); - tvheadend.autorec_editor(panel, 3); - return panel; + tvheadend.dvr_upcoming(p, 0); + tvheadend.dvr_finished(p, 1); + tvheadend.dvr_failed(p, 2); + tvheadend.autorec_editor(p, 3); + return p; } diff --git a/src/webui/static/app/epggrab.js b/src/webui/static/app/epggrab.js index 92d6699b..7720891c 100644 --- a/src/webui/static/app/epggrab.js +++ b/src/webui/static/app/epggrab.js @@ -8,7 +8,7 @@ tvheadend.epggrabChannels = new Ext.data.JsonStore({ 'mod-name'] }); -tvheadend.epggrab = function() { +tvheadend.epggrab = function(panel, index) { /* **************************************************************** * Data @@ -394,5 +394,5 @@ tvheadend.epggrab = function() { }); } - return confpanel; + tvheadend.paneladd(panel, confpanel, index); }; diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index e4e6cb01..61a5faf4 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -1240,10 +1240,7 @@ tvheadend.idnode_grid = function(panel, conf) page.changePage(0); }); - if (conf.tabIndex != null) - panel.insert(conf.tabIndex, grid); - else - panel.add(grid); + tvheadend.paneladd(panel, grid, conf.tabIndex); /* Add comet listeners */ var update = function(o) { @@ -1496,10 +1493,7 @@ tvheadend.idnode_form_grid = function(panel, conf) items: [grid] }); - if (conf.tabIndex != null) - panel.insert(conf.tabIndex, mpanel); - else - panel.add(mpanel); + tvheadend.paneladd(panel, mpanel, conf.tabIndex); /* Add comet listeners */ var update = function(o) { @@ -1512,7 +1506,7 @@ tvheadend.idnode_form_grid = function(panel, conf) /* * IDNode Tree */ -tvheadend.idnode_tree = function(conf) +tvheadend.idnode_tree = function(panel, conf) { var current = null; var events = {}; @@ -1576,7 +1570,7 @@ tvheadend.idnode_tree = function(conf) } }); - var panel = new Ext.Panel({ + var mpanel = new Ext.Panel({ title: conf.title || '', layout: 'hbox', flex: 1, @@ -1588,11 +1582,10 @@ tvheadend.idnode_tree = function(conf) items: [tree] }); + tvheadend.paneladd(panel, mpanel, conf.tabIndex); tree.on('beforerender', function() { // To be honest this isn't quite right, but it'll do tree.expandAll(); }); - - return panel; }; diff --git a/src/webui/static/app/iptv.js b/src/webui/static/app/iptv.js deleted file mode 100644 index 83609b35..00000000 --- a/src/webui/static/app/iptv.js +++ /dev/null @@ -1,318 +0,0 @@ -/** - * IPTV service grid - */ -tvheadend.iptv = function(adapterId) { - - var servicetypeStore = new Ext.data.JsonStore({ - root: 'entries', - id: 'val', - url: '/iptv/services', - baseParams: { - op: 'servicetypeList' - }, - fields: ['val', 'str'], - autoLoad: false, - sortInfo: { - field: 'channelname', - direction: 'ASC' - } - }); - - var fm = Ext.form; - - - var actions = new Ext.ux.grid.RowActions({ - header: '', - dataIndex: 'actions', - width: 45, - actions: [{ - iconCls: 'info', - qtip: 'Detailed information about service', - cb: function(grid, record, action, row, col) { - Ext.Ajax.request({ - url: "servicedetails/" + record.id, - success: function(response, options) { - r = Ext.util.JSON.decode(response.responseText); - tvheadend.showTransportDetails(r); - } - }); - } - }] - }); - - var cm = new Ext.grid.ColumnModel({ - defaultSortable: true, - columns: [ - { - xtype: 'checkcolumn', - header: "Enabled", - dataIndex: 'enabled', - width: 45 - }, - { - header: "Channel name", - dataIndex: 'channelname', - width: 150, - renderer: function(value, metadata, record, row, col, store) { - return value ? value - : 'Unmapped'; - }, - editor: new fm.ComboBox({ - store: tvheadend.channels, - allowBlank: true, - typeAhead: true, - minChars: 2, - lazyRender: true, - triggerAction: 'all', - mode: 'local', - displayField: 'name' - }) - }, - { - header: "Interface", - dataIndex: 'interface', - width: 100, - renderer: function(value, metadata, record, row, col, store) { - return value ? value : 'Unset'; - }, - editor: new fm.TextField({ - allowBlank: false - }) - }, - { - header: "Group", - dataIndex: 'group', - width: 100, - renderer: function(value, metadata, record, row, col, store) { - return value ? value : 'Unset'; - }, - editor: new fm.TextField({ - allowBlank: false - }) - }, - { - header: "UDP Port", - dataIndex: 'port', - width: 60, - editor: new fm.NumberField({ - minValue: 1, - maxValue: 65535 - }) - }, - { - header: "Service ID", - dataIndex: 'sid', - width: 50, - hidden: true - }, - { - header: 'Service Type', - width: 100, - dataIndex: 'stype', - hidden: true, - editor: new fm.ComboBox({ - valueField: 'val', - displayField: 'str', - forceSelection: false, - editable: false, - mode: 'local', - triggerAction: 'all', - store: servicetypeStore - }), - renderer: function(value, metadata, record, row, col, store) { - var val = value ? servicetypeStore.getById(value) : null; - return val ? val.get('str') - : 'Unset'; - } - }, { - header: "PMT PID", - dataIndex: 'pmt', - width: 50, - hidden: true - }, { - header: "PCR PID", - dataIndex: 'pcr', - width: 50, - hidden: true - }, actions]}); - - var rec = Ext.data.Record.create(['id', 'enabled', 'channelname', - 'interface', 'group', 'port', 'sid', 'pmt', 'pcr', 'stype']); - - var store = new Ext.data.JsonStore({ - root: 'entries', - fields: rec, - url: "iptv/services", - autoLoad: true, - id: 'id', - baseParams: { - op: "get" - }, - listeners: { - 'update': function(s, r, o) { - d = s.getModifiedRecords().length === 0 - saveBtn.setDisabled(d); - rejectBtn.setDisabled(d); - } - } - }); - - /* - var storeReloader = new Ext.util.DelayedTask(function() { - store.reload() - }); - - tvheadend.comet.on('dvbService', function(m) { - storeReloader.delay(500); - }); - */ - - function addRecord() { - Ext.Ajax.request({ - url: "iptv/services", - params: { - op: "create" - }, - failure: function(response, options) { - Ext.MessageBox.alert('Server Error', - 'Unable to generate new record'); - }, - success: function(response, options) { - var responseData = Ext.util.JSON.decode(response.responseText); - var p = new rec(responseData, responseData.id); - grid.stopEditing(); - store.insert(0, p); - grid.startEditing(0, 0); - } - }); - } - ; - - function delSelected() { - var selectedKeys = grid.selModel.selections.keys; - if (selectedKeys.length > 0) { - Ext.MessageBox.confirm('Message', - 'Do you really want to delete selection?', deleteRecord); - } - else { - Ext.MessageBox.alert('Message', - 'Please select at least one item to delete'); - } - } - ; - - function deleteRecord(btn) { - if (btn === 'yes') { - var selectedKeys = grid.selModel.selections.keys; - - Ext.Ajax.request({ - url: "iptv/services", - params: { - op: "delete", - entries: Ext.encode(selectedKeys) - }, - failure: function(response, options) { - Ext.MessageBox.alert('Server Error', 'Unable to delete'); - }, - success: function(response, options) { - store.reload(); - } - }); - } - } - - function saveChanges() { - var mr = store.getModifiedRecords(); - var out = new Array(); - for (var x = 0; x < mr.length; x++) { - v = mr[x].getChanges(); - out[x] = v; - out[x].id = mr[x].id; - } - - Ext.Ajax.request({ - url: "iptv/services", - params: { - op: "update", - entries: Ext.encode(out) - }, - success: function(response, options) { - store.commitChanges(); - }, - failure: function(response, options) { - Ext.MessageBox.alert('Message', response.statusText); - } - }); - } - - var delButton = new Ext.Toolbar.Button({ - tooltip: 'Delete one or more selected rows', - iconCls: 'remove', - text: 'Delete selected services', - handler: delSelected, - disabled: true - }); - - var saveBtn = new Ext.Toolbar.Button({ - tooltip: 'Save any changes made (Changed cells have red borders).', - iconCls: 'save', - text: "Save changes", - handler: saveChanges, - disabled: true - }); - - var rejectBtn = new Ext.Toolbar.Button({ - tooltip: 'Revert any changes made (Changed cells have red borders).', - iconCls: 'undo', - text: "Revert changes", - handler: function() { - store.rejectChanges(); - }, - disabled: true - }); - - var selModel = new Ext.grid.RowSelectionModel({ - singleSelect: false - }); - - var grid = new Ext.grid.EditorGridPanel({ - stripeRows: true, - title: 'IPTV', - iconCls: 'iptv', - plugins: [actions], - store: store, - clicksToEdit: 2, - cm: cm, - viewConfig: { - forceFit: true - }, - selModel: selModel, - tbar: [ - { - tooltip: 'Create a new entry on the server. ' - + 'The new entry is initially disabled so it must be enabled ' - + 'before it start taking effect.', - iconCls: 'add', - text: 'Add service', - handler: addRecord - }, '-', delButton, '-', saveBtn, rejectBtn, '->', - { - text: 'Help', - handler: function() { - new tvheadend.help('IPTV', 'config_iptv.html'); - } - }] - }); - - store.on('update', function(s, r, o) { - d = s.getModifiedRecords().length === 0; - saveBtn.setDisabled(d); - rejectBtn.setDisabled(d); - }); - - selModel.on('selectionchange', function(self) { - delButton.setDisabled(self.getCount() === 0); - }); - - return grid; -}; diff --git a/src/webui/static/app/mpegts.js b/src/webui/static/app/mpegts.js index c2d7ec1e..9a852d29 100644 --- a/src/webui/static/app/mpegts.js +++ b/src/webui/static/app/mpegts.js @@ -25,13 +25,13 @@ tvheadend.comet.on('mpegts_network', function() { tvheadend.network_list.reload(); }); -tvheadend.networks = function(panel) +tvheadend.networks = function(panel, index) { tvheadend.idnode_grid(panel, { url: 'api/mpegts/network', titleS: 'Network', titleP: 'Networks', - tabIndex: 1, + tabIndex: index, help: function() { new tvheadend.help('Networks', 'config_networks.html'); }, @@ -56,13 +56,13 @@ tvheadend.networks = function(panel) }); }; -tvheadend.muxes = function(panel) +tvheadend.muxes = function(panel, index) { tvheadend.idnode_grid(panel, { url: 'api/mpegts/mux', titleS: 'Mux', titleP: 'Muxes', - tabIndex: 2, + tabIndex: index, hidemode: true, help: function() { new tvheadend.help('Muxes', 'config_muxes.html'); @@ -193,7 +193,7 @@ tvheadend.show_service_streams = function(data) { win.show(); }; -tvheadend.services = function(panel) +tvheadend.services = function(panel, index) { var mapButton = new Ext.Toolbar.Button({ tooltip: 'Map services to channels', @@ -233,7 +233,7 @@ tvheadend.services = function(panel) url: 'api/mpegts/service', titleS: 'Service', titleP: 'Services', - tabIndex: 3, + tabIndex: index, hidemode: true, add: false, del: false, @@ -262,13 +262,13 @@ tvheadend.services = function(panel) }); }; -tvheadend.mux_sched = function(panel) +tvheadend.mux_sched = function(panel, index) { tvheadend.idnode_grid(panel, { url: 'api/mpegts/mux_sched', titleS: 'Mux Scheduler', titleP: 'Mux Schedulers', - tabIndex: 4, + tabIndex: index, help: function() { new tvheadend.help('Mux Schedulers', 'config_muxsched.html'); }, diff --git a/src/webui/static/app/timeshift.js b/src/webui/static/app/timeshift.js index 3e4ed45a..8653b330 100644 --- a/src/webui/static/app/timeshift.js +++ b/src/webui/static/app/timeshift.js @@ -1,4 +1,4 @@ -tvheadend.timeshift = function() { +tvheadend.timeshift = function(panel, index) { /* **************************************************************** * Data @@ -177,5 +177,5 @@ tvheadend.timeshift = function() { }); } - return confpanel; + tvheadend.paneladd(panel, confpanel, index); }; diff --git a/src/webui/static/app/tvadapters.js b/src/webui/static/app/tvadapters.js index 7a5330be..1f0aaf50 100644 --- a/src/webui/static/app/tvadapters.js +++ b/src/webui/static/app/tvadapters.js @@ -1,9 +1,13 @@ -tvheadend.tvadapters = function() { - return tvheadend.idnode_tree({ +tvheadend.tvadapters = function(panel, index) { + + tvheadend.idnode_tree(panel, { url: 'api/hardware/tree', title: 'TV adapters', + tabIndex: index, help: function() { new tvheadend.help('TV adapters', 'config_tvadapters.html'); } }); + + return panel; }; diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index 3e8d93df..1ab34477 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -1,9 +1,7 @@ tvheadend.accessupdate = null; tvheadend.capabilties = null; -tvheadend.conf_chepg = null; -tvheadend.conf_dvbin = null; -tvheadend.conf_tsdvr = null; -tvheadend.conf_csa = null; +tvheadend.dvrpanel = null; +tvheadend.confpanel = null; /* State Provider */ Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ @@ -40,6 +38,13 @@ tvheadend.help = function(title, pagename) { }); }; +tvheadend.paneladd = function(dst, add, idx) { + if (idx != null) + dst.insert(idx, add); + else + dst.add(add); +}; + tvheadend.Ajax = function(conf) { var orig_success = conf.success; var orig_failure = conf.failure; @@ -248,102 +253,108 @@ function accessUpdate(o) { } if (o.admin == true && tvheadend.confpanel == null) { - var tabs1 = [ - new tvheadend.miscconf, - new tvheadend.acleditor - ]; - var tabs2; - /* DVB inputs */ - tabs2 = []; - if (tvheadend.capabilities.indexOf('linuxdvb') !== -1 || - tvheadend.capabilities.indexOf('satip_client') !== -1 || - tvheadend.capabilities.indexOf('v4l') !== -1) { - tabs2.push(new tvheadend.tvadapters); - } - /* - tabs2.push(new tvheadend.iptv); - */ - tvheadend.conf_dvbin = new Ext.TabPanel({ + var cp = new Ext.TabPanel({ + activeTab: 0, + autoScroll: true, + title: 'Configuration', + iconCls: 'wrench', + items: [] + }); + + tvheadend.miscconf(cp); + + tvheadend.acleditor(cp); + + /* DVB inputs, networks, muxes, services */ + var dvbin = new Ext.TabPanel({ activeTab: 0, autoScroll: true, title: 'DVB Inputs', iconCls: 'hardware', - items: tabs2 + items: [] }); - tvheadend.networks(tvheadend.conf_dvbin); - tvheadend.muxes(tvheadend.conf_dvbin); - tvheadend.services(tvheadend.conf_dvbin); - tvheadend.mux_sched(tvheadend.conf_dvbin); - tabs1.push(tvheadend.conf_dvbin); + + var idx = 0; + + if (tvheadend.capabilities.indexOf('linuxdvb') !== -1 || + tvheadend.capabilities.indexOf('satip_client') !== -1 || + tvheadend.capabilities.indexOf('v4l') !== -1) + tvheadend.tvadapters(dvbin); + tvheadend.networks(dvbin); + tvheadend.muxes(dvbin); + tvheadend.services(dvbin); + tvheadend.mux_sched(dvbin); + + cp.add(dvbin); /* Channel / EPG */ - tvheadend.conf_chepg = new Ext.TabPanel({ + var chepg = new Ext.TabPanel({ activeTab: 0, autoScroll: true, title: 'Channel / EPG', iconCls: 'television', items: [] }); - tvheadend.channel_tab(tvheadend.conf_chepg, 0); - tvheadend.cteditor(tvheadend.conf_chepg, 1); - tvheadend.conf_chepg.insert(2, new tvheadend.epggrab); - tabs1.push(tvheadend.conf_chepg); + tvheadend.channel_tab(chepg); + tvheadend.cteditor(chepg); + tvheadend.epggrab(chepg); + + cp.add(chepg); /* DVR / Timeshift */ - tvheadend.conf_tsdvr = new Ext.TabPanel({ + var tsdvr = new Ext.TabPanel({ activeTab: 0, autoScroll: true, title: 'Recording', iconCls: 'drive', items: [] }); - tvheadend.dvr_settings(tvheadend.conf_tsdvr, 0); + tvheadend.dvr_settings(tsdvr); if (tvheadend.capabilities.indexOf('timeshift') !== -1) - tvheadend.conf_tsdvr.add(new tvheadend.timeshift); - tabs1.push(tvheadend.conf_tsdvr); + tvheadend.timeshift(tsdvr); + + cp.add(tsdvr); /* CSA */ - tabs2 = []; - if (tvheadend.capabilities.indexOf('cwc') !== -1) - tabs2.push(new tvheadend.cwceditor); - if (tvheadend.capabilities.indexOf('capmt') !== -1) - tabs2.push(new tvheadend.capmteditor); - if (tabs2.length > 0) { - tvheadend.conf_csa = new Ext.TabPanel({ + if (tvheadend.capabilities.indexOf('cwc') !== -1 || + tvheadend.capabilities.indexOf('capmt') !== -1) { + + var csa = new Ext.TabPanel({ activeTab: 0, autoScroll: true, title: 'CSA', iconCls: 'key', - items: tabs2 + items: [] }); - tabs1.push(tvheadend.conf_csa); + + if (tvheadend.capabilities.indexOf('cwc') !== -1) + tvheadend.cwceditor(csa); + if (tvheadend.capabilities.indexOf('capmt') !== -1) + tvheadend.capmteditor(csa); + + cp.add(csa); } /* Stream Config */ - tvheadend.conf_stream = new Ext.TabPanel({ + var stream = new Ext.TabPanel({ activeTab: 0, autoScroll: true, title: 'Stream', iconCls: 'stream_config', items: [] }); - tvheadend.esfilter_tab(tvheadend.conf_stream); - tabs1.push(tvheadend.conf_stream); + tvheadend.esfilter_tab(stream); + + cp.add(stream); /* Debug */ - tabs1.push(new tvheadend.tvhlog); + tvheadend.tvhlog(cp); - tvheadend.confpanel = new Ext.TabPanel({ - activeTab: 0, - autoScroll: true, - title: 'Configuration', - iconCls: 'wrench', - items: tabs1 - }); - - tvheadend.rootTabPanel.add(tvheadend.confpanel); - tvheadend.confpanel.doLayout(); + /* Finish */ + tvheadend.rootTabPanel.add(cp); + tvheadend.confpanel = cp; + cp.doLayout(); } if (o.admin == true && tvheadend.statuspanel == null) { @@ -412,7 +423,7 @@ tvheadend.app = function() { tvheadend.rootTabPanel = new Ext.TabPanel({ region: 'center', activeTab: 0, - items: [new tvheadend.epg] + items: [tvheadend.epg()] }); var viewport = new Ext.Viewport({ diff --git a/src/webui/static/app/tvhlog.js b/src/webui/static/app/tvhlog.js index 8062b7ac..665cd710 100644 --- a/src/webui/static/app/tvhlog.js +++ b/src/webui/static/app/tvhlog.js @@ -1,4 +1,4 @@ -tvheadend.tvhlog = function() { +tvheadend.tvhlog = function(panel, index) { /* * Basic Config */ @@ -115,5 +115,5 @@ tvheadend.tvhlog = function() { }); } - return confpanel; + tvheadend.paneladd(panel, confpanel, index); }; diff --git a/src/webui/static/app/v4l.js b/src/webui/static/app/v4l.js deleted file mode 100644 index ab355e10..00000000 --- a/src/webui/static/app/v4l.js +++ /dev/null @@ -1,321 +0,0 @@ -/** - * V4L adapter details - */ -tvheadend.v4l_adapter_general = function(adapterData) { - - adapterId = adapterData.identifier; - - /* Conf panel */ - - var confreader = new Ext.data.JsonReader({ - root: 'v4ladapters' - }, ['name', 'logging']); - - function saveConfForm() { - confform.getForm().submit({ - url: 'v4l/adapter/' + adapterId, - params: { - 'op': 'save' - }, - waitMsg: 'Saving Data...' - }); - } - - var items = [{ - fieldLabel: 'Adapter name', - name: 'name', - width: 250 - }, new Ext.form.Checkbox({ - fieldLabel: 'Detailed logging', - name: 'logging' - })]; - - var confform = new Ext.FormPanel({ - title: 'Adapter configuration', - columnWidth: .40, - frame: true, - border: true, - disabled: true, - style: 'margin:10px', - bodyStyle: 'padding:5px', - labelAlign: 'right', - labelWidth: 110, - waitMsgTarget: true, - reader: confreader, - defaultType: 'textfield', - items: items, - buttons: [{ - text: 'Save', - handler: saveConfForm - }] - }); - - confform.getForm().load({ - url: 'v4l/adapter/' + adapterId, - params: { - 'op': 'load' - }, - success: function(form, action) { - confform.enable(); - } - }); - - /** - * Information / capabilities panel - */ - - var infoTemplate = new Ext.XTemplate( - '

Hardware

' - + '

Device path:

{path}' + '

Device name:

{devicename}' - + '

Status

' - + '

Currently tuned to:

{currentMux} '); - - var infoPanel = new Ext.Panel({ - title: 'Information and capabilities', - columnWidth: .35, - frame: true, - border: true, - style: 'margin:10px', - bodyStyle: 'padding:5px', - html: infoTemplate.applyTemplate(adapterData) - }); - - /** - * Main adapter panel - */ - var panel = new Ext.Panel({ - title: 'General', - layout: 'column', - items: [confform, infoPanel] - }); - - /** - * Subscribe and react on updates for this adapter - */ - tvheadend.tvAdapterStore.on('update', function(s, r, o) { - if (r.data.identifier !== adapterId) - return; - infoTemplate.overwrite(infoPanel.body, r.data); - }); - - return panel; -}; - -/** - * V4L service grid - */ -tvheadend.v4l_services = function(adapterId) { - - var fm = Ext.form; - - var enabledColumn = new Ext.grid.CheckColumn({ - header: "Enabled", - dataIndex: 'enabled', - width: 45 - }); - - var cm = new Ext.grid.ColumnModel({ - defaultSortable: true, - columns: [ - enabledColumn, { - header: "Channel name", - dataIndex: 'channelname', - width: 150, - renderer: function(value, metadata, record, row, col, store) { - return value ? value : 'Unmapped'; - }, - editor: new fm.ComboBox({ - store: tvheadend.channels, - allowBlank: true, - typeAhead: true, - minChars: 2, - lazyRender: true, - triggerAction: 'all', - mode: 'local', - displayField: 'name' - }) - }, { - header: "Frequency", - dataIndex: 'frequency', - width: 60, - editor: new fm.NumberField({ - minValue: 10000, - maxValue: 1000000000 - }) - }]}); - - var rec = Ext.data.Record.create(['id', 'enabled', 'channelname', - 'frequency']); - - var store = new Ext.data.JsonStore({ - root: 'entries', - fields: rec, - url: "v4l/services/" + adapterId, - autoLoad: true, - id: 'id', - baseParams: { - op: "get" - }, - listeners: { - 'update': function(s, r, o) { - d = s.getModifiedRecords().length === 0; - saveBtn.setDisabled(d); - rejectBtn.setDisabled(d); - } - } - }); - - function addRecord() { - Ext.Ajax.request({ - url: "v4l/services/" + adapterId, - params: { - op: "create" - }, - failure: function(response, options) { - Ext.MessageBox.alert('Server Error', - 'Unable to generate new record'); - }, - success: function(response, options) { - var responseData = Ext.util.JSON.decode(response.responseText); - var p = new rec(responseData, responseData.id); - grid.stopEditing(); - store.insert(0, p); - grid.startEditing(0, 0); - } - }); - }; - - function delSelected() { - var selectedKeys = grid.selModel.selections.keys; - if (selectedKeys.length > 0) { - Ext.MessageBox.confirm('Message', - 'Do you really want to delete selection?', deleteRecord); - } - else { - Ext.MessageBox.alert('Message', - 'Please select at least one item to delete'); - } - }; - - function deleteRecord(btn) { - if (btn === 'yes') { - var selectedKeys = grid.selModel.selections.keys; - - Ext.Ajax.request({ - url: "v4l/services/" + adapterId, - params: { - op: "delete", - entries: Ext.encode(selectedKeys) - }, - failure: function(response, options) { - Ext.MessageBox.alert('Server Error', 'Unable to delete'); - }, - success: function(response, options) { - store.reload(); - } - }); - } - } - - function saveChanges() { - var mr = store.getModifiedRecords(); - var out = new Array(); - for (var x = 0; x < mr.length; x++) { - v = mr[x].getChanges(); - out[x] = v; - out[x].id = mr[x].id; - } - - Ext.Ajax.request({ - url: "v4l/services/" + adapterId, - params: { - op: "update", - entries: Ext.encode(out) - }, - success: function(response, options) { - store.commitChanges(); - }, - failure: function(response, options) { - Ext.MessageBox.alert('Message', response.statusText); - } - }); - } - - var delButton = new Ext.Toolbar.Button({ - tooltip: 'Delete one or more selected rows', - iconCls: 'remove', - text: 'Delete selected services', - handler: delSelected, - disabled: true - }); - - var saveBtn = new Ext.Toolbar.Button({ - tooltip: 'Save any changes made (Changed cells have red borders).', - iconCls: 'save', - text: "Save changes", - handler: saveChanges, - disabled: true - }); - - var rejectBtn = new Ext.Toolbar.Button({ - tooltip: 'Revert any changes made (Changed cells have red borders).', - iconCls: 'undo', - text: "Revert changes", - handler: function() { - store.rejectChanges(); - }, - disabled: true - }); - - var selModel = new Ext.grid.RowSelectionModel({ - singleSelect: false - }); - - var grid = new Ext.grid.EditorGridPanel({ - stripeRows: true, - title: 'Services', - plugins: [enabledColumn], - store: store, - clicksToEdit: 2, - cm: cm, - viewConfig: { - forceFit: true - }, - selModel: selModel, - tbar: [ - { - tooltip: 'Create a new entry on the server. ' - + 'The new entry is initially disabled so it must be enabled ' - + 'before it start taking effect.', - iconCls: 'add', - text: 'Add service', - handler: addRecord - }, '-', delButton, '-', saveBtn, rejectBtn] - }); - - store.on('update', function(s, r, o) { - d = s.getModifiedRecords().length === 0; - saveBtn.setDisabled(d); - rejectBtn.setDisabled(d); - }); - - selModel.on('selectionchange', function(self) { - delButton.setDisabled(self.getCount() === 0); - }); - - return grid; -}; - -/** - * - */ -tvheadend.v4l_adapter = function(data) { - var panel = new Ext.TabPanel({ - border: false, - activeTab: 0, - autoScroll: true, - items: [new tvheadend.v4l_adapter_general(data), - new tvheadend.v4l_services(data.identifier)] - }); - return panel; -};