Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WEBUI: Add support for partial updates also for idnode grids
- so the DVR grids are not 'refreshed' each second to lose the position
- TODO: 'create' event reloads the whole store like before
  • Loading branch information
perexg committed Oct 12, 2015
1 parent 6080ebd commit 5c8a775
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/webui/static/app/epg.js
Expand Up @@ -911,25 +911,24 @@ tvheadend.epg = function() {
tvheadend.comet.on('epg', function(m) {
if (!panel.isVisible())
return;
if ('delete' in m) {
for (var i = 0; i < m['delete'].length; i++) {
var r = epgStore.getById(m['delete'][i]);
if ('delete' in m)
Ext.each(m['delete'], function(d) {
var r = epgStore.getById(d);
if (r)
epgStore.remove(r);
}
}
});
if (m.update || m.dvr_update || m.dvr_delete) {
var a = m.update || m.dvr_update || m.dvr_delete;
if (m.update && m.dvr_update)
var a = m.update.concat(m.dvr_update);
if (m.update || m.dvr_update)
a = a.concat(m.dvr_delete);
var ids = [];
for (var i = 0; i < a.length; i++) {
var r = epgStore.getById(a[i]);
Ext.each(a, function (id) {
var r = epgStore.getById(id);
if (r)
ids.push(r.id);
}
});
if (ids) {
Ext.Ajax.request({
url: 'api/epg/events/load',
Expand Down
33 changes: 32 additions & 1 deletion src/webui/static/app/idnode.js
Expand Up @@ -1137,7 +1137,38 @@ tvheadend.idnode_grid = function(panel, conf)
var idnode = null;

var update = function(o) {
if (auto.getValue())
if ('delete' in o)
Ext.each(o['delete'], function (d) {
var r = store.getById(d);
if (r)
store.remove(r);
});
if (o.change) {
var ids = [];
Ext.each(o.change, function(id) {
var r = store.getById(id);
if (r)
ids.push(r.id);
});
if (ids) {
var p = { uuid: ids };
if (conf.list) p.list = conf.list;
Ext.Ajax.request({
url: 'api/idnode/load',
params: p,
success: function (d) {
d = json_decode(d);
Ext.each(d, function(jd) {
tvheadend.replace_entry(store.getById(jd.uuid), jd);
});
},
failure: function(response, options) {
Ext.MessageBox.alert(_('Grid Update'), response.statusText);
}
});
}
}
if (o.create && auto.getValue())
store.reload();
};

Expand Down
29 changes: 22 additions & 7 deletions src/webui/static/app/tvheadend.js
Expand Up @@ -169,13 +169,28 @@ tvheadend.doQueryAnyMatch = function(q, forceAll) {
*/

tvheadend.replace_entry = function(r, d) {
if (!r) return;
r.store.fields.each(function (n) {
var v = d[n.name];
r.data[n.name] = n.convert((v !== undefined) ? v : n.defaultValue, v);
});
r.json = d;
r.commit();
if (!r) return;
var dst = r.data;
var src = d.params instanceof Array ? d.params : d;
var lookup = src instanceof Array;
r.store.fields.each(function (n) {
if (lookup) {
for (var i = 0; i < src.length; i++) {
if (src[i].id == n.name) {
var v = src[i].value;
break;
}
}
} else {
var v = src[n.name];
}
var x = v;
if (typeof v === 'undefined')
x = typeof n.defaultValue === 'undefined' ? '' : n.defaultValue;
dst[n.name] = n.convert(x, v);
});
r.json = src;
r.commit();
}

/*
Expand Down

0 comments on commit 5c8a775

Please sign in to comment.