Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WEBUI: Add persistent view level settings (global + per ACL)
  • Loading branch information
perexg committed Dec 2, 2015
1 parent feb752a commit fb734d8
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 7 deletions.
27 changes: 27 additions & 0 deletions src/access.c
Expand Up @@ -489,6 +489,7 @@ static access_t *access_alloc(void)
{
access_t *a = calloc(1, sizeof(access_t));
a->aa_uilevel = -1;
a->aa_uilevel_nochange = -1;
return a;
}

Expand All @@ -499,6 +500,7 @@ static access_t *access_full(access_t *a)
{
a->aa_rights = ACCESS_FULL;
a->aa_uilevel = UILEVEL_EXPERT;
a->aa_uilevel_nochange = config.uilevel_nochange;
return a;
}

Expand Down Expand Up @@ -529,6 +531,9 @@ access_update(access_t *a, access_entry_t *ae)
if(ae->ae_uilevel > a->aa_uilevel)
a->aa_uilevel = ae->ae_uilevel;

if(ae->ae_uilevel_nochange > a->aa_uilevel_nochange)
a->aa_uilevel_nochange = ae->ae_uilevel_nochange;

if(ae->ae_chmin || ae->ae_chmax) {
uint64_t *p = realloc(a->aa_chrange, (a->aa_chrange_count + 2) * sizeof(uint64_t));
if (p) {
Expand Down Expand Up @@ -610,6 +615,8 @@ access_set_lang_ui(access_t *a)
}
if (a->aa_uilevel < 0)
a->aa_uilevel = config.uilevel;
if (a->aa_uilevel_nochange < 0)
a->aa_uilevel_nochange = config.uilevel_nochange;
}

/**
Expand Down Expand Up @@ -1042,6 +1049,7 @@ access_entry_create(const char *uuid, htsmsg_t *conf)
TAILQ_INIT(&ae->ae_ipmasks);

ae->ae_uilevel = UILEVEL_DEFAULT;
ae->ae_uilevel_nochange = -1;

if (conf) {
/* defaults */
Expand Down Expand Up @@ -1372,6 +1380,17 @@ uilevel_get_list ( void *o, const char *lang )
return strtab2htsmsg(tab, 1, lang);
}

static htsmsg_t *
uilevel_nochange_get_list ( void *o, const char *lang )
{
static const struct strtab tab[] = {
{ N_("Default"), -1 },
{ N_("No"), 0 },
{ N_("Yes"), 1 },
};
return strtab2htsmsg(tab, 1, lang);
}

const idclass_t access_entry_class = {
.ic_class = "access",
.ic_caption = N_("Access"),
Expand Down Expand Up @@ -1418,6 +1437,14 @@ const idclass_t access_entry_class = {
.list = uilevel_get_list,
.opts = PO_EXPERT
},
{
.type = PT_INT,
.id = "uilevel_nochange",
.name = N_("Persistent user interface level"),
.off = offsetof(access_entry_t, ae_uilevel_nochange),
.list = uilevel_nochange_get_list,
.opts = PO_EXPERT
},
{
.type = PT_STR,
.id = "lang",
Expand Down
2 changes: 2 additions & 0 deletions src/access.h
Expand Up @@ -99,6 +99,7 @@ typedef struct access_entry {
int ae_index;
int ae_enabled;
int ae_uilevel;
int ae_uilevel_nochange;

int ae_streaming;
int ae_adv_streaming;
Expand Down Expand Up @@ -151,6 +152,7 @@ typedef struct access {
uint32_t aa_conn_streaming;
uint32_t aa_conn_dvr;
int aa_uilevel;
int aa_uilevel_nochange;
} access_t;

TAILQ_HEAD(access_ticket_queue, access_ticket);
Expand Down
8 changes: 8 additions & 0 deletions src/config.c
Expand Up @@ -1974,6 +1974,14 @@ const idclass_t config_class = {
.list = config_class_uilevel,
.group = 1
},
{
.type = PT_BOOL,
.id = "uilevel_nochange",
.name = N_("Persistent user interface level"),
.off = offsetof(config_t, uilevel_nochange),
.opts = PO_ADVANCED,
.group = 1
},
{
.type = PT_U32,
.id = "cookie_expires",
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Expand Up @@ -31,6 +31,7 @@ typedef struct config {
idnode_t idnode;
uint32_t version;
int uilevel;
int uilevel_nochange;
char *full_version;
char *server_name;
char *language;
Expand Down
5 changes: 4 additions & 1 deletion src/webui/comet.c
Expand Up @@ -160,8 +160,11 @@ comet_access_update(http_connection_t *hc, comet_mailbox_t *cmb)
case UILEVEL_EXPERT: s = "expert"; break;
default: s = NULL; break;
}
if (s)
if (s) {
htsmsg_add_str(m, "uilevel", s);
if (config.uilevel_nochange)
htsmsg_add_u32(m, "uilevel_nochange", config.uilevel_nochange);
}
if (!access_noacl)
htsmsg_add_str(m, "username", username);
if (hc->hc_peer_ipstr)
Expand Down
4 changes: 2 additions & 2 deletions src/webui/static/app/acleditor.js
Expand Up @@ -5,15 +5,15 @@
tvheadend.acleditor = function(panel, index)
{
var list = 'enabled,username,password,prefix,' +
'lang,webui,uilevel,admin,' +
'lang,webui,uilevel,uilevel_nochange,admin,' +
'streaming,adv_streaming,htsp_streaming,' +
'profile,conn_limit_type,conn_limit,' +
'dvr,htsp_dvr,all_dvr,all_rw_dvr,' +
'dvr_config,channel_min,channel_max,' +
'channel_tag_exclude,channel_tag,comment';

var list2 = 'enabled,username,password,prefix,' +
'lang,webui,langui,uilevel,admin,' +
'lang,webui,langui,uilevel,uilevel_nochange,admin,' +
'streaming,adv_streaming,htsp_streaming,' +
'profile,conn_limit_type,conn_limit,' +
'dvr,htsp_dvr,all_dvr,all_rw_dvr,' +
Expand Down
8 changes: 4 additions & 4 deletions src/webui/static/app/idnode.js
Expand Up @@ -1079,7 +1079,7 @@ tvheadend.idnode_editor = function(_uilevel, item, conf)
}

var uilevelBtn = null;
if (!conf.uilevel || conf.uilevel !== 'expert') {
if (!tvheadend.uilevel_nochange && (!conf.uilevel || conf.uilevel !== 'expert')) {
uilevelBtn = tvheadend.idnode_uilevel_menu(uilevel, function(l) {
uilevel = l;
var values = panel.getForm().getFieldValues();
Expand Down Expand Up @@ -1817,7 +1817,7 @@ tvheadend.idnode_grid = function(panel, conf)
}
}

if (!conf.uilevel || conf.uilevel !== 'expert') {
if (!tvheadend.uilevel_nochange && (!conf.uilevel || conf.uilevel !== 'expert')) {
abuttons.uilevel = tvheadend.idnode_uilevel_menu(uilevel, function (l) {
uilevel = l;
for (var i = 0; i < ifields.length; i++) {
Expand Down Expand Up @@ -2185,7 +2185,7 @@ tvheadend.idnode_form_grid = function(panel, conf)
}
}

if (!conf.uilevel || conf.uilevel !== 'expert') {
if (!tvheadend.uilevel_nochange && (!conf.uilevel || conf.uilevel !== 'expert')) {
abuttons.uilevel = tvheadend.idnode_uilevel_menu(uilevel, function (l) {
uilevel = l;
var values = null;
Expand Down Expand Up @@ -2626,7 +2626,7 @@ tvheadend.idnode_simple = function(panel, conf)
}
}

if (!conf.uilevel || conf.uilevel !== 'expert') {
if (!tvheadend.uilevel_nochange && (!conf.uilevel || conf.uilevel !== 'expert')) {
abuttons.uilevel = tvheadend.idnode_uilevel_menu(uilevel, uilevel_change);
buttons.push('->');
buttons.push(abuttons.uilevel);
Expand Down
4 changes: 4 additions & 0 deletions src/webui/static/app/tvheadend.js
Expand Up @@ -4,6 +4,7 @@ tvheadend.capabilities = null;
tvheadend.admin = false;
tvheadend.dialog = null;
tvheadend.uilevel = 'expert';
tvheadend.uilevel_nochange = false;
tvheadend.uilevel_cb = [];

tvheadend.cookieProvider = new Ext.state.CookieProvider({
Expand Down Expand Up @@ -429,6 +430,9 @@ function accessUpdate(o) {

tvheadend.admin = o.admin == true;

if (o.uilevel_nochange)
tvheadend.uilevel_nochange = true;

if ('info_area' in o)
tvheadend.rootTabPanel.setInfoArea(o.info_area);
if ('username' in o)
Expand Down

0 comments on commit fb734d8

Please sign in to comment.