Add code for updating webui when title / descriptors are changed in tvh
This commit is contained in:
parent
12a963e839
commit
9b5d47e21a
5 changed files with 66 additions and 10 deletions
51
src/idnode.c
51
src/idnode.c
|
@ -5,6 +5,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "idnode.h"
|
||||
#include "notify.h"
|
||||
|
||||
static int randfd = 0;
|
||||
|
||||
|
@ -187,6 +188,21 @@ add_descriptors(struct idnode *self, const idclass_t *ic, htsmsg_t *p)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static const char *
|
||||
idnode_get_title(idnode_t *in)
|
||||
{
|
||||
if(in->in_class->ic_get_title != NULL) {
|
||||
return in->in_class->ic_get_title(in);
|
||||
} else {
|
||||
return idnode_uuid_as_str(in);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -199,12 +215,7 @@ idnode_serialize(struct idnode *self)
|
|||
m = c->ic_serialize(self);
|
||||
} else {
|
||||
m = htsmsg_create_map();
|
||||
|
||||
if(c->ic_get_title != NULL) {
|
||||
htsmsg_add_str(m, "text", c->ic_get_title(self));
|
||||
} else {
|
||||
htsmsg_add_str(m, "text", idnode_uuid_as_str(self));
|
||||
}
|
||||
htsmsg_add_str(m, "text", idnode_get_title(self));
|
||||
|
||||
htsmsg_t *p = htsmsg_create_list();
|
||||
add_descriptors(self, c, p);
|
||||
|
@ -223,12 +234,24 @@ static void
|
|||
idnode_save(idnode_t *in)
|
||||
{
|
||||
const idclass_t *ic = in->in_class;
|
||||
|
||||
for(; ic != NULL; ic = ic->ic_super) {
|
||||
if(ic->ic_save != NULL) {
|
||||
ic->ic_save(in);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Tell about updated descriptors
|
||||
|
||||
htsmsg_t *m = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "id", idnode_uuid_as_str(in));
|
||||
|
||||
htsmsg_t *p = htsmsg_create_list();
|
||||
add_descriptors(in, in->in_class, p);
|
||||
htsmsg_add_msg(m, "descriptors", p);
|
||||
|
||||
notify_by_msg("idnodeDescriptorsChanged", m);
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,3 +290,17 @@ idnode_update_all_props(idnode_t *in,
|
|||
if(do_save)
|
||||
idnode_save(in);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void
|
||||
idnode_notify_title_changed(void *obj)
|
||||
{
|
||||
idnode_t *in = obj;
|
||||
htsmsg_t *m = htsmsg_create_map();
|
||||
htsmsg_add_str(m, "id", idnode_uuid_as_str(in));
|
||||
htsmsg_add_str(m, "text", idnode_get_title(in));
|
||||
notify_by_msg("idnodeNameChanged", m);
|
||||
}
|
||||
|
|
|
@ -42,3 +42,6 @@ void idnode_update_all_props(idnode_t *in,
|
|||
const char *(*getvalue)(void *opaque,
|
||||
const char *key),
|
||||
void *opaque);
|
||||
|
||||
void idnode_notify_title_changed(void *obj);
|
||||
|
||||
|
|
|
@ -190,9 +190,9 @@ prop_seti(void *obj, const property_t *p, const char *value)
|
|||
mystrset(val, value);
|
||||
break;
|
||||
}
|
||||
|
||||
if(p->notify)
|
||||
p->notify(obj);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ typedef struct property {
|
|||
const char *(*str_get)(void *ptr);
|
||||
void (*str_set)(void *ptr, const char *str);
|
||||
|
||||
void (*notify)(void *ptr);
|
||||
|
||||
} property_t;
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
tvheadend.item_editor = function(item) {
|
||||
|
||||
var fields = []
|
||||
console.log(fields);
|
||||
|
||||
for (var idx in item.descriptors) {
|
||||
var f = item.descriptors[idx];
|
||||
switch(f.type) {
|
||||
|
@ -98,6 +98,20 @@ tvheadend.dvb_networks = function() {
|
|||
}
|
||||
});
|
||||
|
||||
tvheadend.comet.on('idnodeNameChanged', function(o) {
|
||||
var n = tree.getNodeById(o.id);
|
||||
if(n) {
|
||||
n.setText(o.text);
|
||||
}
|
||||
});
|
||||
|
||||
tvheadend.comet.on('idnodeDescriptorsChanged', function(o) {
|
||||
var n = tree.getNodeById(o.id);
|
||||
if(n) {
|
||||
n.attributes.descriptors = o.descriptors;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var panel = new Ext.Panel({
|
||||
title: 'DVB Networks',
|
||||
|
|
Loading…
Add table
Reference in a new issue