add tcpfix, chunked mode for pkg/diag output

git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2646 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2016-02-14 18:24:30 +00:00
parent 687fc606a1
commit 59c4e7ad1f
8 changed files with 232 additions and 198 deletions

View File

@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.2.8-3
Version: 1.2.8-4
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.20),lighttpd(>=1.4.39-1),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.1),hmt(>=2.0.9),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),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7)
Depends: tcpfix,webif-channelicons(>=1.1.20),lighttpd(>=1.4.39-1),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.1),hmt(>=2.0.9),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),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7)
Suggests:
Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/6484/

View File

@ -9,28 +9,31 @@ cgi_input
set cmd [cgi_get cmd update]
proc putsf {str} {
puts $str
flush stdout
}
proc opkg {cmd} {
puts ">>> opkg $cmd"
putsf ">>> opkg $cmd"
set bcmd "|/mod/webif/lib/bin/opkg $cmd"
set fd [open $bcmd r]
while {[gets $fd line] >= 0} {
puts "$line"
putsf "$line"
}
close $fd
puts ""
putsf ""
}
httpheader "text/plain"
httpheader "text/plain" 0 "Transfer-Encoding: chunked\r\n"
set cmdargs [lassign $cmd cmd]
set netcmds {install update upgrade}
if {$cmd in $netcmds && ![system connectivity]} {
puts ""
puts "!! ERROR - No network connectivity to package repository !!"
puts ""
puts "Check your Internet connection and DNS service and then try again."
putsf "!! ERROR - No network connectivity to package repository !!"
putsf "Check your Internet connection and DNS service and then try again."
exit
}
@ -38,12 +41,13 @@ if {$cmd eq "upgrade"} { opkg update }
opkg "$cmd $cmdargs"
if {$cmd eq "update" || $cmd eq "upgrade"} {
puts "Updating package meta information"
putsf "Updating package meta information"
pkg fetchmeta
puts "Done."
puts ""
puts "Updating diagnostic meta information"
putsf "Done."
putsf ""
putsf "Updating diagnostic meta information"
pkg fetchdiagmeta
puts "Done."
}
putsf "Done."

View File

@ -3,7 +3,11 @@
puts {
<div id=d_results class=hidden title="Results">
<div id=results></div>
<div id=resultsheader></div>
<div id=results></div>
<div class=hidden id=resultscomplete>
<img border=0 src=/images/167_2_00_Check_W2_SUB.png> Completed.
</div>
</div>
<div id=safeconfirm class=hidden xtitle="Safe Mode">

View File

@ -88,15 +88,17 @@ util "editor" "editor" "File Editor" "/edit/edit.jim"
util "db" "dbinfo" "Database Browser" "/db/"
util "aerials" "muxinfo" "Mux Info" "/diag/mux.jim"
util "disc" "disk" "Disk Diagnostics" "/diag/disk.jim"
util "dspace" "diskspace" "Disk Space" "/diag/dspace/"
if {$model eq "HDR"} {
util "disc" "disk" "Disk Diagnostics" "/diag/disk.jim"
util "dspace" "diskspace" "Disk Space" "/diag/dspace/"
util "dlna_large" "dlna" "DLNA Reset" "/dlna/dlna.jim"
}
if {$smv >= 310} {
util "safe" "safe" "Safe Mode" "#" "<br><span id=saferesult></span>"
}
util "reset" "reset" "CFW Reset" "#" "<br><span id=resetresult></span>"
util "shredder" "rma" "RMA" "#" "<br><span id=rmaresult></span>"

View File

@ -12,34 +12,68 @@ var $dialog = $('#d_results').dialog({
height: 600, width: 900,
show: 'scale', hide: 'fade',
draggable: true, resizable: true,
buttons: { "Close":
function() {$(this).dialog('close');}},
buttons: { "Close": function() { $(this).dialog('close'); }}
});
function loaddata(data, status)
{
$('#results').text(data).wrapInner('<pre>');
if (status) // Request completed
{
$('#resultscomplete').slideDown('slow');
$('#resultsheader').slideUp('slow', function() {
$(this).empty();
});
}
// $('#d_results').animate({
// scrollTop: $('#d_results').scrollTop() + ('#d_results').height()
// }, 'slow');
}
function chunked_request(placeholder, url, data)
{
$('#resultsheader').html('<img src=/img/loading.gif> ' + placeholder)
.slideDown('slow');
$('#resultscomplete').hide();
$('#results').empty();
$('#d_results').dialog('open');
$.ajax({
type: "GET",
url: url,
data: data,
xhrFields: {
onprogress: function(x) {
if (x.target)
loaddata(x.target.responseText);
}
},
progressInterval: 500,
success: function(data, status) {
loaddata(data, status);
},
error: function(_, _, e) {
if (window.console)
console.log("ajax error");
alert(e);
}
});
}
$('#rundiag').on('click', function() {
var val = $('#diagsel').val();
if (val == '0')
val = $('#seq').val();
$('#results')
.html('<img src=/img/loading.gif> Running diagnostic ' +
'<i>' + val + '</i>')
.load('rundiag.jim', { diag: val }, function() {
$('#results').wrapInner('<pre>');
});
$('#d_results').dialog('open');
chunked_request('Running diagnostic <i>' + val + '</i>',
'rundiag.jim', { diag: val });
});
$('#runfopkg').on('click', function() {
var pkg = $('#fopkg').val();
$('#results')
.html('<img src=/img/loading.gif> ' +
'Forcibly re-installing package <i>' + pkg + '</i>')
.load('/cgi-bin/opkg.jim', {
cmd: 'install --force-reinstall ' + pkg
}, function() {
$('#results').wrapInner('<pre>');
});
$('#d_results').dialog('open');
chunked_request('Re-installing package <i>' + pkg + '</i>',
'/cgi-bin/opkg.jim', { cmd: 'install --force-reinstall ' + pkg });
});
$('a.logclear').on('click', function(e) {
@ -50,16 +84,9 @@ $('a.logclear').on('click', function(e) {
if (!confirm('Delete ' + file + '?'))
return;
$('#results')
.html('<img src=/img/loading.gif> Clearing log ' +
'<i>' + file + '</i>')
.load('/log/act.jim', {
action: 'clear',
file: file
}, function() {
$('#results').wrapInner('<pre>');
});
$('#d_results').dialog('open');
chunked_request('Clearing log <i>' + file + '</i>',
'/log/act.jim', { action: 'clear', file: file });
});
$.getJSON('/diag/rpc.jim?act=getall', function(data) {
@ -71,7 +98,6 @@ $.getJSON('/diag/rpc.jim?act=getall', function(data) {
});
});
$('#safe,#reset,#rma,#maint').on('click', function(e) {
e.preventDefault();

View File

@ -30,7 +30,7 @@ puts {
</div>
<div id=dialogue class=hidden style="align: center">
<pre id=dresults></pre>
<div id=dresults></div>
<div id=dspinner>
<img border=0 src=/img/loading.gif>
Processing request...

View File

@ -1,169 +1,166 @@
var opkg = '/cgi-bin/opkg.jim?cmd=';
var opkg = '/cgi-bin/opkg.jim';
$(document).ready(function() {
var busy = false;
var tswitch = false;
var stick = true;
var busy = false;
var tswitch = false;
var stick = true;
// Retrieve the stored selected tab from the hash portion of the URL.
var curtab = ~~(window.location.hash.slice(1));
if (curtab < 0 || curtab > 2)
curtab = 0;
// Retrieve the stored selected tab from the hash portion of the URL.
var curtab = ~~(window.location.hash.slice(1));
if (curtab < 0 || curtab > 2)
curtab = 0;
$('#opkgupdate')
.button()
.click(function() { tswitch = 2; execopkg('update'); })
.fadeIn('slow');
$('#opkgupdate')
.button()
.click(function() { tswitch = 2; execopkg('update'); })
.fadeIn('slow');
$('#opkgupgradeall')
.button()
.click(function() { tswitch = 2; execopkg('upgrade'); })
.fadeIn('slow');
$('#opkgupgradeall')
.button()
.click(function() { tswitch = 2; execopkg('upgrade'); })
.fadeIn('slow');
$('#pkgtabs').tabs({
active: curtab,
create: function(event, ui) {
$(ui.panel).html("<img src=/img/loading.gif>" +
"Loading data... Please wait...");
busy = true;
$('#pkgtabs').tabs('disable');
},
activate: function(event, ui) {
window.location.hash = ui.newTab.index();
if (busy)
{
alert('Please wait until the current ' +
'operation completes.');
return false;
}
$(ui.newPanel).html("<img src=/img/loading.gif>" +
"Loading data... Please wait...");
busy = true;
$('#pkgtabs').tabs('disable');
},
load: function() {
busy = false;
setup_buttons();
$('#pkgtabs').tabs('enable');
},
spinner: '<img border=0 src=/img/loading.gif> ' +
'<em>Loading...</em>'
});
var $dialog = $('#dialogue').dialog({
title: "Package Management Results",
modal: false, autoOpen: false,
height: 500, width: 700,
show: 'scale', hide: 'fade',
draggable: true, resizable: true,
buttons: { "Close":
function() {$(this).dialog('close');}},
close: function(e,u) {
if (tswitch)
{
var curtab = $('#pkgtabs')
.tabs('option', 'active');
if (curtab != tswitch)
$('#pkgtabs').tabs('option',
'active', tswitch);
else
{
$('.ui-tabs-panel')
.html("<img src=/img/loading.gif>" +
"Loading data... Please wait...");
$('#pkgtabs').tabs('load', tswitch);
}
tswitch = false;
$('button.va').enable();
}
else
{
var pkg = $('#dialogue').attr('pkg');
$('tr[pkg="' + pkg + '"]')
.disable()
.find('button').removeClass('va');
$('button.va').enable();
}
}
});
function loaddata(data, status)
{
if (window.console)
{
console.log('loaddata called, status=' + status);
console.log('Data: ' + data);
}
if (status)
{
$('#dresults').text(data);
$('#dspinner').hide('slow');
$('#complete').show('slow');
if (status == 'success' && !stick)
$('#dialogue').dialog('close');
//stick = false;
}
else
$('#dresults').append(data);
}
function execopkg(arg, pkg)
{
$('#pkgtabs').tabs({
active: curtab,
create: function(event, ui) {
$(ui.panel).html("<img src=/img/loading.gif>" +
"Loading data... Please wait...");
busy = true;
$('#pkgtabs').tabs('disable');
},
activate: function(event, ui) {
window.location.hash = ui.newTab.index();
if (busy)
{
alert('Please wait until the current ' +
'operation completes.');
return;
return false;
}
$(ui.newPanel).html("<img src=/img/loading.gif>" +
"Loading data... Please wait...");
busy = true;
$('button.va').disable();
$('#dspinner').show();
$('#complete').hide();
$('#dresults').empty();
$('#dialogue').attr('pkg', pkg);
$dialog.dialog('open');
$.ajax({
type: "GET",
url: opkg + arg,
progress: loaddata,
progressInterval: 500,
success: function(data, status) {
loaddata(data, status);
},
error: function(_, _, e) {
if (window.console)
console.log("ajax error");
alert(e);
}
});
$('#pkgtabs').tabs('disable');
},
load: function() {
busy = false;
}
setup_buttons();
$('#pkgtabs').tabs('enable');
},
spinner: '<img border=0 src=/img/loading.gif> ' +
'<em>Loading...</em>'
});
function setup_buttons()
var $dialog = $('#dialogue').dialog({
title: "Package Management Results",
modal: false, autoOpen: false,
height: 500, width: 700,
show: 'scale', hide: 'fade',
draggable: true, resizable: true,
buttons: { "Close":
function() {$(this).dialog('close');}},
close: function(e,u) {
if (tswitch)
{
var curtab = $('#pkgtabs')
.tabs('option', 'active');
if (curtab != tswitch)
$('#pkgtabs').tabs('option',
'active', tswitch);
else
{
$('.ui-tabs-panel')
.html("<img src=/img/loading.gif>" +
"Loading data... Please wait...");
$('#pkgtabs').tabs('load', tswitch);
}
tswitch = false;
$('button.va').enable();
}
else
{
var pkg = $('#dialogue').attr('pkg');
$('tr[pkg="' + pkg + '"]')
.disable()
.find('button').removeClass('va');
$('button.va').enable();
}
}
});
function loaddata(data, status)
{
$('#dresults').text(data).wrapInner('<pre>');
if (status) // Request completed
{
$('button.remove, button.install, button.upgrade')
.button()
.click(function() {
if ($(this).attr('action') == 'remove' &&
!confirm('Please confirm removal of the ' +
$(this).attr('id') + ' package.'))
return;
execopkg(encodeURIComponent($(this).attr('action') +
' ' + $(this).attr('id')),
$(this).closest('tr').attr('pkg'));
}).fadeIn('slow');
$('a.depends').click(function(e) {
e.preventDefault();
var pkg = $(this).closest('tr').attr('pkg');
stick = true;
execopkg(encodeURIComponent('whatdepends ' + pkg),
false);
});
$('#dspinner').hide('slow');
$('#complete').show('slow');
if (status == 'success' && !stick)
$('#dialogue').dialog('close');
//stick = false;
}
}
function execopkg(arg, pkg)
{
if (busy)
{
alert('Please wait until the current ' +
'operation completes.');
return;
}
busy = true;
$('button.va').disable();
$('#dspinner').show();
$('#complete').hide();
$('#dresults').empty();
$('#dialogue').attr('pkg', pkg);
$dialog.dialog('open');
$.ajax({
type: "GET",
url: opkg,
data: { cmd: arg },
xhrFields: {
onprogress: function(x) {
if (x.target)
loaddata(x.target.responseText);
},
},
progressInterval: 500,
success: function(data, status) {
loaddata(data, status);
},
error: function(_, _, e) {
if (window.console)
console.log("ajax error");
alert(e);
}
});
busy = false;
}
function setup_buttons()
{
$('button.remove, button.install, button.upgrade')
.button()
.click(function() {
if ($(this).attr('action') == 'remove' &&
!confirm('Please confirm removal of the ' +
$(this).attr('id') + ' package.'))
return;
execopkg($(this).attr('action') + ' ' + $(this).attr('id'),
$(this).closest('tr').attr('pkg'));
}).fadeIn('slow');
$('a.depends').click(function(e) {
e.preventDefault();
var pkg = $(this).closest('tr').attr('pkg');
stick = true;
execopkg('whatdepends ' + pkg, false);
});
}
});

View File

@ -7,11 +7,12 @@ proc chunk {chk} {
proc chunk_pad {{len 256}} {
incr len
chunk [string range [format "%${len}d" 0] 1 end-1]
chunk [string repeat " " $len]
}
proc start_chunked {{type "text/html"}} {
httpheader $type 0 "Transfer-Encoding: chunked\r\n"
#chunk_pad
}
proc end_chunked {} {