]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
webui: Add Previous button to epg and dvr, fix minor issues (If you select the first...
authorpablozg <pablozg@gmail.com>
Fri, 21 Sep 2018 19:34:28 +0000 (21:34 +0200)
committerperexg <perex@perex.cz>
Wed, 26 Sep 2018 15:30:34 +0000 (17:30 +0200)
src/webui/static/app/dvr.js
src/webui/static/app/epg.js

index 4a642a193177121d815bb3a8da5e9cc2d2e470dc..3863e7762b4e9204958dd12902f6977efa56f3dc 100644 (file)
@@ -26,6 +26,7 @@ tvheadend.dvrDetails = function(grid, index) {
     var win;
     // We need a unique DOM id in case user opens two dialogs.
     var nextButtonId = Ext.id();
+    var previousButtonId = Ext.id();
     // Our title is passed to search functions (such as imdb)
     // So always ensure this does not contain channel info.
     function getTitle(d) {
@@ -44,6 +45,7 @@ tvheadend.dvrDetails = function(grid, index) {
       if (channelname && channelname.length) fields.push(channelname);
       return fields.join(' - ');
     }
+
     function getDialogContent(d) {
         var params = d[0].params;
         var chicon = params[0].value;
@@ -173,6 +175,13 @@ tvheadend.dvrDetails = function(grid, index) {
         if (title)
             buttons.push(comboGetInfo);
 
+        buttons.push(new Ext.Button({
+              id: previousButtonId,
+              handler: previousEvent,
+              iconCls: 'previous',
+              tooltip: _('Go to previous event'),
+              text: _("Previous"),
+        }));
         buttons.push(new Ext.Button({
             id: nextButtonId,
             handler: nextEvent,
@@ -201,11 +210,11 @@ tvheadend.dvrDetails = function(grid, index) {
             buttons: buttons,
             html: content
         });
+       win.show();
+       checkButtonAvailability(win.fbar)
+  }
 
-        win.show();
-     }
-
-    function load(store, index, cb) {
+  function load(store, index, cb) {
       var uuid = store.getAt(index).id;
       tvheadend.loading(1);
       Ext.Ajax.request({
@@ -226,15 +235,27 @@ tvheadend.dvrDetails = function(grid, index) {
             tvheadend.loading(0);
         }
       });
-    }                           // load
-
-    function nextEvent() {
-      var store = grid.getStore();
-        ++current_index;
-        load(store,current_index,updateit);
-      }
+  }                           // load
+
+  function previousEvent() {
+      --current_index;
+      load(store,current_index,updateit);
+  }
+  function nextEvent() {
+      ++current_index;
+      load(store,current_index,updateit);
+  }
+
+  function checkButtonAvailability(toolBar){
+        // If we're at the end of the store then disable the next
+        // or previous button.  (getTotalCount is one-based).
+        if (current_index == store.getTotalCount() - 1)
+          toolBar.getComponent(nextButtonId).disable();
+        if (current_index == 0)
+          toolBar.getComponent(previousButtonId).disable();
+    }
 
-     function updateit(d) {
+  function updateit(d) {
         var dialogTitle = getDialogTitle(d);
         var content = getDialogContent(d);
         var buttons = getDialogButtons(getTitle(d));
@@ -246,15 +267,12 @@ tvheadend.dvrDetails = function(grid, index) {
         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();
+            tbar.addButton(btn);
+        });
+        checkButtonAvailability(tbar);
         // Finally, relayout.
         win.doLayout();
-     }
+  }
 
     var store = grid.getStore();
     load(store,index,showit);
index 28f373885b4b7833de4d88a0c2e2b32cafa3ee4d..9a9743567e8fa96892fb436c0902a264175ee08d 100644 (file)
@@ -110,6 +110,7 @@ tvheadend.filmAffinityLanguage = function() {
 tvheadend.epgDetails = function(grid, index) {
     // We need a unique DOM id in case user opens two dialogs.
     var nextButtonId = Ext.id();
+    var previousButtonId = Ext.id();
     var confcomboButtonId = Ext.id();
 
     function getDialogTitle(event) {
@@ -334,6 +335,13 @@ tvheadend.epgDetails = function(grid, index) {
               tooltip: _('Create an automatic recording rule to record all future programs that match the current query.'),
               text: event.serieslinkUri ? _("Record series") : _("Autorec")
           }));
+          buttons.push(new Ext.Button({
+              id: previousButtonId,
+              handler: previousEvent,
+              iconCls: 'previous',
+              tooltip: _('Go to previous event'),
+              text: _("Previous"),
+          }));
           buttons.push(new Ext.Button({
               id: nextButtonId,
               handler: nextEvent,
@@ -355,6 +363,7 @@ tvheadend.epgDetails = function(grid, index) {
 
     var current_index = index;
     var event = grid.getStore().getAt(index).data;
+    var store = grid.getStore();
     var content = getDialogContent(event);
     var buttons = getDialogButtons();
     var windowHeight = Ext.getBody().getViewSize().height - 150;
@@ -363,7 +372,7 @@ tvheadend.epgDetails = function(grid, index) {
         title: title,
         iconCls: 'broadcast_details',
         layout: 'fit',
-        width: 800,
+        width: 850,
         height: windowHeight,
         constrainHeader: true,
         buttons: buttons,
@@ -372,6 +381,7 @@ tvheadend.epgDetails = function(grid, index) {
         html: content
     });
     win.show();
+    checkButtonAvailability(win.fbar);
 
     function playProgram() {
         var title = event.title;
@@ -381,10 +391,26 @@ tvheadend.epgDetails = function(grid, index) {
                     '?title=' + encodeURIComponent(title), '_blank');
     }
 
+    function previousEvent() {
+        --current_index;
+        event = store.getAt(current_index).data;
+        updateit();
+    }
     function nextEvent() {
-      var store = grid.getStore();
-      ++current_index;
-      event = store.getAt(current_index).data;
+        ++current_index;
+        event = store.getAt(current_index).data;
+        updateit();
+    }
+    function checkButtonAvailability(toolBar){
+        // If we're at the end of the store then disable the next
+        // or previous button.  (getTotalCount is one-based).
+        if (current_index == store.getTotalCount() - 1)
+          toolBar.getComponent(nextButtonId).disable();
+        if (current_index == 0)
+          toolBar.getComponent(previousButtonId).disable();
+    }
+
+    function updateit() {
       var title = getDialogTitle(event);
       var content = getDialogContent(event);
       var buttons = getDialogButtons(event);
@@ -399,10 +425,7 @@ tvheadend.epgDetails = function(grid, index) {
       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();
+      checkButtonAvailability(tbar);
       // Finally, relayout.
       win.doLayout();
     }