Skip to content

Commit fa1ec75

Browse files
committed
ncp-web: implement dashboard
1 parent b94bcb4 commit fa1ec75

File tree

10 files changed

+282
-82
lines changed

10 files changed

+282
-82
lines changed

bin/ncp-diag

100755100644
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ echo "datadir|$DATADIR$DIRINFO"
3232
echo "data disk usage|$( df -h "$DATADIR" | tail -1 | awk '{ print $3"/"$2 }')"
3333
}
3434
echo "rootfs usage|$( df -h / | tail -1 | awk '{ print $3"/"$2 }')"
35-
echo "swapfile|$( swapon | tail -1 | awk '{ print $1 }' )"
35+
SWP="$( swapon | tail -1 | awk '{ print $1 }' )"
36+
[[ "$SWP" == "" ]] && SWP="none"
37+
echo "swapfile|$SWP"
3638

3739
# Nextcloud
38-
VERSION="$( sudo -u www-data php /var/www/nextcloud/occ status | grep "version:" | awk '{ print $3 }' )"
40+
VERSION="$( php /var/www/nextcloud/occ status | grep "version:" | awk '{ print $3 }' )"
3941
if [[ "$VERSION" != "" ]]; then
4042
echo "Nextcloud check|ok"
4143
echo "Nextcloud version|$VERSION"
@@ -75,13 +77,10 @@ echo "gateway|$GW"
7577
echo "interface|$IFACE"
7678

7779
# Certificates
78-
LEOUT="$( /etc/letsencrypt/letsencrypt-auto certificates 2>/dev/null )"
79-
CERTS="$( echo -e "$LEOUT" | grep "Domains:" | awk '{ print $2 }' | tr '\n' ' ' )"
80-
CDUE="$( echo -e "$LEOUT" | grep "VALID:" | grep -oP "\d+ days" | tr '\n' ' ' )"
80+
CERTS="$( grep "SSLCertificateFile /etc/letsencrypt/live/" /etc/apache2/sites-available/nextcloud.conf \
81+
| sed 's|.*SSLCertificateFile /etc/letsencrypt/live/||;s|/fullchain.pem||' )"
8182
[[ "$CERTS" == "" ]] && CERTS=none
82-
[[ "$CDUE" == "" ]] && CDUE=none
8383
echo "certificates|$CERTS"
84-
echo "certs due|$CDUE"
8584

8685
RESOLV="$( ping -c 1 "$CERTS" 2>/dev/null | head -1 | grep -oP '\d{1,3}(.\d{1,3}){3}' )"
8786
echo "NAT loopback|$( [[ "$RESOLV" == "$IP" ]] && echo yes || echo no )"

bin/ncp-report

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ echo "<--! Paste this in GitHub report -->"
3939
##
4040

4141
open_summary "NextCloudPi diagnostics"
42-
ncp-diag | column -t -s'|'
42+
bash /usr/local/bin/ncp-diag | column -t -s'|'
4343
close_summary
4444

4545
##

bin/ncp-suggestions

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
#
4+
# NextCloudPi configuration suggestions
5+
#
6+
# Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
7+
# GPL licensed (see end of file) * Use at your own risk!
8+
#
9+
# Usage:
10+
# sudo ncp-suggestions "$( ncp-diag )"
11+
#
12+
# More at https://ownyourbits.com
13+
#
14+
15+
OUT="$@"
16+
17+
DNSMASQ_ON="$( grep "^ACTIVE_=" /usr/local/etc/nextcloudpi-config.d/dnsmasq.sh | cut -d'=' -f2 )"
18+
19+
grep -q "distribution|.*bian GNU/Linux 9" <<<"$OUT" || \
20+
echo -e "You are using an unsupported distro release. Please upgrade to latest Debian/Raspbian"
21+
22+
[[ $DNSMASQ_ON != "yes" ]] && \
23+
grep -q "NAT loopback|no" <<<"$OUT" && \
24+
echo -e "\nYou should enable dnsmasq to use your domain inside home"
25+
26+
grep -q "certificates|none" <<<"$OUT" && \
27+
echo -e "\nYou should run Lets Encrypt for trusted encrypted access"
28+
29+
grep -q "port check .*|closed" <<<"$OUT" && \
30+
echo -e "\nYou should open your ports for Lets Encrypt and external access"
31+
32+
grep -q "USB devices|none" <<<"$OUT" || {
33+
grep -q "data in SD|yes" <<<"$OUT" && \
34+
echo -e "\nYou should use nc-datadir to move your files to your plugged in USB drive"
35+
36+
grep -q "automount|no" <<<"$OUT" && \
37+
echo -e "\nYou should enable automount to use your plugged in USB drive"
38+
}

changelog.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11

2-
[v0.53.8](https://github.com/nextcloud/nextcloudpi/commit/cc733af) (2018-04-02) ncp-web: fix update notification
2+
[v0.53.10](https://github.com/nextcloud/nextcloudpi/commit/dce58cc) (2018-04-03) ncp-web: implement dashboard
33

4-
[v0.53.7](https://github.com/nextcloud/nextcloudpi/commit/d4ca26a) (2018-03-29) ncp-web: use random passwords for NC and ncp-web
4+
[v0.53.9](https://github.com/nextcloud/nextcloudpi/commit/486d6ef) (2018-04-02) SSH: stop service upon activation
5+
6+
[v0.53.8 ](https://github.com/nextcloud/nextcloudpi/commit/afd2c8e) (2018-04-02) ncp-web: fix update notification
7+
8+
[v0.53.7 ](https://github.com/nextcloud/nextcloudpi/commit/d4ca26a) (2018-03-29) ncp-web: use random passwords for NC and ncp-web
59

610
[v0.53.6 ](https://github.com/nextcloud/nextcloudpi/commit/151160b) (2018-03-27) samba: dont force NAME_REGEX for username
711

etc/nextcloudpi-config.d/nc-info.sh

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Usage:
99
#
10-
# ./installer.sh nc-diag.sh <IP> (<img>)
10+
# ./installer.sh nc-info.sh <IP> (<img>)
1111
#
1212
# See installer.sh instructions for details
1313
# More at: https://ownyourbits.com
@@ -17,36 +17,16 @@ DESCRIPTION="Print NextCloudPi system info"
1717

1818
configure()
1919
{
20-
# info
21-
22-
local OUT="$( ncp-diag )"
2320
echo "Gathering information..."
21+
local OUT="$( bash /usr/local/bin/ncp-diag )"
22+
23+
# info
2424
echo "$OUT" | column -t -s'|'
2525

2626
# suggestions
27-
28-
DNSMASQ_ON="$( grep "^ACTIVE_=" /usr/local/etc/nextcloudpi-config.d/dnsmasq.sh | cut -d'=' -f2 )"
29-
30-
grep -q "distribution|.*bian GNU/Linux 9" <<<"$OUT" || \
31-
echo -e "\nYou are using an unsupported distro release. Please upgrade to latest Debian/Raspbian"
32-
33-
[[ $DNSMASQ_ON != "yes" ]] && \
34-
grep -q "NAT loopback|no" <<<"$OUT" && \
35-
echo -e "\nYou should enable dnsmasq to use your domain inside home"
36-
37-
grep -q "certificates|none" <<<"$OUT" && \
38-
echo -e "\nYou should run Lets Encrypt for trusted encrypted access"
39-
40-
grep -q "port check .*|closed" <<<"$OUT" && \
41-
echo -e "\nYou should open your ports for Lets Encrypt and external access"
42-
43-
grep -q "USB devices|none" <<<"$OUT" || {
44-
grep -q "data in SD|yes" <<<"$OUT" && \
45-
echo -e "\nYou should use nc-datadir to move your files to your plugged in USB drive"
46-
47-
grep -q "automount|no" <<<"$OUT" && \
48-
echo -e "\nYou should enable automount to uyyse your plugged in USB drive"
49-
}
27+
echo
28+
bash /usr/local/bin/ncp-suggestions "$OUT"
29+
5030
return 0
5131
}
5232

@@ -68,4 +48,3 @@ install() { :; }
6848
# along with this script; if not, write to the
6949
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
7050
# Boston, MA 02111-1307 USA
71-

ncp-web/img/dashboard.svg

Lines changed: 65 additions & 0 deletions
Loading

ncp-web/index.php

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
</a>
112112
</div>
113113
<div id="header-right">
114+
<div id="dashboard-btn">
115+
<div id="expand">
116+
<div class="icon-dashboard"></div>
117+
</div>
118+
</div>
114119
<?php
115120
if ( file_exists( 'wizard' ) )
116121
echo <<<HTML
@@ -139,7 +144,7 @@
139144
<?php
140145

141146
// fill options with contents from directory
142-
$files = array_diff(scandir($modules_path), array('.', '..', 'nc-wifi.sh', 'l10n'));
147+
$files = array_diff(scandir($modules_path), array('.', '..', 'nc-wifi.sh', 'nc-info.sh', 'l10n'));
143148

144149
foreach ($files as $file) {
145150
$script = pathinfo($file, PATHINFO_FILENAME);
@@ -169,24 +174,33 @@
169174

170175
<div id="app-content">
171176
<div id="app-navigation-toggle" class="icon-menu hidden"></div>
172-
<h2 id="config-box-title"><?php echo $l->__("Configure NextCloudPi features"); ?></h2>
173-
<a href="#" target="_blank">
174-
<div id="config-extra-info" class="icon-info"></div>
175-
</a>
176-
<div id="config-box-info"></div>
177-
<br/>
178-
<div id="config-box-wrapper" class="hidden">
179-
<form>
180-
<div id="config-box"></div>
181-
<div id="config-button-wrapper">
182-
<button id="config-button"><?php echo $l->__("Run"); ?></button>
183-
<img id="loading-gif" src="img/loading-small.gif">
184-
<div id="circle-retstatus" class="icon-red-circle"></div>
185-
</div>
186-
</form>
187-
<textarea readonly id="details-box" rows="12"></textarea>
177+
178+
<div id="config-wrapper" class="hidden">
179+
<h2 id="config-box-title" class="text-title"><?php echo $l->__("System Info"); ?></h2>
180+
<div id="config-box-info-txt"></div>
181+
<a href="#" target="_blank">
182+
<div id="config-extra-info" class="icon-info"></div>
183+
</a>
184+
<br/>
185+
<div id="config-box-wrapper" class="table-wrapper">
186+
<form>
187+
<div id="config-box"></div>
188+
<div id="config-button-wrapper">
189+
<button id="config-button"><?php echo $l->__("Run"); ?></button>
190+
<img id="loading-gif" src="img/loading-small.gif">
191+
<div id="circle-retstatus" class="icon-red-circle"></div>
192+
</div>
193+
</form>
194+
<textarea readonly id="details-box" class="outputbox" rows="12"></textarea>
195+
</div>
188196
</div>
189197

198+
<div id="dashboard-wrapper">
199+
<h2 class="text-title"><?php echo $l->__("System Info"); ?></h2>
200+
<div id="dashboard-suggestions" class="table-wrapper"></div>
201+
<div id="dashboard-table" class="outputbox table-wrapper"></div>
202+
</div>
203+
<div id="loading-info-gif"> <img src="img/loading-small.gif"> </div>
190204
</div>
191205

192206
<div id="poweroff-dialog" class='dialog primary hidden'>
@@ -200,7 +214,8 @@
200214

201215
<?php
202216
include('csrf.php');
203-
echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>';
217+
echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>';
218+
echo '<input type="hidden" id="csrf-token-dash" name="csrf-token-dash" value="' . getCSRFToken() . '"/>';
204219
?>
205220
<script src="minified.js"></script>
206221
<script src="ncp.js"></script>

0 commit comments

Comments
 (0)