forked from hummypkg/webif
new log viewer
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@2084 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
8516f21c18
commit
bf94690223
@ -1,7 +1,7 @@
|
||||
Package: webif
|
||||
Priority: optional
|
||||
Section: web
|
||||
Version: 1.0.18
|
||||
Version: 1.0.18-1
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hummypkg.org.uk
|
||||
Depends: webif-channelicons(>=1.1.14),lighttpd(>=1.4.35-2),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.0.14),hmt(>=1.1.21),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),mongoose
|
||||
|
@ -1,22 +0,0 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
|
||||
httpheader
|
||||
|
||||
set logdirs {/var/log /mod/tmp /mnt/hd3}
|
||||
set logext {.log}
|
||||
|
||||
set log [cgi_get file 0]
|
||||
set unlink [cgi_get unlink 0]
|
||||
|
||||
set ldir [file dirname $log]
|
||||
if {[file dirname $log] in $logdirs && [file extension $log] in $logext} {
|
||||
file copy -force "/dev/null" $log
|
||||
if {$unlink} { file delete $log }
|
||||
puts "Cleared $log"
|
||||
exit
|
||||
}
|
||||
puts "Cannot clear $log"
|
||||
|
@ -12,7 +12,6 @@ pkg loaddiagmeta
|
||||
|
||||
set smv [system modversion 1]
|
||||
|
||||
|
||||
puts {
|
||||
<fieldset class=cleft>
|
||||
<legend>Utilities</legend>
|
||||
@ -167,17 +166,14 @@ View:
|
||||
<legend>View Log Files</legend>
|
||||
}
|
||||
|
||||
foreach file [lsort [concat \
|
||||
[glob -nocomplain /var/log/*.log] \
|
||||
[glob -nocomplain /mod/tmp/*.log] \
|
||||
[glob -nocomplain /mnt/hd3/*.log] \
|
||||
]] {
|
||||
puts "<a href=# class=log file=\"$file\">
|
||||
source /mod/webif/html/log/_lib.jim
|
||||
foreach file [lsort -command logsort $loglist] {
|
||||
puts "
|
||||
<img border=0 height=14 src=/images/421_1_00_CH_Title_2R_Arrow.png>
|
||||
[file tail $file]</a>
|
||||
<a href=\"../log/?log=[cgi_quote_url $file]\">
|
||||
[file tail $file]
|
||||
</a>
|
||||
(<span class=lsize>[pretty_size [file size $file]]</span>)
|
||||
<a class=\"va footnote logclear\" href=# file=\"$file\">
|
||||
<img class=va border=0 src=/img/close.png width=20>Clear</a>
|
||||
<br>"
|
||||
}
|
||||
|
||||
|
@ -27,32 +27,6 @@ $('#runfopkg').click(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$('a.log').click(function(e) {
|
||||
e.preventDefault();
|
||||
$('#results')
|
||||
.slideDown()
|
||||
.text('\n\nLoading log, please wait...\n\n')
|
||||
.load('/cgi-bin/cat.jim?file=' +
|
||||
encodeURIComponent($(this).attr('file')), function() {
|
||||
$('#results').wrapInner('<pre>');
|
||||
});
|
||||
});
|
||||
|
||||
$('a.logclear').click(function(e) {
|
||||
var t = $(this);
|
||||
e.preventDefault();
|
||||
if (!confirm('Delete ' + $(this).attr('file') + '?'))
|
||||
return;
|
||||
$('#results')
|
||||
.slideDown()
|
||||
.text('\n\nClearing log, please wait...\n\n')
|
||||
.load('clearlog.jim?file=' +
|
||||
encodeURIComponent($(this).attr('file')), function() {
|
||||
$('#results').wrapInner('<pre>');
|
||||
$(t).prev('span.lsize').html('0 bytes');
|
||||
});
|
||||
});
|
||||
|
||||
$('#runedit').click(function(e) {
|
||||
e.preventDefault();
|
||||
window.location = '/edit/edit.jim';
|
||||
|
56
webif/html/lib/jquery.plugin/bindwithdelay/bindWithDelay.js
Normal file
56
webif/html/lib/jquery.plugin/bindwithdelay/bindWithDelay.js
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
bindWithDelay jQuery plugin
|
||||
Author: Brian Grinstead
|
||||
MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
http://github.com/bgrins/bindWithDelay
|
||||
http://briangrinstead.com/files/bindWithDelay
|
||||
|
||||
Usage:
|
||||
See http://api.jquery.com/bind/
|
||||
.bindWithDelay( eventType, [ eventData ], handler(eventObject), timeout, throttle )
|
||||
|
||||
Examples:
|
||||
$("#foo").bindWithDelay("click", function(e) { }, 100);
|
||||
$(window).bindWithDelay("resize", { optional: "eventData" }, callback, 1000);
|
||||
$(window).bindWithDelay("resize", callback, 1000, true);
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.fn.bindWithDelay = function( type, data, fn, timeout, throttle ) {
|
||||
|
||||
if ( $.isFunction( data ) ) {
|
||||
throttle = timeout;
|
||||
timeout = fn;
|
||||
fn = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
// Allow delayed function to be removed with fn in unbind function
|
||||
fn.guid = fn.guid || ($.guid && $.guid++);
|
||||
|
||||
// Bind each separately so that each element has its own delay
|
||||
return this.each(function() {
|
||||
|
||||
var wait = null;
|
||||
|
||||
function cb() {
|
||||
var e = $.extend(true, { }, arguments[0]);
|
||||
var ctx = this;
|
||||
var throttler = function() {
|
||||
wait = null;
|
||||
fn.apply(ctx, [e]);
|
||||
};
|
||||
|
||||
if (!throttle) { clearTimeout(wait); wait = null; }
|
||||
if (!wait) { wait = setTimeout(throttler, timeout); }
|
||||
}
|
||||
|
||||
cb.guid = fn.guid;
|
||||
|
||||
$(this).bind(type, data, cb);
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/first.png
Normal file
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/first.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 720 B |
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/last.png
Normal file
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/last.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 737 B |
Binary file not shown.
After Width: | Height: | Size: 416 B |
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/next.png
Normal file
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/next.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 736 B |
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/prev.png
Normal file
BIN
webif/html/lib/jquery.plugin/tablesorter2/images/pager/prev.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 745 B |
12
webif/html/log/_lib.jim
Executable file
12
webif/html/log/_lib.jim
Executable file
@ -0,0 +1,12 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
set loglist [concat \
|
||||
[glob -nocomplain /var/log/*.log] \
|
||||
[glob -nocomplain /mod/tmp/*.log] \
|
||||
[glob -nocomplain /mnt/hd3/*.log]
|
||||
]
|
||||
|
||||
proc logsort {a b} {
|
||||
return [string compare [file tail $a] [file tail $b]]
|
||||
}
|
||||
|
24
webif/html/log/act.jim
Executable file
24
webif/html/log/act.jim
Executable file
@ -0,0 +1,24 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
|
||||
source _lib.jim
|
||||
|
||||
cgi_input
|
||||
|
||||
set file [cgi_get file "-"]
|
||||
if {$file ni $loglist} { exit }
|
||||
|
||||
set action [cgi_get action -]
|
||||
|
||||
switch $action {
|
||||
clear {
|
||||
file copy -force "/dev/null" $file
|
||||
puts "Cleared $file"
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
puts "Unknown action."
|
||||
|
32
webif/html/log/fetch.jim
Executable file
32
webif/html/log/fetch.jim
Executable file
@ -0,0 +1,32 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
|
||||
source _lib.jim
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
httpheader
|
||||
|
||||
set file [cgi_get file "-"]
|
||||
if {$file eq "-"} { set file "/var/log/humaxtv.log" }
|
||||
if {$file ni $loglist} { exit }
|
||||
|
||||
set lines [cgi_get lines 0]
|
||||
|
||||
if {$lines} {
|
||||
set fp [popen [list tail -n $lines $file]]
|
||||
} else {
|
||||
set fp [open $file r]
|
||||
}
|
||||
set l 1
|
||||
while {![$fp eof]} {
|
||||
$fp gets line
|
||||
if {[$fp eof]} break
|
||||
puts "<tr><td>$l</td><td>[cgi_quote_html $line]</td></tr>"
|
||||
incr l
|
||||
}
|
||||
$fp close
|
||||
|
90
webif/html/log/index.jim
Executable file
90
webif/html/log/index.jim
Executable file
@ -0,0 +1,90 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require pretty_size system.class pkg.class
|
||||
source _lib.jim
|
||||
|
||||
set logf [cgi_get log -]
|
||||
|
||||
jqplugin enadis tablesorter2 bindwithdelay highlight
|
||||
jscss script.js style.css
|
||||
header
|
||||
|
||||
puts "
|
||||
<div class=cleft>
|
||||
Log File: <select id=log name=log>
|
||||
<option value=0>--- Select logfile ---</option>
|
||||
"
|
||||
|
||||
foreach file [lsort -command logsort $loglist] {
|
||||
set pf ""
|
||||
if {[string match {/var/log/*} $file]} {
|
||||
set pf " *"
|
||||
}
|
||||
puts -nonewline "<option value=\"$file\""
|
||||
if {$logf eq $file} {
|
||||
puts -nonewline " selected"
|
||||
}
|
||||
puts ">[file rootname [file tail $file]]$pf</option>"
|
||||
}
|
||||
|
||||
|
||||
proc pager {} {
|
||||
set ir "/lib/jquery.plugin/tablesorter2/images/pager"
|
||||
|
||||
return "
|
||||
<div class=\"pager cleft\">
|
||||
Page: <select class=gotoPage></select>
|
||||
<img src=$ir/first.png class=first alt=First title=First page />
|
||||
<img src=$ir/prev.png class=prev alt=Prev title=Previous page />
|
||||
<span class=pagedisplay></span>
|
||||
<img src=$ir/next.png class=next alt=Next title=Next page />
|
||||
<img src=$ir/last.png class=last alt=Last title= Last page />
|
||||
<select class=pagesize>
|
||||
<option value=50>50</option>
|
||||
<option value=100>100</option>
|
||||
<option value=200>200</option>
|
||||
<option value=500>500</option>
|
||||
</select>
|
||||
lines
|
||||
</div>
|
||||
"
|
||||
}
|
||||
|
||||
puts "
|
||||
</select>
|
||||
<span id=loginfo class=blood></span>
|
||||
<span id=loading class=hidden><img src=/img/loading.gif>Loading...</span>
|
||||
</div>
|
||||
|
||||
<div class=left id=buttons>
|
||||
<button id=reload>Reload</button>
|
||||
<button id=clear>Clear Log</button>
|
||||
</div>
|
||||
|
||||
<div id=logarea class=\"cleft hidden\">
|
||||
[pager]
|
||||
|
||||
<div class=left id=highlight_div>
|
||||
Highlight:
|
||||
<input type=text placeholder=\"Enter text\" value=\"\" size=30 id=highlight>
|
||||
</div>
|
||||
|
||||
<table id=logtab>
|
||||
<thead><tr>
|
||||
<th class=\"line filter-false\">Line</th>
|
||||
<th class=text
|
||||
data-sorter=\"false\"
|
||||
data-placeholder=\"Search log...\">Text</th>
|
||||
</tr></thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
[pager]
|
||||
|
||||
</div>
|
||||
"
|
||||
|
||||
footer
|
||||
|
26
webif/html/log/loginfo.jim
Executable file
26
webif/html/log/loginfo.jim
Executable file
@ -0,0 +1,26 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require pretty_size
|
||||
|
||||
source _lib.jim
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
set file [cgi_get file "-"]
|
||||
if {$file eq "-"} { set file "/var/log/humaxtv.log" }
|
||||
if {$file ni $loglist} { exit }
|
||||
|
||||
httpheader "application/json"
|
||||
|
||||
lassign [exec wc -l $file] lines
|
||||
|
||||
puts "{
|
||||
\"size\": \"[file size $file]\",
|
||||
\"pretty_size\": \"[pretty_size [file size $file]]\",
|
||||
\"lines\": \"$lines\"
|
||||
}
|
||||
"
|
||||
|
149
webif/html/log/script.js
Normal file
149
webif/html/log/script.js
Normal file
@ -0,0 +1,149 @@
|
||||
|
||||
$(function() {
|
||||
|
||||
// 0 - client side
|
||||
// 1 - server side
|
||||
var mode = -1;
|
||||
var logfile;
|
||||
var logdata;
|
||||
|
||||
var pageroptions = {
|
||||
container: $('.pager'),
|
||||
output: 'Showing {startRow} - {endRow} / {filteredRows}',
|
||||
size: 50,
|
||||
fixedHeight: true,
|
||||
removeRows: false,
|
||||
cssGoto: '.gotoPage'
|
||||
};
|
||||
|
||||
var pageroptionsajax = $.extend({
|
||||
ajaxUrl: 'fetch.jim?page={page}&size={size}&{sortList:col}&{filterList:fcol}',
|
||||
customAjaxUrl: function(table, url) {
|
||||
var nurl = 'fetch.jim?file=' + encodeURIComponent(logfile) +
|
||||
'&' + url.substring(10);
|
||||
alert(nurl);
|
||||
return nurl;
|
||||
}
|
||||
}, pageroptions);
|
||||
|
||||
function loadlog_ajax()
|
||||
{
|
||||
$('#loginfo').append(' <i>(Ajax)</i>');
|
||||
if (mode != 1)
|
||||
{
|
||||
//$('#logtab').trigger('destroy.pager');
|
||||
$('#logtab').tablesorterPager(pageroptionsajax);
|
||||
$('#logtab').trigger('pageSet', 0);
|
||||
mode = 1;
|
||||
}
|
||||
loadedlog();
|
||||
}
|
||||
|
||||
function loadlog_entire(data)
|
||||
{
|
||||
var lines = 0;
|
||||
|
||||
if (data.lines > 5000)
|
||||
{
|
||||
lines = 5000;
|
||||
$('#loginfo').append(' - <i>showing 5000 most recent.</i>');
|
||||
}
|
||||
|
||||
$.get('fetch.jim', {
|
||||
'file': logfile,
|
||||
'lines': lines
|
||||
}, function(data) {
|
||||
if (mode != 0)
|
||||
{
|
||||
$('#logtab').trigger('destroy.pager');
|
||||
$('#logtab').tablesorterPager(pageroptions);
|
||||
mode = 0;
|
||||
}
|
||||
$('#logtab tbody').html(data).trigger('update');
|
||||
$('#logtab').trigger('update');
|
||||
loadedlog();
|
||||
});
|
||||
}
|
||||
|
||||
function loadlog(file, ajax)
|
||||
{
|
||||
$('button').button('disable');
|
||||
|
||||
if (!file || file == '0')
|
||||
return;
|
||||
|
||||
$('#logarea').slideDown();
|
||||
$('#loginfo').empty();
|
||||
$('#loading').show('fast');
|
||||
$('#logtab tbody').empty();
|
||||
|
||||
// Fetch log info
|
||||
$.getJSON('loginfo.jim', { 'file': file }, function(data) {
|
||||
$('#loginfo').html(data.pretty_size +
|
||||
' (' + data.lines + ' line' +
|
||||
(data.lines == 1 ? "" : "s") + ')');
|
||||
logfile = file;
|
||||
logdata = data;
|
||||
if (ajax)
|
||||
loadlog_ajax(data);
|
||||
else
|
||||
loadlog_entire(data);
|
||||
});
|
||||
}
|
||||
|
||||
function loadedlog()
|
||||
{
|
||||
$('#logtab')
|
||||
.trigger('filterReset')
|
||||
.trigger('sorton', [[[0,1]]]);
|
||||
$('#loading').hide('fast');
|
||||
|
||||
$('button').button('enable');
|
||||
|
||||
if (logdata.lines == 0)
|
||||
{
|
||||
$('#logtab tbody')
|
||||
.html('<tr><td></td><td><i>Log is empty...</i></td></tr>');
|
||||
$('#clear').button('disable');
|
||||
}
|
||||
|
||||
var hl = $('#highlight').val();
|
||||
if (hl && hl.length)
|
||||
$('#highlight').trigger('keyup');
|
||||
}
|
||||
|
||||
$('#logtab')
|
||||
.tablesorter({
|
||||
theme: 'green',
|
||||
sortList: [[0,1]],
|
||||
headerTemplate : '{content} {icon}',
|
||||
widthFixed: true,
|
||||
widgets: ['zebra', 'filter']
|
||||
});
|
||||
|
||||
$('#clear').button({icons: { primary: "ui-icon-trash" }})
|
||||
.on('click', function() {
|
||||
if (confirm('Are you sure you wish to clear ' + logfile + '?'))
|
||||
$.get('act.jim', {
|
||||
'file': logfile,
|
||||
'action': 'clear'
|
||||
}, function() {
|
||||
loadlog(logfile);
|
||||
});
|
||||
});
|
||||
|
||||
$('#reload').button({icons: { primary: "ui-icon-refresh" }})
|
||||
.on('click', function() {
|
||||
$('#log').trigger('change');
|
||||
});
|
||||
|
||||
$('#highlight').bindWithDelay('keyup', function(e) {
|
||||
$('#logtab tbody').removeHighlight().highlight($(this).val());
|
||||
}, 500);
|
||||
|
||||
$('#log').on('change', function() {
|
||||
loadlog($('#log').val())
|
||||
}).trigger('change');
|
||||
|
||||
});
|
||||
|
38
webif/html/log/style.css
Normal file
38
webif/html/log/style.css
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
div#logarea
|
||||
{
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
th.line
|
||||
{
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
div.pager
|
||||
{
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
td
|
||||
{
|
||||
padding: 3px !important;
|
||||
}
|
||||
|
||||
#buttons
|
||||
{
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
#highlight_div
|
||||
{
|
||||
padding-left: 5em;
|
||||
}
|
||||
|
||||
#highlight
|
||||
{
|
||||
padding: 5px 10px;
|
||||
border-style: none;
|
||||
box-sharow: none;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user