From 32ed32e4a4dd6b7878122532406f289645cf2b05 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 8 Jun 2014 11:46:54 +0100 Subject: [PATCH] WebUI: Add programme duration filtering --- src/dvr/dvr_autorec.c | 18 +++++++ src/webui/static/app/dvr.js | 30 ++++++++++++ src/webui/static/app/epg.js | 98 ++++++++++++++++++------------------- 3 files changed, 97 insertions(+), 49 deletions(-) diff --git a/src/dvr/dvr_autorec.c b/src/dvr/dvr_autorec.c index ec92ce3d..c9576b96 100644 --- a/src/dvr/dvr_autorec.c +++ b/src/dvr/dvr_autorec.c @@ -283,6 +283,24 @@ autorec_record_build(dvr_autorec_entry_t *dae) build_weekday_tags(l, dae->dae_weekdays); htsmsg_add_msg(e, "weekdays", l); +//IH +// This is where we add mindurationstring and maxdurationstring to the proceedings, I think +// Same question as to whether we deal with an offset, and absolute time (s), or the string. +// Increasingly, I think it should be the offset... although look at 'channel', above, that translates on the fly +// +// It also looks like we need to adjust dea to include the min/max fields (offset, absolute, string...) +// dvr_autorec_entry in dvr.h + +// More thoughts... +// +// Channel group and contentype jus start from their base values (string/value +// as relevant). Start time (approx) does the same, but changes as soon as you +// select, so it isn't primed with the existing value - we could default to 0 +// and max as well, 'you're changing it, here's the full range' sort of logic +// +// This way I don't care what it's set to beyond the string value for +// initial display purposes + htsmsg_add_str(e, "pri", dvr_val2pri(dae->dae_pri)); if (dae->dae_brand) diff --git a/src/webui/static/app/dvr.js b/src/webui/static/app/dvr.js index 6705884e..552a07b1 100644 --- a/src/webui/static/app/dvr.js +++ b/src/webui/static/app/dvr.js @@ -589,6 +589,33 @@ tvheadend.autoreceditor = function() { emptyText: 'Only include content...' }) }, +// IH + +// This will now bring through the real limit (i.e. seconds). We can look that up from the Store to turn it into an index +// or into a string equivalent, and populate the combobox with the same values so it will automatically match +// see epg.js for the lookup/conversion code + + { + header: "Min" + /*dataIndex: minduration, + editor: new Ext.ux.form.ComboBox({ + store: tvheadend.DurationStore, + mode: 'local', + valueField: 'value', + displayField: 'label' + })*/ + }, + { + header: "Max" + /*dataIndex: maxduration + editor: new Ext.ux.form.ComboBox({ + store: tvheadend.DurationStore, + mode: 'local', + valueField: 'value', + displayField: 'label' + })*/ + }, +// { header: "Weekdays", dataIndex: 'weekdays', @@ -786,6 +813,9 @@ tvheadend.dvr = function() { tvheadend.autorecRecord = Ext.data.Record.create(['enabled', 'title', 'serieslink', 'channel', 'tag', 'creator', 'contenttype', 'comment', + //IH + 'mindurationstring', 'maxdurationstring', + // 'weekdays', 'pri', 'approx_time', 'config_name']); tvheadend.autorecStore = new Ext.data.JsonStore({ diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 57eca0c9..0e200b56 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -29,6 +29,22 @@ tvheadend.contentGroupLookupName = function(code) { tvheadend.ContentGroupStore.setDefaultSort('code', 'ASC'); +//IH +tvheadend.DurationStore = new Ext.data.SimpleStore({ + storeId: 'durations', + id: 0, + fields: ['identifier','label','value'], + data: [['0','0 min',0], + ['1','20 min', 1200], + ['2','45 min', 2700], + ['3','90 min', 5400], + ['4','3 hrs', 10800], + ['5','6 hrs', 21600], + ['6','12 hrs', 43200], + ['7','24 hrs', 86400]] +}); +// + tvheadend.epgDetails = function(event) { var content = ''; @@ -410,13 +426,15 @@ tvheadend.epg = function() { //IH // Slider for duration selection, including tooltip function to display the appropriate string - + var tip = new Ext.slider.Tip({ getText: function(thumb){ return thumb.slider.durations[thumb.value]; } }); + // Note: is there any way to seed the slider labels in one go, versus with specific lookups? + var durationSlider = new Ext.slider.MultiSlider({ width: 100, values: [0, 7], @@ -424,47 +442,35 @@ tvheadend.epg = function() { maxValue: 7, increment: 1, durations: { - 0: '0 min', - 1: '20 min', - 2: '45 min', - 3: '90 min', - 4: '3 hrs', - 5: '6 hrs', - 6: '12 hrs', - 7: '24 hrs' - }, - seconds: { - 0: 0, - 1: 1200, - 2: 2700, - 3: 5400, - 4: 10800, - 5: 21600, - 6: 43200, - 7: 86400 + 0: tvheadend.DurationStore.getById(0).data.label, + 1: tvheadend.DurationStore.getById(1).data.label, + 2: tvheadend.DurationStore.getById(2).data.label, + 3: tvheadend.DurationStore.getById(3).data.label, + 4: tvheadend.DurationStore.getById(4).data.label, + 5: tvheadend.DurationStore.getById(5).data.label, + 6: tvheadend.DurationStore.getById(6).data.label, + 7: tvheadend.DurationStore.getById(7).data.label }, plugins: tip, listeners: { change: function(slider, thumb, value){ -// setduration(slider, thumb, value); setduration(slider); }} }); // function epgQueryClear() { +//IH - reset the pointers before deleting the underlying variables - otherwise they reset to 0/24h not null/null + durationSlider.setValue(0,0); + durationSlider.setValue(1,7); +// delete epgStore.baseParams.channel; delete epgStore.baseParams.tag; delete epgStore.baseParams.contenttype; -//IH - delete epgStore.baseParams.contenttypestring; -// delete epgStore.baseParams.title; //IH delete epgStore.baseParams.minduration; - delete epgStore.baseParams.mindurationstring; delete epgStore.baseParams.maxduration; - delete epgStore.baseParams.maxdurationstring; // epgFilterChannels.setValue(""); @@ -472,11 +478,6 @@ tvheadend.epg = function() { epgFilterContentGroup.setValue(""); epgFilterTitle.setValue(""); -//IH - durationSlider.setValue(0,0); - durationSlider.setValue(1,7); -// - epgStore.reload(); } @@ -497,31 +498,30 @@ tvheadend.epg = function() { epgFilterContentGroup.on('select', function(c, r) { if (epgStore.baseParams.contenttype !== r.data.code) { epgStore.baseParams.contenttype = r.data.code; -//IH - epgStore.baseParams.contenttypestring = tvheadend.contentGroupLookupName(r.data.code); - console.log('contentype is',epgStore.baseParams.contenttype,'contenttypestring is',epgStore.baseParams.contenttypestring); -// epgStore.reload(); } }); //IH ------------------ -// setduration = function(slider, thumb, value) { setduration = function(slider) { - console.log('durationSlider fired'); - var min = slider.getValue(0); var max = slider.getValue(1); + var minRec = tvheadend.DurationStore.getById(min); + var maxRec = tvheadend.DurationStore.getById(max); - console.log('Min:', min, "Duration:", slider.durations[min], slider.seconds[min]); - console.log('Max:', max, "Duration:", slider.durations[max], slider.seconds[max]); - - epgStore.baseParams.minduration = slider.seconds[min]; - epgStore.baseParams.mindurationstring = slider.durations[min]; - epgStore.baseParams.maxduration = slider.seconds[max]; - epgStore.baseParams.maxdurationstring = slider.durations[max]; + epgStore.baseParams.minduration = minRec.data.value; + epgStore.baseParams.maxduration = maxRec.data.value; + +//Debugging to test set and lookup + var index = tvheadend.DurationStore.find( 'value', epgStore.baseParams.minduration ); + var string = tvheadend.DurationStore.getById(index).data.label; + console.log('Min Duration record:', index, 'string:', string); + var index = tvheadend.DurationStore.find( 'value', epgStore.baseParams.maxduration ); + var string = tvheadend.DurationStore.getById(index).data.label; + console.log('Max Duration record:', index, 'string:', string); +// epgStore.reload(); }; // @@ -617,17 +617,17 @@ tvheadend.epg = function() { var tag = epgStore.baseParams.tag ? epgStore.baseParams.tag : "Don't care"; //IH - correct to display content type as a string as opposed to the underlying (lookup) code -// var contenttype = epgStore.baseParams.contenttype ? epgStore.baseParams.contenttype - var contenttype = epgStore.baseParams.contenttypestring ? epgStore.baseParams.contenttypestring + var contenttype = epgStore.baseParams.contenttype ? tvheadend.contentGroupLookupName(epgStore.baseParams.contenttype) // : "Don't care"; //IH - var minduration = epgStore.baseParams.mindurationstring ? epgStore.baseParams.mindurationstring + var minduration = epgStore.baseParams.minduration ? tvheadend.DurationStore.getById(tvheadend.DurationStore.find('value', epgStore.baseParams.minduration)).data.label : "Don't care"; - var maxduration = epgStore.baseParams.maxdurationstring ? epgStore.baseParams.maxdurationstring + var maxduration = epgStore.baseParams.maxduration ? tvheadend.DurationStore.getById(tvheadend.DurationStore.find('value', epgStore.baseParams.maxduration)).data.label : "Don't care"; // + Ext.MessageBox.confirm('Auto Recorder', 'This will create an automatic rule that ' + 'continuously scans the EPG for programmes ' //IH - correct typo @@ -652,7 +652,7 @@ tvheadend.epg = function() { // // IH: TO DO // -// Check that contenttype is still passed correctly (epgStore.baseParams.contenttype) to autorec vs the new contenttypestring +// Check that contenttype is still passed correctly (epgStore.baseParams.contenttype) to autorec vs the new contenttypestring - SHOULDN'T HAVE CHANGED // Add min/max to autorec rules (C) // Check they're displayed (js) //