]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
WEBUI: Add persistent view level settings (global + per ACL)
authorJaroslav Kysela <perex@perex.cz>
Wed, 2 Dec 2015 17:18:14 +0000 (18:18 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 2 Dec 2015 17:18:14 +0000 (18:18 +0100)
src/access.c
src/access.h
src/config.c
src/config.h
src/webui/comet.c
src/webui/static/app/acleditor.js
src/webui/static/app/idnode.js
src/webui/static/app/tvheadend.js

index f61ccb077435210b74209015d27c2309648971fe..061868f3ad35dfcb7baf2e8852944f9a1d20aaeb 100644 (file)
@@ -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;
 }
 
@@ -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;
 }
 
@@ -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) {
@@ -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;
 }
 
 /**
@@ -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 */
@@ -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"),
@@ -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",
index 67ed47130713cf7bfde81fc168f4579d52699dd5..bbc30088867e50e54d3bef10c11b49f91c24893e 100644 (file)
@@ -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;
@@ -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);
index fee0440331640250f85671d2501f5a75b1a4949c..824a736c3a7b7a05905db2243ac28389785ffb8b 100644 (file)
@@ -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",
index c4f4126e0db87f12c2feaea85e52ee579ffe9ab6..57798bfb6713f4d605bcab25dc7bca26d7b34d85 100644 (file)
@@ -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;
index 42ec2c2266f7d2c172f27857f751e65fb41f2d50..f2dfc5cc1081221850a457964aa489e93759d74b 100644 (file)
@@ -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)
index 6735667c1fe91cbec0b6081164fc2008a7255e79..0afc2c8c6cd5a8876c8c911f975c83a0febdeee2 100644 (file)
@@ -5,7 +5,7 @@
 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,' +
@@ -13,7 +13,7 @@ tvheadend.acleditor = function(panel, index)
               '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,' +
index 51a24a507744e0eb55a508ef6ecec9a07367a37d..84d1655bf40f90362842e2128376b2032d70f015 100644 (file)
@@ -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();
@@ -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++) {
@@ -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;
@@ -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);
index 47ea31fe4484e7654ce7c190f665a8e3858558c9..1b9d8551cf1c996219c3263bacea742192c52a80 100644 (file)
@@ -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({
@@ -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)