add support for queue options

This commit is contained in:
hummypkg 2017-01-09 19:24:23 +00:00
parent cf0916ace6
commit e5259b1350
5 changed files with 87 additions and 13 deletions

View File

@ -1,9 +1,9 @@
Package: sweeper Package: sweeper
Priority: optional Priority: optional
Section: misc Section: misc
Version: 2.1.5 Version: 2.1.5-1
Architecture: mipsel Architecture: mipsel
Maintainer: af123@hummypkg.org.uk Maintainer: af123@hummypkg.org.uk
Depends: webif(>=1.3.5) Depends: webif(>=1.3.5-2)
Description: Sweeper is a package for managing recordings in a variety of ways using custom rules [See forum for details] Description: Sweeper is a package for managing recordings in a variety of ways using custom rules [See forum for details]
Tags: http://hummy.tv/forum/threads/5138/ Tags: http://hummy.tv/forum/threads/5138/

View File

@ -900,8 +900,13 @@ proc ::sweeper::action_unflag {ts cmd arg folder} {
proc ::sweeper::action_queue {ts cmd arg folder} { proc ::sweeper::action_queue {ts cmd arg folder} {
log "Queued [$ts get file] for $arg" 0 log "Queued [$ts get file] for $arg" 0
set opt [lassign $arg arg]
log "ARG: ($arg) OPT: ($opt)" 2
if {!$::sweeper::dryrun} { if {!$::sweeper::dryrun} {
{queue insert} $ts $arg set q [{queue insert} $ts $arg]
if {[string trim $opt] ne ""} {
$q set args $opt
}
} }
return 0 return 0
} }

View File

@ -234,9 +234,13 @@ For pattern matching, the following special sequences may appear in the pattern:
<div class=hidden id=edit_action title="Rule Action"> <div class=hidden id=edit_action title="Rule Action">
<select name=edit_action_act id=edit_action_act></select> <select name=edit_action_act id=edit_action_act></select>
<input name=edit_action_arg id=edit_action_arg size=60 maxlength=255 /> <input name=edit_action_arg id=edit_action_arg size=55 maxlength=255
placeholder="Argument..." />
<select class=hidden name=edit_action_select_field <select class=hidden name=edit_action_select_field
id=edit_action_select_field></select> id=edit_action_select_field></select>
<input class=hidden name=edit_action_select_arg
id=edit_action_select_arg
size=20 maxlength=255 placeholder="Options..." />
<div class="hidden edit_action_help blood" id=edit_action_help_folder> <div class="hidden edit_action_help blood" id=edit_action_help_folder>
Enter one of: Enter one of:
<ul> <ul>

View File

@ -373,7 +373,7 @@ var schema = {
}, },
queue: { queue: {
'class': 'all', 'class': 'all',
argtype: 'select', argtype: 'selectx',
desc: 'Queue recording for', desc: 'Queue recording for',
select: queueselect, select: queueselect,
continues: true continues: true

View File

@ -13,6 +13,21 @@ function quot(str)
return '{' + str + '}'; return '{' + str + '}';
} }
function splitarg(arg)
{
o = {
'arg': arg,
'opt': ''
};
i = arg.indexOf(' ');
if (i > -1)
{
o.arg = arg.substring(0, i);
o.opt = arg.substring(i + 1);
}
return o;
}
function fixupdown() function fixupdown()
{ {
$('#ruleset a.uprule').enable().filter(':first').disable(); $('#ruleset a.uprule').enable().filter(':first').disable();
@ -170,6 +185,15 @@ function ruleconf(rule)
rule.find('tr.action td.val').attr('val')); rule.find('tr.action td.val').attr('val'));
s += 'action {' + act + ' ' + quot(arg) + '}'; s += 'action {' + act + ' ' + quot(arg) + '}';
break; break;
case 'selectx':
arg = $.trim(
rule.find('tr.action td.val').attr('val'));
opt = $.trim(
rule.find('tr.action td.val').attr('opt'));
if (opt)
arg += ' ' + opt;
s += 'action {' + act + ' ' + quot(arg) + '}';
break;
default: default:
s += 'action {' + act + ' ' + quot(arg) + '}'; s += 'action {' + act + ' ' + quot(arg) + '}';
break; break;
@ -315,11 +339,26 @@ function action(data)
s = '<tr class=action>' + s = '<tr class=action>' +
'<th class=title>Then:</th>' + '<th class=title>Then:</th>' +
'<th class=cmd cmd=' + data.cmd + '>' + c.desc + '</th>'; '<th class=cmd cmd=' + data.cmd + '>' + c.desc + '</th>';
if (c.argtype == 'select')
switch (c.argtype)
{
case 'select':
s += '<td class=val val=\"' + data.arg + '\">' + s += '<td class=val val=\"' + data.arg + '\">' +
c.select[data.arg]; c.select[data.arg];
else break;
case 'selectx':
a = splitarg(data.arg);
s += '<td class=val opt=\"' + a.opt + '\" ' +
'val=\"' + a.arg + '\">' +
c.select[a.arg];
if (a.opt)
s += ' (' + a.opt + ')';
break;
default:
s += '<td class=val>' + data.arg; s += '<td class=val>' + data.arg;
break;
}
s += '</td>' + s += '</td>' +
'<td><a class=editaction href=#>' + '<td><a class=editaction href=#>' +
'<img src=img/edit.png></a></td>' + '<img src=img/edit.png></a></td>' +
@ -1148,16 +1187,24 @@ $('#ruleset')
arg = ''; arg = '';
$('#edit_action_act').val(cmd).trigger('change'); $('#edit_action_act').val(cmd).trigger('change');
if (schema.action[cmd].argtype == 'select') switch (schema.action[cmd].argtype)
{ {
case 'selectx':
opt = rule.find('tr.action td.val').attr('opt');
$('#edit_action_select_arg').val(opt);
// Pass-through...
case 'select':
arg = rule.find('tr.action td.val').attr('val');
$('#edit_action_select_field').val(arg); $('#edit_action_select_field').val(arg);
$.each(schema.action[cmd].select, function(k, v) { $.each(schema.action[cmd].select, function(k, v) {
if (arg == v) if (arg == v)
$('#edit_action_select_field').val(k); $('#edit_action_select_field').val(k);
}); });
} break;
else default:
$('#edit_action_arg').val(arg); $('#edit_action_arg').val(arg);
break;
}
$('#edit_action').dialog({ $('#edit_action').dialog({
height: 'auto', width: 'auto', height: 'auto', width: 'auto',
@ -1172,11 +1219,25 @@ $('#ruleset')
buttons: { buttons: {
"Save": function() { "Save": function() {
cmd = $('#edit_action_act').val(); cmd = $('#edit_action_act').val();
if (schema.action[cmd].argtype == 'select') switch (schema.action[cmd].argtype)
{
case 'select':
arg = $('#edit_action_select_field') arg = $('#edit_action_select_field')
.val(); .val();
else break;
case 'selectx':
arg = $('#edit_action_select_field')
.val();
opt = $.trim(
$('#edit_action_select_arg').val()
);
if (opt)
arg += ' ' + opt;
break;
default:
arg = $('#edit_action_arg').val(); arg = $('#edit_action_arg').val();
break;
}
rule.find('table.action tbody').empty() rule.find('table.action tbody').empty()
.append(action({cmd: cmd, arg: arg})); .append(action({cmd: cmd, arg: arg}));
@ -1256,11 +1317,15 @@ $('#ruleset')
$('#edit_action_arg').show(); $('#edit_action_arg').show();
$('#edit_action_select_field').hide(); $('#edit_action_select_field').hide();
$('#edit_action_select_arg').hide();
switch (schema.action[cmd].argtype) switch (schema.action[cmd].argtype)
{ {
case 'none': case 'none':
$('#edit_action_arg').disable(); $('#edit_action_arg').hide().disable();
break; break;
case 'selectx':
$('#edit_action_select_arg').empty().show();
// Fall-through...
case 'select': case 'select':
$('#edit_action_arg').hide(); $('#edit_action_arg').hide();
$('#edit_action_select_field').empty().show(); $('#edit_action_select_field').empty().show();