added webui for capmt
This commit is contained in:
parent
7be992c72e
commit
58868079ac
4 changed files with 97 additions and 13 deletions
29
src/capmt.c
29
src/capmt.c
|
@ -162,6 +162,7 @@ typedef struct capmt_transport {
|
|||
*/
|
||||
typedef struct capmt {
|
||||
int capmt_fd;
|
||||
int capmt_connected;
|
||||
|
||||
int capmt_sock_ca0;
|
||||
int capmt_sock;
|
||||
|
@ -204,6 +205,7 @@ typedef struct capmt {
|
|||
char *capmt_sockfile;
|
||||
char *capmt_hostname;
|
||||
int capmt_port;
|
||||
char *capmt_comment;
|
||||
char *capmt_id;
|
||||
|
||||
// const char *capmt_errtxt;
|
||||
|
@ -729,10 +731,12 @@ capmt_record_build(capmt_t *capmt)
|
|||
htsmsg_t *e = htsmsg_create_map();
|
||||
|
||||
htsmsg_add_str(e, "id", capmt->capmt_id);
|
||||
htsmsg_add_u32(e, "enabled", !!capmt->capmt_enabled);
|
||||
htsmsg_add_u32(e, "connected", !!capmt->capmt_connected);
|
||||
|
||||
htsmsg_add_str(e, "sockfile", capmt->capmt_sockfile ?: "");
|
||||
htsmsg_add_str(e, "hostname", capmt->capmt_hostname ?: "");
|
||||
htsmsg_add_str(e, "camdfilename", capmt->capmt_sockfile ?: "");
|
||||
htsmsg_add_u32(e, "port", capmt->capmt_port);
|
||||
htsmsg_add_str(e, "comment", capmt->capmt_comment ?: "");
|
||||
|
||||
return e;
|
||||
}
|
||||
|
@ -753,18 +757,22 @@ capmt_entry_update(void *opaque, const char *id, htsmsg_t *values, int maycreate
|
|||
|
||||
lock_assert(&global_lock);
|
||||
|
||||
if((s = htsmsg_get_str(values, "sockfile")) != NULL) {
|
||||
if((s = htsmsg_get_str(values, "camdfilename")) != NULL) {
|
||||
free(capmt->capmt_sockfile);
|
||||
capmt->capmt_sockfile = strdup(s);
|
||||
printf("capmt sockfile %s\n", s);
|
||||
}
|
||||
|
||||
if((s = htsmsg_get_str(values, "hostname")) != NULL) {
|
||||
free(capmt->capmt_hostname);
|
||||
capmt->capmt_hostname = strdup(s);
|
||||
}
|
||||
|
||||
if(!htsmsg_get_u32(values, "port", &u32))
|
||||
if(!htsmsg_get_u32(values, "port", &u32)) {
|
||||
capmt->capmt_port = u32;
|
||||
printf("capmt listen port %d\n", u32);
|
||||
}
|
||||
|
||||
if((s = htsmsg_get_str(values, "comment")) != NULL) {
|
||||
free(capmt->capmt_comment);
|
||||
capmt->capmt_comment = strdup(s);
|
||||
}
|
||||
|
||||
/*
|
||||
capmt->capmt_reconfigure = 1;
|
||||
|
||||
|
@ -863,8 +871,5 @@ capmt_init(void)
|
|||
|
||||
dt = dtable_create(&capmt_dtc, "capmt", NULL);
|
||||
dtable_load(dt);
|
||||
|
||||
/* create initial entry */
|
||||
capmt_entry_find(NULL, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@ extjs_root(http_connection_t *hc, const char *remain, void *opaque)
|
|||
extjs_load(hq, "static/app/cteditor.js");
|
||||
extjs_load(hq, "static/app/acleditor.js");
|
||||
extjs_load(hq, "static/app/cwceditor.js");
|
||||
extjs_load(hq, "static/app/capmteditor.js");
|
||||
extjs_load(hq, "static/app/tvadapters.js");
|
||||
extjs_load(hq, "static/app/dvb.js");
|
||||
extjs_load(hq, "static/app/iptv.js");
|
||||
|
|
77
src/webui/static/app/capmteditor.js
Normal file
77
src/webui/static/app/capmteditor.js
Normal file
|
@ -0,0 +1,77 @@
|
|||
|
||||
tvheadend.capmteditor = function() {
|
||||
var fm = Ext.form;
|
||||
|
||||
var enabledColumn = new Ext.grid.CheckColumn({
|
||||
header: "Enabled",
|
||||
dataIndex: 'enabled',
|
||||
width: 60
|
||||
});
|
||||
|
||||
function setMetaAttr(meta, record){
|
||||
var enabled = record.get('enabled');
|
||||
if(!enabled) return;
|
||||
|
||||
var connected = record.get('connected');
|
||||
if(connected == 1){
|
||||
meta.attr = 'style="color:green;"';
|
||||
} else {
|
||||
meta.attr = 'style="color:red;"';
|
||||
}
|
||||
}
|
||||
|
||||
var cm = new Ext.grid.ColumnModel([
|
||||
enabledColumn,
|
||||
{
|
||||
header: "Camd.socket Filename",
|
||||
dataIndex: 'camdfilename',
|
||||
width: 200,
|
||||
renderer: function(value, metadata, record, row, col, store) {
|
||||
setMetaAttr(metadata, record);
|
||||
return value;
|
||||
},
|
||||
editor: new fm.TextField({allowBlank: false})
|
||||
},{
|
||||
header: "Listenport",
|
||||
dataIndex: 'port',
|
||||
renderer: function(value, metadata, record, row, col, store) {
|
||||
setMetaAttr(metadata, record);
|
||||
return value;
|
||||
},
|
||||
editor: new fm.TextField({allowBlank: false})
|
||||
},{
|
||||
header: "Comment",
|
||||
dataIndex: 'comment',
|
||||
width: 400,
|
||||
renderer: function(value, metadata, record, row, col, store) {
|
||||
setMetaAttr(metadata, record);
|
||||
return value;
|
||||
},
|
||||
editor: new fm.TextField()
|
||||
}
|
||||
]);
|
||||
|
||||
var rec = Ext.data.Record.create([
|
||||
'enabled','connected','camdfilename','port','comment'
|
||||
]);
|
||||
|
||||
store = new Ext.data.JsonStore({
|
||||
root: 'entries',
|
||||
fields: rec,
|
||||
url: "tablemgr",
|
||||
autoLoad: true,
|
||||
id: 'id',
|
||||
baseParams: {table: 'capmt', op: "get"}
|
||||
});
|
||||
|
||||
tvheadend.comet.on('capmtStatus', function(server) {
|
||||
var rec = store.getById(server.id);
|
||||
if(rec){
|
||||
rec.set('connected', server.connected);
|
||||
}
|
||||
});
|
||||
|
||||
return new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec,
|
||||
[enabledColumn], store,
|
||||
'config_capmt.html', 'key');
|
||||
}
|
|
@ -54,7 +54,8 @@ function accessUpdate(o) {
|
|||
new tvheadend.tvadapters,
|
||||
new tvheadend.iptv,
|
||||
new tvheadend.acleditor,
|
||||
new tvheadend.cwceditor]
|
||||
new tvheadend.cwceditor,
|
||||
new tvheadend.capmteditor]
|
||||
});
|
||||
tvheadend.rootTabPanel.add(tvheadend.confpanel);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue