forked from hummypkg/webif
fixes/improvements
git-svn-id: file:///root/webif/svn/pkg/webif/trunk@3434 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
759b96e764
commit
1fc426cb1a
@ -1,7 +1,7 @@
|
||||
Package: webif
|
||||
Priority: optional
|
||||
Section: web
|
||||
Version: 1.3.4
|
||||
Version: 1.3.4-1
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hpkg.tv
|
||||
Depends: tcpfix,webif-channelicons(>=1.1.24),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.3),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.9),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1)
|
||||
|
@ -6,7 +6,6 @@ export TZ=GMT+0BST,M3.5.0/1,M10.5.0/2
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
/mod/webif/lib/bin/update_queue
|
||||
/mod/webif/lib/bin/manage_logs
|
||||
plog activity "System booted (`lbr_descr`)."
|
||||
;;
|
||||
|
@ -883,7 +883,7 @@ $('#bmpdialogue').dialog({
|
||||
// Selection overlay
|
||||
$seloverlay = $('#selectoverlay').dialog({
|
||||
modal: false, autoOpen: false,
|
||||
height: 85, width: 460,
|
||||
height: 85, width: 485,
|
||||
show: 'fade', hide: 'fade',
|
||||
draggable: true, resizable: false
|
||||
});
|
||||
|
37
webif/html/diag/queue/fetch.jim
Executable file
37
webif/html/diag/queue/fetch.jim
Executable file
@ -0,0 +1,37 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
source /mod/webif/lib/setup
|
||||
require queue.class
|
||||
|
||||
httpheader "application/json"
|
||||
|
||||
puts "\["
|
||||
set flag 0
|
||||
foreach q [queue all] {
|
||||
set name [string map {
|
||||
"/mnt/hd2/My Video/" ""
|
||||
"/media/drive1/Video/" ""
|
||||
"/media/" ""
|
||||
".ts" ""
|
||||
} [$q get file]]
|
||||
set dat [clock format [$q get dat] -format {%c}]
|
||||
|
||||
if {$flag} { puts "," } else { incr flag }
|
||||
puts "{"
|
||||
puts " \"qid\": [$q get id],"
|
||||
puts " \"dat\": \"$dat\","
|
||||
puts " \"file\": \"$name\","
|
||||
puts " \"action\": \"[$q get action]\","
|
||||
puts " \"status\": \"[$q get status]\","
|
||||
puts " \"log\": \"[$q get log]\","
|
||||
if {[$q get elapsed] > 0} {
|
||||
set time [clock format [$q get elapsed] -format "%T"]
|
||||
puts " \"elapsed\": \"$time\","
|
||||
} else {
|
||||
puts " \"elapsed\": \"0\","
|
||||
}
|
||||
puts " \"retry\": \"[$q get retry]\""
|
||||
puts -nonewline "}"
|
||||
}
|
||||
puts "\n]"
|
||||
|
@ -16,51 +16,27 @@ puts {
|
||||
</h3>
|
||||
<fieldset class=cleft>
|
||||
<legend>Queued Tasks</legend>
|
||||
<table class=borders cellpadding=5>
|
||||
<table id=queuetab class=borders cellpadding=5>
|
||||
<thead>
|
||||
<tr>
|
||||
<th nowrap>ID<input type=checkbox id=selall></th>
|
||||
<th nowrap>ID</th>
|
||||
<th>Submitted</th>
|
||||
<th>File</th>
|
||||
<th>Action</th>
|
||||
<th>Status</th>
|
||||
<th>Time</th>
|
||||
<th>Log</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
}
|
||||
|
||||
foreach q [queue all] {
|
||||
set name [string map {
|
||||
"/mnt/hd2/My Video/" ""
|
||||
"/media/drive1/Video/" ""
|
||||
"/media/" ""
|
||||
".ts" ""
|
||||
} [$q get file]]
|
||||
|
||||
puts "
|
||||
<tr>
|
||||
<td><input type=checkbox class=qid value=[$q get id]>
|
||||
[$q get id]
|
||||
</td>
|
||||
<td>[clock format [$q get dat] -format {%c}]</td>
|
||||
<td>$name</td>
|
||||
<td>[$q get action]</td>
|
||||
<td class=\"status [$q get status]\">[$q get status]"
|
||||
if {[$q get status] eq "RUNNING"} {
|
||||
puts "<img src=/img/loading.gif>"
|
||||
}
|
||||
puts "</td>
|
||||
<td>[$q get log]</td>
|
||||
</tr>
|
||||
"
|
||||
}
|
||||
|
||||
puts {
|
||||
</tbody>
|
||||
</table>
|
||||
<button id=qdelete>Delete Selected</button>
|
||||
<button id=refresh>Refresh Page</button>
|
||||
<button id=selcomplete>Select Completed</button>
|
||||
<button id=selall>Select All</button>
|
||||
<button id=selnone>Select None</button>
|
||||
<button id=refresh>Refresh</button>
|
||||
<span id=isloading><img src=/img/loading.gif></span>
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,50 @@ function page_refresh(msg)
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
$.getJSON('fetch.jim', function(data) {
|
||||
$('#queuetab > tbody').empty();
|
||||
|
||||
$.each(data, function(k, v) {
|
||||
|
||||
$('#isloading').show('fast');
|
||||
|
||||
s = '<tr>' +
|
||||
'<td><input type=checkbox class=qid status=' + v.status +
|
||||
' value=' + v.qid + '>' +
|
||||
v.qid + '</td>' +
|
||||
'<td>' + v.dat + '</td>' +
|
||||
'<td>' + v.file + '</td>' +
|
||||
'<td>' + v.action + '</td>' +
|
||||
'<td class="status ' + v.status + '">' + v.status;
|
||||
if (v.status == 'RUNNING')
|
||||
s += ' <img class=va src=/img/loading.gif>';
|
||||
s += '</td><td>';
|
||||
if (v.elapsed != '0')
|
||||
s += v.elapsed;
|
||||
s += '</td>' +
|
||||
'<td>' + v.log + '</td>' +
|
||||
'</tr>';
|
||||
|
||||
$('#queuetab > tbody').append(s);
|
||||
});
|
||||
var resort = true;
|
||||
$('#queuetab').trigger('update', [resort]);
|
||||
$('input.qid:checkbox').prop('checked', false).enable();
|
||||
|
||||
$('tr').each(function() {
|
||||
var status = $(this).find('td.status').text();
|
||||
|
||||
if (status == 'RUNNING')
|
||||
$(this).find('input.qid:checkbox').disable();
|
||||
});
|
||||
|
||||
$('input.qid').first().trigger('change');
|
||||
$('#isloading').hide('slow');
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
$('table')
|
||||
@ -18,17 +62,9 @@ $('table')
|
||||
widgets: ['zebra', 'stickyHeaders']
|
||||
});
|
||||
|
||||
load();
|
||||
|
||||
$('input.qid:checkbox').prop('checked', false).enable();
|
||||
|
||||
$('tr').each(function() {
|
||||
var status = $(this).find('td.status').text();
|
||||
|
||||
if (status == 'RUNNING')
|
||||
$(this).find('input.qid:checkbox').disable();
|
||||
});
|
||||
|
||||
$('input.qid:checkbox').on('change', function() {
|
||||
$('#queuetab').on('change', 'input.qid', function() {
|
||||
var num = $('input.qid:checked').size();
|
||||
if (num)
|
||||
$('#qdelete').enable();
|
||||
@ -47,7 +83,6 @@ $('#qdelete').button({icons:{primary:"ui-icon-trash"}})
|
||||
message: '<h1><img src=/img/loading.gif> Deleting... </h1>'
|
||||
});
|
||||
|
||||
|
||||
var slots = $('input.qid:checked').map(function() {
|
||||
return this.value;
|
||||
}).get();
|
||||
@ -60,16 +95,27 @@ $('#qdelete').button({icons:{primary:"ui-icon-trash"}})
|
||||
|
||||
});
|
||||
|
||||
$('#selnone').button({icons:{primary:"ui-icon-close"}})
|
||||
.on('click', function() {
|
||||
$('#queuetab input:checkbox').prop('checked', false);
|
||||
});
|
||||
|
||||
$('#selall').button({icons:{primary:"ui-icon-check"}})
|
||||
.on('click', function() {
|
||||
$('#queuetab input:checkbox').prop('checked', true);
|
||||
});
|
||||
|
||||
$('#selcomplete').button({icons:{primary:"ui-icon-stop"}})
|
||||
.on('click', function() {
|
||||
$('#queuetab input:checkbox[status="COMPLETE"]').prop('checked', true);
|
||||
});
|
||||
|
||||
$('#refresh').button({icons:{primary:"ui-icon-refresh"}})
|
||||
.on('click', function() {
|
||||
page_refresh();
|
||||
load();
|
||||
});
|
||||
|
||||
$('#selall').on('change', function() {
|
||||
$('input.qid:checkbox').prop('checked', $(this).prop('checked'));
|
||||
});
|
||||
|
||||
setInterval(function() { page_refresh() }, 60000);
|
||||
setInterval(load, 60000);
|
||||
|
||||
});
|
||||
|
||||
|
@ -121,7 +121,7 @@ foreach mod $modules {
|
||||
proc plugin_callback {plugin hook} {
|
||||
puts "<h4>Settings for <i>[file tail $plugin]</i> package</h4>"
|
||||
puts "<div class=pluginsettings>"
|
||||
if {[catch {source "$plugin/$hook"} msg]} {
|
||||
if {[catch {uplevel source "$plugin/$hook"} msg]} {
|
||||
puts "ERROR: $msg"
|
||||
}
|
||||
puts "</div>"
|
||||
|
@ -881,6 +881,7 @@ if {[lindex $argv 0] eq "-singledir"} {
|
||||
scansingle [lrange $argv 1 end]
|
||||
} elseif {[lindex $argv 0] eq "-queue"} {
|
||||
log "Processing queue..." 2
|
||||
queue startup
|
||||
while {[llength [set q [queue pop]]]} {
|
||||
oktorun
|
||||
|
||||
@ -900,11 +901,14 @@ if {[lindex $argv 0] eq "-singledir"} {
|
||||
}
|
||||
set func $::queue_actions($act)
|
||||
$q update RUNNING "Started at [clock format [clock seconds]]"
|
||||
set start [clock seconds]
|
||||
if {[catch {$func $ts} msg]} {
|
||||
$q update FAILED $msg 1
|
||||
continue
|
||||
}
|
||||
$q update COMPLETE "Completed at [clock format [clock seconds]]"
|
||||
set elapsed $([clock seconds] - $start)
|
||||
$q update COMPLETE \
|
||||
"Completed at [clock format [clock seconds]]" 0 $elapsed
|
||||
}
|
||||
} elseif {[llength $argv] > 0} {
|
||||
set loglevel 2
|
||||
|
@ -1,7 +0,0 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
source /mod/webif/lib/setup
|
||||
require queue.class
|
||||
|
||||
queue boot
|
||||
|
@ -4,7 +4,7 @@ proc eval_plugins {hook {verbose 0} {callback ""}} {
|
||||
if {[file exists "$plugin/.disabled"]} continue
|
||||
if {[file isfile "$plugin/$hook.hook"]} {
|
||||
if {$callback ne ""} {
|
||||
$callback $plugin $hook.hook
|
||||
uplevel $callback $plugin $hook.hook
|
||||
continue
|
||||
}
|
||||
if {[catch \
|
||||
|
@ -10,6 +10,7 @@ class queue {
|
||||
log ""
|
||||
status ""
|
||||
retry 0
|
||||
elapsed 0
|
||||
}
|
||||
|
||||
proc {queue dbhandle} {args} {
|
||||
@ -36,6 +37,7 @@ proc {queue dbhandle} {args} {
|
||||
action text,
|
||||
status text default 'PENDING',
|
||||
log text default '',
|
||||
elapsed integer,
|
||||
retry integer default 0
|
||||
);
|
||||
}
|
||||
@ -44,26 +46,39 @@ proc {queue dbhandle} {args} {
|
||||
}
|
||||
} else {
|
||||
set ::queue::db [sqlite3.open /mod/etc/queue.db]
|
||||
# XXX - Remove before release
|
||||
catch { $::queue::db query {
|
||||
alter table queue
|
||||
add column elapsed integer default 0
|
||||
}}
|
||||
}
|
||||
|
||||
return $::queue::db
|
||||
}
|
||||
|
||||
queue method update {_status {_log ""} {_retry 0}} {
|
||||
queue method update {_status {_log ""} {_retry 0} {_elapsed 0}} {
|
||||
set db [queue dbhandle]
|
||||
$db query {
|
||||
update queue
|
||||
set status = '%s', log = '%s', retry = retry + %s
|
||||
set status = '%s',
|
||||
log = '%s',
|
||||
retry = retry + %s,
|
||||
elapsed = %s
|
||||
where id = %s
|
||||
} $_status $_log $_retry $id
|
||||
} $_status $_log $_retry $_elapsed $id
|
||||
|
||||
set status $_status
|
||||
set log $_log
|
||||
incr retry $_retry
|
||||
set elapsed $_elapsed
|
||||
}
|
||||
|
||||
proc {queue boot} {} {
|
||||
proc {queue startup} {} {
|
||||
set db [queue dbhandle]
|
||||
$db query {
|
||||
update queue
|
||||
set status = 'INTERRUPTED',
|
||||
log = 'System was shut down. Job will be retried automatically.',
|
||||
log = 'Job will be retried automatically.',
|
||||
retry = retry + 1
|
||||
where status in ('RUNNING', 'INTERRUPTED')
|
||||
}
|
||||
@ -71,7 +86,7 @@ proc {queue boot} {} {
|
||||
delete from queue
|
||||
where status in ('COMPLETE', 'FAILED')
|
||||
and dat < %s
|
||||
} [expr [clock seconds] - 86400 * 3]
|
||||
} [expr [clock seconds] - 86400 * 7]
|
||||
}
|
||||
|
||||
proc {queue insert} {ts action} {
|
||||
|
Loading…
Reference in New Issue
Block a user