tinycm rev 81

Improve dashboard plugin (more to come)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 11 14:33:17 2017 +0100 (2017-02-11)
parents 2778498112c0
children 4418f0315c8e
files plugins/dashboard/dashboard.cgi
line diff
     1.1 --- a/plugins/dashboard/dashboard.cgi	Sat Feb 11 10:18:48 2017 +0000
     1.2 +++ b/plugins/dashboard/dashboard.cgi	Sat Feb 11 14:33:17 2017 +0100
     1.3 @@ -2,7 +2,6 @@
     1.4  #
     1.5  # TinyCM Plugin - Users and admin Dashboard.
     1.6  #
     1.7 -. /usr/lib/slitaz/httphelper
     1.8  
     1.9  if [ "$(GET dashboard)" ]; then
    1.10  	d="Dashboard"
    1.11 @@ -37,37 +36,47 @@
    1.12  <h2>$d</h2>
    1.13  
    1.14  <pre>
    1.15 -Users     : $users
    1.16 -Wiki      : $docs ($wikisize)
    1.17 -Cache     : $cachesize
    1.18 -Mercurial : $hg
    1.19 +Wiki docs        : $docs ($wikisize)
    1.20 +Cache size       : $cachesize
    1.21 +Mercurial        : $hg
    1.22 +User accounts    : $users
    1.23 +Server uptime    : $(uptime | cut -d " " -f 4 | sed s"/:/h /" | sed s"/,/min/")
    1.24  </pre>
    1.25  
    1.26  <h3>Admin users</h3>
    1.27  EOT
    1.28  		# Get the list of administrators
    1.29 -		for u in $(ls $PEOPLE)
    1.30 +		fgrep -l "ADMIN_USER=" $PEOPLE/*/account.conf | while read file;
    1.31  		do
    1.32 -			user=${u}
    1.33 -			if admin_user; then
    1.34 -				echo "<a href='?user=$u'>$u</a>"
    1.35 -			fi
    1.36 +			. ${file}
    1.37 +			echo "<a href='?user=$USER'>$USER</a>"
    1.38 +			unset NAME USER
    1.39  		done
    1.40 -		echo '</p>'
    1.41  		
    1.42  		# Only for admins
    1.43  		if check_auth && admin_user; then
    1.44  			# List all plugins
    1.45  			cat << EOT
    1.46  <h3>$(gettext "Plugins")</h3>
    1.47 -<pre>
    1.48 +<table>
    1.49 +	<thead>
    1.50 +		<td>$(gettext "Name")</td>
    1.51 +		<td>$(gettext "Description")</td>
    1.52 +		<td>$(gettext "Action")</td>
    1.53 +	</thead>
    1.54  EOT
    1.55  			for p in $(ls -1 $plugins)
    1.56  			do
    1.57  				. $plugins/$p/$p.conf
    1.58 -				echo "<a href='?$p'>$PLUGIN</a> - $SHORT_DESC"
    1.59 +				cat << EOT
    1.60 +	<tr>
    1.61 +		<td><a href='?$p'>$PLUGIN</a></td>
    1.62 +		<td>$SHORT_DESC</td>
    1.63 +		<td>remove</td>
    1.64 +	</tr>
    1.65 +EOT
    1.66  			done
    1.67 -			echo '</pre>'
    1.68 +			echo "</table>"
    1.69  		fi
    1.70  	else
    1.71  			gettext "You must be logged in to view the dashboard."