From 85fed3247a021c4122585273e918c726eed146bd Mon Sep 17 00:00:00 2001 From: hummypkg Date: Tue, 30 Dec 2014 19:00:15 +0000 Subject: [PATCH] show usb disk space. Clickable log viewer git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@2093 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- webif/cgi-bin/usbeject.jim | 2 +- webif/html/js/usbeject.js | 16 ++++++++++++++-- webif/html/lib/header.jim | 1 + webif/html/log/script.js | 23 +++++++++++++++++++++++ webif/include/usbeject.jim | 3 +++ webif/lib/system.class | 3 ++- webif/lib/tdelete | 2 +- 8 files changed, 46 insertions(+), 6 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index 0ede8c3..165d456 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 1.0.18-5 +Version: 1.0.18-6 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(>=2.1),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),e2fsprogs,mongoose diff --git a/webif/cgi-bin/usbeject.jim b/webif/cgi-bin/usbeject.jim index 1c17326..be735d5 100755 --- a/webif/cgi-bin/usbeject.jim +++ b/webif/cgi-bin/usbeject.jim @@ -20,7 +20,7 @@ foreach usb [system usbmounts 1] { } else { puts "\"status\": 1," puts "\"result\": \"Successfully ejected $label\"" - file delete -force $usb(MP) + catch {file delete -force $usb(MP)} } puts "}" exit diff --git a/webif/html/js/usbeject.js b/webif/html/js/usbeject.js index 37a83d5..6a85831 100644 --- a/webif/html/js/usbeject.js +++ b/webif/html/js/usbeject.js @@ -30,8 +30,8 @@ $('#usbeject').on('click', function(e) { var num = 0; $.each(data, function(k,v) { num++; - var size = (v.SIZE / 1000000000); - if (size > 1000) + var size = v.SIZE / 1000000000; + if (size >= 1000) size = (size / 1000).toFixed(1) + "TB"; else size = size.toFixed(1) + "GB"; @@ -53,11 +53,23 @@ $('#usbeject').on('click', function(e) { '(' + drive + ' - ' + type + ' ' + ' - ' + size + ')' + + '' + + '' + v.USED + + '%' + '' + '' + ''); + $('#usbejecttab .pie').easyPieChart({ + size: 20, + barColor: '#00ff00', + trackColor: '#A3A3C2', + lineWidth: 4, + scaleColor: false, + lineCap: 'butt' + }); }); $('#usbejectout').empty(); if (!num) diff --git a/webif/html/lib/header.jim b/webif/html/lib/header.jim index 9003d26..c36123e 100755 --- a/webif/html/lib/header.jim +++ b/webif/html/lib/header.jim @@ -36,6 +36,7 @@ if {[info exists _mws_js]} { foreach css $::_mws_css { puts "" } + incr ::_mws_headerdone } puts { diff --git a/webif/html/log/script.js b/webif/html/log/script.js index 2dc2dbf..ef6a104 100644 --- a/webif/html/log/script.js +++ b/webif/html/log/script.js @@ -145,5 +145,28 @@ $('#log').on('change', function() { loadlog($('#log').val()) }).trigger('change'); +function expand(el, dir, num) +{ + el.show('fast').find('td').css('color', '#ff4000 !important'); + if (!num) return; + switch (dir) + { + case 'up': + expand(el.prev(), dir, num - 1); + break; + case 'down': + expand(el.next(), dir, num - 1); + break; + } +} + +$('#logtab').on('click', 'tbody > tr', function() { + $(this) + .removeClass('odd even') + .addClass('highlight'); + expand($(this), 'up', 10); + expand($(this), 'down', 10); +}); + }); diff --git a/webif/include/usbeject.jim b/webif/include/usbeject.jim index 7cd2d3b..699c091 100755 --- a/webif/include/usbeject.jim +++ b/webif/include/usbeject.jim @@ -1,5 +1,8 @@ #!/mod/bin/jimsh +source /mod/webif/lib/setup +jqplugin easy-pie-chart + puts {
diff --git a/webif/lib/system.class b/webif/lib/system.class index 1a58830..477dd6a 100644 --- a/webif/lib/system.class +++ b/webif/lib/system.class @@ -423,8 +423,9 @@ proc {system usbmounts} {{full 0}} { } } - lassign [exec stat -f -c {%b %S} $mp] blockc blocks + lassign [exec stat -f -c {%S %b %f} $mp] blocks blockc blockf set rec(SIZE) $($blockc * $blocks) + set rec(USED) $(100 - $blockf * 100 / $blockc) # /dev/sda1: LABEL="SAN" UUID="DBC1-1CF8" TYPE="vfat" catch { diff --git a/webif/lib/tdelete b/webif/lib/tdelete index e2fa979..71931b5 100644 --- a/webif/lib/tdelete +++ b/webif/lib/tdelete @@ -1,7 +1,7 @@ # Deprecated - just use {file tdelete} -if {![exists -alias tdelete]} { +if {![exists -alias tdelete]} { alias tdelete {file tdelete} }