Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: use combobox for owner field, allow edit owner/comment fields fo…
…r finished/failed recordings, fixes #3100
  • Loading branch information
perexg committed Oct 2, 2015
1 parent 32e14d1 commit 2412697
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 5 deletions.
25 changes: 22 additions & 3 deletions src/access.c
Expand Up @@ -1202,10 +1202,19 @@ static const char *
access_entry_class_get_title (idnode_t *self, const char *lang)
{
access_entry_t *ae = (access_entry_t *)self;
const char *s = ae->ae_username;

if (ae->ae_comment && ae->ae_comment[0] != '\0')
return ae->ae_comment;
return ae->ae_username ?: "";
if (ae->ae_comment && ae->ae_comment[0] != '\0') {
if (ae->ae_username && ae->ae_username[0]) {
snprintf(prop_sbuf, PROP_SBUF_LEN, "%s (%s)", ae->ae_username, ae->ae_comment);
s = prop_sbuf;
} else {
s = ae->ae_comment;
}
}
if (s == NULL || *s == '\0')
s = "";
return s;
}

static int
Expand Down Expand Up @@ -1349,6 +1358,16 @@ language_get_list ( void *obj, const char *lang )
return m;
}

htsmsg_t *
user_get_userlist ( void *obj, const char *lang )
{
htsmsg_t *m = htsmsg_create_map();
htsmsg_add_str(m, "type", "api");
htsmsg_add_str(m, "uri", "access/entry/userlist");
htsmsg_add_str(m, "event", "access");
return m;
}

const idclass_t access_entry_class = {
.ic_class = "access",
.ic_caption = N_("Access"),
Expand Down
1 change: 1 addition & 0 deletions src/access.h
Expand Up @@ -302,5 +302,6 @@ void access_done(void);
*
*/
htsmsg_t *language_get_list ( void *obj, const char *lang );
htsmsg_t *user_get_userlist ( void *obj, const char *lang );

#endif /* ACCESS_H_ */
3 changes: 3 additions & 0 deletions src/api.h
Expand Up @@ -97,6 +97,9 @@ typedef void (*api_idnode_grid_callback_t)
typedef idnode_set_t *(*api_idnode_tree_callback_t)
(access_t *perm);

htsmsg_t *api_idnode_flist_conf
( htsmsg_t *args, const char *name );

int api_idnode_grid
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp );

Expand Down
40 changes: 40 additions & 0 deletions src/api/api_access.c
Expand Up @@ -89,6 +89,45 @@ api_ipblock_entry_create
*
*/

static int
api_access_entry_userlist
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
int i;
idnode_set_t *is;
idnode_t *in;
access_entry_t *ae;
htsmsg_t *l, *e;

l = htsmsg_create_list();
if ((is = idnode_find_all(&access_entry_class, NULL))) {
for (i = 0; i < is->is_count; i++) {
in = is->is_array[i];

if (idnode_perm(in, perm, NULL))
continue;

ae = (access_entry_t *)in;
if (ae->ae_username != NULL && ae->ae_username[0] != '\0' &&
ae->ae_username[0] != '*') {
e = htsmsg_create_map();
htsmsg_add_str(e, "key", ae->ae_username);
htsmsg_add_str(e, "val", ae->ae_username);
htsmsg_add_msg(l, NULL, e);
}

idnode_perm_unset(in);
}
free(is->is_array);
free(is);
}

*resp = htsmsg_create_map();
htsmsg_add_msg(*resp, "entries", l);

return 0;
}

static void
api_access_entry_grid
( access_t *perm, idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args )
Expand Down Expand Up @@ -129,6 +168,7 @@ void api_access_init ( void )
{ "ipblock/entry/create", ACCESS_ADMIN, api_ipblock_entry_create, NULL },

{ "access/entry/class", ACCESS_ADMIN, api_idnode_class, (void*)&access_entry_class },
{ "access/entry/userlist", ACCESS_ADMIN, api_access_entry_userlist, NULL },
{ "access/entry/grid", ACCESS_ADMIN, api_idnode_grid, api_access_entry_grid },
{ "access/entry/create", ACCESS_ADMIN, api_access_entry_create, NULL },

Expand Down
2 changes: 1 addition & 1 deletion src/api/api_idnode.c
Expand Up @@ -23,7 +23,7 @@
#include "htsmsg.h"
#include "api.h"

static htsmsg_t *
htsmsg_t *
api_idnode_flist_conf( htsmsg_t *args, const char *name )
{
htsmsg_t *m = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/dvr/dvr_db.c
Expand Up @@ -2226,6 +2226,7 @@ const idclass_t dvr_entry_class = {
.id = "owner",
.name = N_("Owner"),
.off = offsetof(dvr_entry_t, de_owner),
.list = user_get_userlist,
.get_opts = dvr_entry_class_owner_opts,
},
{
Expand Down
3 changes: 2 additions & 1 deletion src/webui/static/app/dvr.js
Expand Up @@ -320,6 +320,7 @@ tvheadend.dvr_finished = function(panel, index) {
titleP: _('Finished Recordings'),
iconCls: 'finishedRec',
tabIndex: index,
edit: { params: { list: tvheadend.admin ? "owner,comment" : "comment" } },
del: true,
delquestion: _('Do you really want to delete the selected recordings?') + '<br/><br/>' +
_('The associated file will be removed from storage.'),
Expand Down Expand Up @@ -395,12 +396,12 @@ tvheadend.dvr_failed = function(panel, index) {
tvheadend.idnode_grid(panel, {
url: 'api/dvr/entry',
gridURL: 'api/dvr/entry/grid_failed',
comet: 'dvrentry',
readonly: true,
titleS: _('Failed Recording'),
titleP: _('Failed Recordings'),
iconCls: 'exclamation',
tabIndex: index,
edit: { params: { list: tvheadend.admin ? "owner,comment" : "comment" } },
del: true,
delquestion: _('Do you really want to delete the selected recordings?') + '<br/><br/>' +
_('The associated file will be removed from storage.'),
Expand Down
2 changes: 2 additions & 0 deletions src/webui/static/app/idnode.js
Expand Up @@ -1339,6 +1339,8 @@ tvheadend.idnode_grid = function(panel, conf)
if (!conf.readonly) {
if (buttons.length > 0)
buttons.push('-');
}
if (!conf.readonly || conf.edit) {
abuttons.edit = new Ext.Toolbar.Button({
tooltip: _('Edit selected entry'),
iconCls: 'edit',
Expand Down
3 changes: 3 additions & 0 deletions src/webui/static/app/tvheadend.js
@@ -1,6 +1,7 @@
tvheadend.dynamic = true;
tvheadend.accessupdate = null;
tvheadend.capabilities = null;
tvheadend.admin = false;

tvheadend.cookieProvider = new Ext.state.CookieProvider({
// 7 days from now
Expand Down Expand Up @@ -360,6 +361,8 @@ function accessUpdate(o) {
if (!tvheadend.capabilities)
return;

tvheadend.admin = o.admin == true;

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

0 comments on commit 2412697

Please sign in to comment.