]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
webui: use new network event to update grid when new elements are added.
authorAdam Sutton <dev@adamsutton.me.uk>
Sat, 6 Jul 2013 14:11:37 +0000 (15:11 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Sat, 6 Jul 2013 14:11:37 +0000 (15:11 +0100)
This is just a first example, need to adopt this across the board.

src/webui/static/app/idnode.js
src/webui/static/app/mpegts.js

index de108c56654257d9d269098a7921b3da3ccefe5b..595e2956629d7d11f4a5171d839887eca978d70d 100644 (file)
@@ -139,7 +139,7 @@ tvheadend.idnode_editor_field = function(f, create)
 /*
  * ID node editor panel
  */
-tvheadend.idnode_editor = function(item, conf)
+tvheadend.idnode_editor = function(item, conf, win)
 {
   var panel  = null;
   var fields = []
@@ -163,7 +163,6 @@ tvheadend.idnode_editor = function(item, conf)
         url            : 'api/idnode',
         params         : params,
         success : function(d) {
-          // TODO
         }
       });
     }
@@ -494,7 +493,7 @@ tvheadend.idnode_grid = function(panel, conf)
               success : function(d)
               {
                 d = json_decode(d);
-                var p = tvheadend.idnode_editor(d[0], {});
+                var p = tvheadend.idnode_editor(d[0], {}, w);
                 var w = new Ext.Window({
                   title       : 'Edit ' + conf.titleS,
                   layout      : 'fit',
@@ -541,8 +540,30 @@ tvheadend.idnode_grid = function(panel, conf)
         emptyMsg    : 'No ' + conf.titleP.toLowerCase() + ' to display'
       })
     });
-
     panel.add(grid);
+
+    /* Add comet listeners */
+    tvheadend.comet.on(conf.comet, function(o) {
+      var fs  = [];
+      var d   = {};
+      for ( i = 0; i < o.params.length; i++)
+        if (o.params[i].id) {
+          fs.push(o.params[i].id);
+          d[o.params[i].id] = o.params[i].value;
+        }
+      var rec = Ext.data.Record.create(fs);
+      rec = new rec(d, o.id);
+      store.add(rec);
+    });
+    tvheadend.comet.on('idnodeParamsChanged', function(o) {
+      var r = store.getById(o.id);
+      if (r) {
+        for ( i = 0; i < o.params.length; i++)
+          if (o.params[i].id)
+            r.set(o.params[i].id, o.params[i].value);
+        r.commit();
+      }
+    });
   }
 
   /* Request data */
@@ -585,7 +606,10 @@ tvheadend.idnode_tree = function (conf)
         if(current)
           panel.remove(current);
         if(!n.isRoot)
-          current = panel.add(new tvheadend.idnode_editor(n.attributes, {title: 'Parameters', fixedHeight: true}));
+          current = panel.add(new tvheadend.idnode_editor(n.attributes, {
+            title       : 'Parameters',
+            fixedHeight : true
+          }), null);
         panel.doLayout();
       }
     }
index 48cfa884fb447b7c6b13ed6f16c9cacdbfccb6f4..282380f41df88737b16d61ed37e31e6181a08641 100644 (file)
@@ -12,13 +12,14 @@ tvheadend.networks = function(panel)
     titleS   :  'Network',
     titleP   :  'Networks',
     url      : 'api/mpegts/network',
-    add       : {
+    comet    : 'mpegts_network',
+    add      : {
       url    : 'api/mpegts/input',
       title  : 'Network',
       select : {
         caption      : 'Input',
         params       : { op: 'list', limit: -1 },
-        displayField : 'fe_path',//displayname',
+        displayField : 'displayname',
         valueField   : 'uuid',
         url          : 'api/mpegts/input',
         clazz        : {