#!/mod/bin/jimsh

package require cgi
package require sqlite3
source /mod/webif/lib/setup
require system.class ts.class pretty_size

header

set dmsfile [system dlnadb]

set vars {
	object.container 0
	object.item.videoItem.movie 0
	object.item.imageItem.photo 0
	object.item.audioItem.musicTrack 0
}

if {[file exists $dmsfile] && ![catch {set db [sqlite3.open $dmsfile]}]} {
	catch {
		foreach ret [$db query "
			select class, count(*) from tblObject group by 1
		"] {
			lassign $ret x class x num
			set vars($class) $num
		}
	}
	$db close
}

if {[system param DMS_START_ON]} {
	set cfgstat "Enabled"
} else {
	set cfgstat "Disabled"
}

if {[system is_listening 9000]} {
	set stat "Running."
	set img "745_1_10_Video_2Live.png"
} else {
	set stat "Not running."
	set img "745_1_11_Video_1REC.png"
}

jscss script.js
puts "
<fieldset class=cleft>
<legend class=va>
<img class=va src=/img/dlna_large.png height=50>
&nbsp;
DLNA Server Information
</legend>

<table class=keyval cellpadding=5>
<tr>
	<th>Server Status</th>
	<td class=va>$cfgstat - <img class=va src=/images/$img> $stat</td>
</tr><tr>
	<th>Folders Indexed</th>
	<td>$vars(object.container)</td>
</tr><tr>
	<th>Movies Indexed</th>
	<td>$vars(object.item.videoItem.movie)</td>
</tr><tr>
	<th>Photos Indexed</th>
	<td>$vars(object.item.imageItem.photo)</td>
</tr><tr>
	<th>Music Tracks Indexed</th>
	<td>$vars(object.item.audioItem.musicTrack)</td>
</tr><tr>

</table>
</fieldset>
<div class=cleft style=\"padding-top: 0.5em\">
<button id=dlnareset>Reset DLNA Database</button>
</div>
<div id=results class=\"cleft hidden blood\"
    style=\"border: solid 1px #ccc; margin: 1em; padding: 1em;\">
</div>
"

footer

