From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Thu, 20 Sep 2018 00:57:34 +0000 (+0100) Subject: ui: Add 'next' button to DVR broadcast details. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1eb3a2a8a1b2e45bfb5adef8495dec5cfb25d3c;p=thirdparty%2Ftvheadend.git ui: Add 'next' button to DVR broadcast details. --- diff --git a/src/webui/static/app/dvr.js b/src/webui/static/app/dvr.js index aca6dc51c..d44728437 100644 --- a/src/webui/static/app/dvr.js +++ b/src/webui/static/app/dvr.js @@ -21,9 +21,16 @@ tvheadend.labelFormattingParser = function(description) { }else return description; }; -tvheadend.dvrDetails = function(uuid) { - - function showit(d) { +tvheadend.dvrDetails = function(grid, index) { + var current_index = index; + var win; + // We need a unique DOM id in case user opens two dialogs. + var nextButtonId = Ext.id(); + function getDialogTitle(d) { + var params = d[0].params; + return params[1].value; + } + function getDialogContent(d) { var params = d[0].params; var chicon = params[0].value; var title = params[1].value; @@ -115,7 +122,10 @@ tvheadend.dvrDetails = function(uuid) { content += '
'; if (chicon) content += ''; /* x-epg-bottom */ + return content + } + function getDialogButtons(title) { var buttons = []; var comboGetInfo = new Ext.form.ComboBox({ @@ -149,9 +159,23 @@ tvheadend.dvrDetails = function(uuid) { if (title) buttons.push(comboGetInfo); - var windowHeight = Ext.getBody().getViewSize().height - 150; - - var win = new Ext.Window({ + buttons.push(new Ext.Button({ + id: nextButtonId, + handler: nextEvent, + iconCls: 'next', + tooltip: _('Go to next event'), + text: _("Next"), + })); + + return buttons; + } // getDialogButtons + + function showit(d) { + var title = getDialogTitle(d); + var content = getDialogContent(d); + var buttons = getDialogButtons(title); + var windowHeight = Ext.getBody().getViewSize().height - 150; + win = new Ext.Window({ title: title, iconCls: 'info', layout: 'fit', @@ -165,10 +189,12 @@ tvheadend.dvrDetails = function(uuid) { }); win.show(); - } + } - tvheadend.loading(1); - Ext.Ajax.request({ + function load(store, index, cb) { + var uuid = store.getAt(index).id; + tvheadend.loading(1); + Ext.Ajax.request({ url: 'api/idnode/load', params: { uuid: uuid, @@ -180,12 +206,44 @@ tvheadend.dvrDetails = function(uuid) { success: function(d) { d = json_decode(d); tvheadend.loading(0), - showit(d); + cb(d); }, failure: function(d) { tvheadend.loading(0); } - }); + }); + } // load + + function nextEvent() { + var store = grid.getStore(); + ++current_index; + load(store,current_index,updateit); + } + + function updateit(d) { + var title = getDialogTitle(d); + var content = getDialogContent(d); + var buttons = getDialogButtons(title); + win.removeAll(); + // Can't update buttons at the same time... + win.update({html: content}); + win.setTitle(title); + // ...so remove the buttons and re-add them. + var tbar = win.fbar; + tbar.removeAll(); + Ext.each(buttons, function(btn) { + tbar.addButton(btn); + }); + // If we're at the end of the store then disable the next + // button. (getTotalCount is one-based). + if (current_index == store.getTotalCount() - 1) + tbar.getComponent(nextButtonId).disable(); + // Finally, relayout. + win.doLayout(); + } + + var store = grid.getStore(); + load(store,index,showit); }; tvheadend.dvrRowActions = function() { @@ -202,7 +260,7 @@ tvheadend.dvrRowActions = function() { iconCls: 'info', qtip: _('Recording details'), cb: function(grid, rec, act, row) { - new tvheadend.dvrDetails(grid.getStore().getAt(row).id); + new tvheadend.dvrDetails(grid, row); } } ],