tazbug view web/plugins/dashboard/dashboard.cgi @ rev 118

Up plugins/users and small improvments to dashboard
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 11 22:27:47 2017 +0100 (2017-02-11)
parents 8bda6c6b79a6
children 039c90c60494
line source
1 #!/bin/sh
2 #
3 # TazBug Plugin - Dashboard
4 #
6 if [ "$(GET dashboard)" ]; then
7 d="Dashboard"
8 header
9 html_header
10 user_box
11 if ! check_auth; then
12 gettext "You must be logged in to view the dashboard"
13 exit 0
14 fi
15 bugs=$(ls -1 $bugdir | wc -l)
16 bugsize=$(du -sh $bugdir | awk '{print $1}')
17 # Source all plugins.conf to get DASHBOARD_TOOLS and ADMIN_TOOLS
18 ADMIN_TOOLS=""
19 DASHBOARD_TOOLS=""
20 for p in $(ls $plugins)
21 do
22 . $plugins/$p/$p.conf
23 done
24 if check_auth && ! admin_user; then
25 ADMIN_TOOLS=""
26 fi
27 if check_auth; then
28 cat << EOT
29 <h2>Dashboard</h2>
31 <div id="tools">
32 $DASHBOARD_TOOLS $ADMIN_TOOLS
33 </div>
35 <pre>
36 Bugs count : $bugs
37 Database size : $bugsize
38 Server uptime :$(uptime | cut -d "," -f 1-2)
39 </pre>
41 <h3>Admin users</h3>
42 EOT
44 # Get the list of administrators
45 fgrep -l "ADMIN_USER=" $PEOPLE/*/account.conf | while read file;
46 do
47 . ${file}
48 echo "<a href='?user=$USER'>$USER</a>"
49 unset NAME USER
50 done
52 # Only for admins
53 if check_auth && admin_user; then
54 # List all plugins
55 cat << EOT
56 <h3>$(gettext "Plugins")</h3>
57 <pre>
58 <table>
59 <thead>
60 <td>$(gettext "Name")</td>
61 <td>$(gettext "Description")</td>
62 <td>$(gettext "Action")</td>
63 </thead>
64 EOT
65 for p in $(ls -1 $plugins)
66 do
67 . $plugins/$p/$p.conf
68 cat << EOT
69 <tr>
70 <td><a href='?$p'>$PLUGIN</a></td>
71 <td>$SHORT_DESC</td>
72 <td>TODO</td>
73 </tr>
74 EOT
75 done
76 echo " </table>"
77 echo "</pre>"
78 fi
79 else
80 gettext "You must be logged in to view the dashboard"
81 fi
82 html_footer && exit 0
83 fi