From 43d50f2d9bb77428664b2982b6d612fe1771815b Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Thu, 15 Aug 2013 12:06:00 +0100 Subject: [PATCH] webui: updated UI to new API calls. Still crap, but hey ho! --- src/webui/static/app/idnode.js | 58 +++++++++------------- src/webui/static/app/mpegts.js | 80 +++++++++++++++--------------- src/webui/static/app/tvadapters.js | 2 +- src/webui/static/app/tvheadend.js | 2 + 4 files changed, 66 insertions(+), 76 deletions(-) diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index 93f224c6..a230ac5a 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -7,10 +7,10 @@ tvheadend.idnode_get_enum = function ( conf ) { /* Build key */ var key = conf.url; - if (conf.event) - key += conf.event; if (conf.params) key += '?' + Ext.util.JSON.encode(conf.params); + if (conf.event) + key += '+' + conf.event; /* Use cached */ if (key in tvheadend.idnode_enum_stores) @@ -22,6 +22,7 @@ tvheadend.idnode_get_enum = function ( conf ) url : conf.url, baseParams : conf.params || {}, fields : conf.fields || [ 'key', 'val' ], + id : conf.id || 'key', autoLoad : true, }); tvheadend.idnode_enum_stores[key] = st; @@ -206,13 +207,11 @@ tvheadend.idnode_editor = function(item, conf) handler : function() { var node = panel.getForm().getFieldValues(); node.uuid = item.uuid; - var params = { - op : 'save', - nodes : Ext.util.JSON.encode([node]) - }; Ext.Ajax.request({ - url : 'api/idnode', - params : params, + url : 'api/idnode/save', + params : { + args : Ext.encode({node: node}) + }, success : function(d) { } }); @@ -259,10 +258,12 @@ tvheadend.idnode_create = function(conf) params['uuid'] = puuid; if (pclass) params['class'] = pclass - params['conf'] = Ext.util.JSON.encode(panel.getForm().getFieldValues()); + params['conf'] = panel.getForm().getFieldValues(); Ext.Ajax.request({ - url : conf.create.url || conf.url, - params : params, + url : conf.create.url || conf.url + '/create', + params : { + args : Ext.util.JSON.encode(params) + }, success : function(d) { win.close(); } @@ -294,7 +295,7 @@ tvheadend.idnode_create = function(conf) /* Create window */ win = new Ext.Window({ - title : 'Add ' + conf.title, + title : 'Add ' + conf.titleS, layout : 'fit', autoWidth : true, autoHeight : true, @@ -379,7 +380,7 @@ tvheadend.idnode_create = function(conf) win.show(); } else { Ext.Ajax.request({ - url : conf.url, + url : conf.url + '/class', params : conf.params, success : function(d) { d = json_decode(d); @@ -458,15 +459,12 @@ tvheadend.idnode_grid = function(panel, conf) /* Store */ var store = new Ext.data.JsonStore({ root : 'entries', - url : conf.url, + url : conf.url + '/grid', autoLoad : true, id : 'uuid', totalProperty : 'total', fields : fields, - remoteSort : true, - baseParams : { - op : 'list', - } + remoteSort : true }); /* Model */ @@ -507,10 +505,9 @@ tvheadend.idnode_grid = function(panel, conf) out[x].uuid = mr[x].id; } Ext.Ajax.request({ - url : 'api/idnode', + url : 'api/idnode/save', params : { - op : 'save', - nodes : Ext.encode(out) + args : Ext.encode({node : out}) }, success : function(d) { @@ -555,10 +552,9 @@ tvheadend.idnode_grid = function(panel, conf) for ( var i = 0; i < r.length; i++ ) uuids.push(r[i].id) Ext.Ajax.request({ - url : conf.url, + url : 'api/idnode/delete', params : { - op: 'delete', - args : Ext.util.JSON.encode({ uuids: uuids}) + args : Ext.util.JSON.encode({ uuid: uuids}) }, success : function(d) { @@ -580,9 +576,8 @@ tvheadend.idnode_grid = function(panel, conf) if (r) { if (conf.edittree) { var p = tvheadend.idnode_tree({ - url : 'api/idnode', + url : 'api/idnode/tree', params : { - op : 'childs', root : r.id } }); @@ -598,15 +593,14 @@ tvheadend.idnode_grid = function(panel, conf) w.show(); } else { Ext.Ajax.request({ - url : 'api/idnode', + url : 'api/idnode/load', params : { - op: 'get', uuid: r.id }, success : function(d) { d = json_decode(d); - var p = tvheadend.idnode_editor(d, {}); + var p = tvheadend.idnode_editor(d[0], {}); var w = new Ext.Window({ title : 'Edit ' + conf.titleS, layout : 'fit', @@ -678,10 +672,7 @@ tvheadend.idnode_grid = function(panel, conf) /* Request data */ if (!conf.fields) { Ext.Ajax.request({ - url : conf.url, - params : { - op: 'class' - }, + url : conf.url + '/class', success : function(d) { build(json_decode(d).props); @@ -696,7 +687,6 @@ tvheadend.idnode_tree = function (conf) { var current = null; var params = conf.params || {}; - params.op = 'childs'; var loader = new Ext.tree.TreeLoader({ dataUrl : conf.url, baseParams : params, diff --git a/src/webui/static/app/mpegts.js b/src/webui/static/app/mpegts.js index ce39561d..dca6600b 100644 --- a/src/webui/static/app/mpegts.js +++ b/src/webui/static/app/mpegts.js @@ -2,39 +2,47 @@ * DVB network */ -tvheadend.network_classes = new Ext.data.JsonStore({ - autoLoad : true, +tvheadend.network_builders = new Ext.data.JsonStore({ + url : 'api/mpegts/network/builders', root : 'entries', - fields : [ 'class', 'caption', 'props' ], - id : 'class', - url : 'api/mpegts/network', - baseParams : { - op: 'class_list' - } + fields : [ 'class', 'caption', 'props' ], + id : 'class', + autoLoad : true, }); + +tvheadend.network_list = new Ext.data.JsonStore({ + url : 'api/idnode/load', + baseParams : { class : 'mpegts_network', enum: 1 }, + root : 'entries', + fields : [ 'uuid', 'title' ], + id : 'uuid', + autoLoad : true, +}); + tvheadend.comet.on('mpegts_network', function() { - tvheadend.network_classes.reload(); + // TODO: Might be a bit excessive + tvheadend.network_builders.reload(); + tvheadend.network_list.reload(); }); tvheadend.networks = function(panel) { tvheadend.idnode_grid(panel, { - titleS : 'Network', - titleP : 'Networks', url : 'api/mpegts/network', comet : 'mpegts_network', + titleS : 'Network', + titleP : 'Networks', add : { - url : 'api/mpegts/network', - title : 'Network', + titleS : 'Network', select : { - caption : 'Type', - store : tvheadend.network_classes, + label : 'Type', + store : tvheadend.network_builders, displayField : 'caption', valueField : 'class', propField : 'props', }, create : { - params : { op: 'create' } + url : 'api/mpegts/network/create' } }, del : true @@ -44,24 +52,23 @@ tvheadend.networks = function(panel) tvheadend.muxes = function(panel) { tvheadend.idnode_grid(panel, { - titleS : 'Mux', - titleP : 'Muxes', url : 'api/mpegts/mux', comet : 'mpegts_mux', - add : { - title : 'Mux', - url : 'api/mpegts/network', - select : { - caption : 'Network', - params : { op: 'list', limit: -1 }, - displayField : 'networkname', + titleS : 'Mux', + titleP : 'Muxes', + add : { + titleS : 'Mux', + select : { + label : 'Network', + store : tvheadend.network_list, + displayField : 'title', valueField : 'uuid', clazz : { - params : { op: 'mux_class' } + url : 'api/mpegts/network/mux_class' } }, - create : { - params : { op: 'mux_create' } + create : { + url : 'api/mpegts/network/mux_create', } }, del : true @@ -72,9 +79,9 @@ tvheadend.services = function(panel) { tvheadend.idnode_grid(panel, { url : 'api/mpegts/service', + comet : 'service', titleS : 'Service', titleP : 'Services', - comet : 'service', add : false, del : false }); @@ -83,20 +90,11 @@ tvheadend.services = function(panel) tvheadend.satconfs = function(panel) { tvheadend.idnode_grid(panel, { - titleS : 'Satconf', - titleP : 'Satconfs', url : 'api/linuxdvb/satconf', comet : 'linuxdvb_satconf', - add : { - title : 'Satconf', - url : 'api/linuxdvb/satconf', - create : { - params : { op: 'create' } - }, - params : { - op: 'class' - } - }, + titleS : 'Satconf', + titleP : 'Satconfs', + add : {}, del : true, edittree : true, }); diff --git a/src/webui/static/app/tvadapters.js b/src/webui/static/app/tvadapters.js index 010d2e40..c5b4a43d 100644 --- a/src/webui/static/app/tvadapters.js +++ b/src/webui/static/app/tvadapters.js @@ -1,4 +1,4 @@ tvheadend.tvadapters = function() { // return tvheadend.item_browser('tvadapters', 'TV Adapters'); - return tvheadend.idnode_tree({ url: 'tvadapters', title: 'TV adapters'}); + return tvheadend.idnode_tree({ url: 'api/tvadapter/tree', title: 'TV adapters'}); } diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index 55e36641..a3280f2a 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -267,7 +267,9 @@ function accessUpdate(o) { tvheadend.capabilities.indexOf('v4l') != -1) { tabs2.push(new tvheadend.tvadapters); } +/* tabs2.push(new tvheadend.iptv); +*/ tvheadend.conf_dvbin = new Ext.TabPanel({ activeTab: 0, autoScroll: true,