memset(&config, 0, sizeof(config));
config.idnode.in_class = &config_class;
+ config.info_area = strdup("login,storage,time");
/* Generate default */
if (!path) {
free(config.full_version);
free(config.server_name);
free(config.language);
+ free(config.info_area);
free(config.muxconf_path);
free(config.chicon_path);
free(config.picon_path);
return m;
}
+static const void *
+config_class_info_area_get ( void *o )
+{
+ return htsmsg_csv_2_list(config.info_area, ',');
+}
+
+static int
+config_class_info_area_set ( void *o, const void *v )
+{
+ char *s = htsmsg_list_2_csv((htsmsg_t *)v, ',', 0);
+ if (strcmp(s ?: "", config.info_area ?: "")) {
+ free(config.info_area);
+ config.info_area = s;
+ return 1;
+ }
+ if (s)
+ free(s);
+ return 0;
+}
+
+static void
+config_class_info_area_list1 ( htsmsg_t *m, const char *key, const char *val )
+{
+ htsmsg_t *e = htsmsg_create_map();
+ htsmsg_add_str(e, "key", key);
+ htsmsg_add_str(e, "val", val);
+ htsmsg_add_msg(m, NULL, e);
+}
+
+static htsmsg_t *
+config_class_info_area_list ( void *o, const char *lang )
+{
+ htsmsg_t *m = htsmsg_create_list();
+ config_class_info_area_list1(m, "login", N_("Login/Logout"));
+ config_class_info_area_list1(m, "storage", N_("Storage space"));
+ config_class_info_area_list1(m, "time", N_("Time"));
+ return m;
+}
+
const idclass_t config_class = {
.ic_snode = &config.idnode,
.ic_class = "config",
.number = 2,
},
{
- .name = N_("DVB Scan Files"),
+ .name = N_("Web User Interface"),
.number = 3,
},
{
- .name = N_("Time Update"),
+ .name = N_("DVB Scan Files"),
.number = 4,
},
{
- .name = N_("Picon"),
+ .name = N_("Time Update"),
.number = 5,
},
+ {
+ .name = N_("Picon"),
+ .number = 6,
+ },
{}
},
.ic_properties = (const property_t[]){
.opts = PO_LORDER,
.group = 2
},
+ {
+ .type = PT_STR,
+ .islist = 1,
+ .id = "info_area",
+ .name = N_("Information Area"),
+ .set = config_class_info_area_set,
+ .get = config_class_info_area_get,
+ .list = config_class_info_area_list,
+ .opts = PO_LORDER,
+ .group = 3
+ },
{
.type = PT_STR,
.id = "muxconfpath",
.name = N_("DVB scan files path"),
.off = offsetof(config_t, muxconf_path),
- .group = 3
+ .group = 4
},
{
.type = PT_BOOL,
.id = "tvhtime_update_enabled",
.name = N_("Update time"),
.off = offsetof(config_t, tvhtime_update_enabled),
- .group = 4,
+ .group = 5,
},
{
.type = PT_BOOL,
.id = "tvhtime_ntp_enabled",
.name = N_("Enable NTP driver"),
.off = offsetof(config_t, tvhtime_update_enabled),
- .group = 4,
+ .group = 5,
},
{
.type = PT_U32,
.id = "tvhtime_tolerance",
.name = N_("Update tolerance (ms)"),
.off = offsetof(config_t, tvhtime_tolerance),
- .group = 4,
+ .group = 5,
},
{
.type = PT_BOOL,
.id = "prefer_picon",
.name = N_("Prefer picons over channel name"),
.off = offsetof(config_t, prefer_picon),
- .group = 5,
+ .group = 6,
},
{
.type = PT_STR,
.id = "chiconpath",
.name = N_("Channel icon path (see Help)"),
.off = offsetof(config_t, chicon_path),
- .group = 5,
+ .group = 6,
},
{
.type = PT_STR,
.id = "piconpath",
.name = N_("Picon path (see Help)"),
.off = offsetof(config_t, picon_path),
- .group = 5,
+ .group = 6,
},
{}
}
char *full_version;
char *server_name;
char *language;
+ char *info_area;
char *muxconf_path;
int prefer_picon;
char *chicon_path;
#include "htsmsg_json.h"
#include "tvheadend.h"
+#include "config.h"
#include "http.h"
#include "dvr/dvr.h"
#include "webui/webui.h"
htsmsg_add_u32(m, "dvr", dvr);
htsmsg_add_u32(m, "admin", !http_access_verify(hc, ACCESS_ADMIN));
+ htsmsg_add_s64(m, "time", time(NULL));
+
+ if (config.info_area && config.info_area[0])
+ htsmsg_add_str(m, "info_area", config.info_area);
+
if (dvr && !dvr_get_disk_space(&bfree, &btotal)) {
htsmsg_add_s64(m, "freediskspace", bfree);
htsmsg_add_s64(m, "totaldiskspace", btotal);
-
tvheadend.dynamic = true;
tvheadend.accessupdate = null;
tvheadend.capabilities = null;
if (!tvheadend.capabilities)
return;
+ if ('info_area' in o)
+ tvheadend.rootTabPanel.setInfoArea(o.info_area);
if ('username' in o)
tvheadend.rootTabPanel.setLogin(o.username);
if ('address' in o)
tvheadend.RootTabPanel = Ext.extend(Ext.TabPanel, {
- extra: {},
-
- onRender: function(ct, position) {
- tvheadend.RootTabPanel.superclass.onRender.call(this, ct, position);
-
- var before = this.strip.dom.childNodes[this.strip.dom.childNodes.length-1];
+ extra: [],
+ info_area: [],
- /* Create login components */
- if (!this.extra.login) {
- this.extra.login = new tvheadend.RootTabExtraComponent();
- this.extra.login.onRender1(this, before);
- }
- if (!this.extra.loginCmd) {
- this.extra.loginCmd = new tvheadend.RootTabExtraClickComponent();
- this.extra.loginCmd.onRender1(this, before, this.onLoginCmdClicked);
- }
- if (!this.extra.storage) {
- this.extra.storage = new tvheadend.RootTabExtraComponent();
- this.extra.storage.onRender1(this, before);
+ getComponent: function(comp) {
+ for (var k in this.extra) {
+ var comp2 = this.extra[k];
+ if (comp === comp2.id || comp == comp2)
+ return comp2;
}
+ return tvheadend.RootTabPanel.superclass.getComponent.call(this, comp);
+ },
+ setInfoArea: function(info_area) {
+ this.info_area = info_area.split(',');
this.on('beforetabchange', function(tp, p) {
for (var k in this.extra)
if (p == this.extra[k])
return false;
});
- },
- getComponent: function(comp) {
- for (var k in this.extra) {
- var comp2 = this.extra[k];
- if (comp === comp2.id || comp == comp2)
- return comp2;
+ var before = this.strip.dom.childNodes[this.strip.dom.childNodes.length-1];
+
+ /* Create extra components */
+ for (var itm in this.info_area) {
+ var nm = this.info_area[itm];
+ if (!(nm in this.extra)) {
+ this.extra[nm] = new tvheadend.RootTabExtraComponent();
+ this.extra[nm].onRender1(this, before);
+ if (nm == 'login') {
+ this.extra.loginCmd = new tvheadend.RootTabExtraClickComponent();
+ this.extra.loginCmd.onRender1(this, before, this.onLoginCmdClicked);
+ }
+ }
}
- return tvheadend.RootTabPanel.superclass.getComponent.call(this, comp);
+
+ if (this.extra.time)
+ window.setInterval(this.setTime, 1000);
},
setLogin: function(login) {
- if (!'login' in this.extra)
- return;
+ if (!('login' in this.extra)) return;
this.login = login;
if (login) {
text = _('Logged in as') + ' <b>' + login + '</b>';
},
setDiskSpace: function(bfree, btotal) {
- if (!'storage' in this.extra) return;
+ if (!('storage' in this.extra)) return;
human = function(val) {
if (val > 1000000000)
val = parseInt(val / 1000000000) + _('GB');
el.qtip = _('Free') + ': ' + human(bfree) + ' ' + _('Total') + ': ' + human(btotal);
},
+ setTime: function(stime) {
+ var panel = tvheadend.rootTabPanel;
+ if (!('time' in panel.extra)) return;
+ var d = stime ? new Date(stime) : new Date();
+ var el = Ext.get(panel.extra.time.tabEl).child('span.x-tab-strip-extra-comp', true);
+ el.innerHTML = '<b>' + d.toLocaleTimeString() + '</b>';
+ el.qtip = d.toLocaleString();
+ },
+
onLoginCmdClicked: function(e) {
window.location.href = this.login ? 'logout' : 'login';
}