Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2017-08-17 23:02:54 +0300
committernachoparker <nacho@ownyourbits.com>2017-08-17 23:02:54 +0300
commit3d8063221d382b2ae83d58aaa729465e0c6faad0 (patch)
tree3d4441f56313a8ce2a72b021dd26a6d0febae9ef
parentba953428c752f921471dfacc890ada7c0d2c440f (diff)
ncp-web: poweroff buttonv0.23.0
-rw-r--r--ncp-web/index.php7
-rw-r--r--ncp-web/loading-small.gifbin1771 -> 1772 bytes
-rw-r--r--ncp-web/ncp-launcher.php15
-rw-r--r--ncp-web/ncp.css33
-rw-r--r--ncp-web/ncp.js12
-rw-r--r--ncp-web/poweroff.svg85
-rw-r--r--nextcloudpi.sh2
-rwxr-xr-xupdate.sh3
8 files changed, 153 insertions, 4 deletions
diff --git a/ncp-web/index.php b/ncp-web/index.php
index 85bea26d..65ceff78 100644
--- a/ncp-web/index.php
+++ b/ncp-web/index.php
@@ -64,9 +64,14 @@
<h1 class="hidden-visually">NextCloudPi</h1>
</div>
</a>
+ <?php echo file_get_contents( "/usr/local/etc/ncp-version" ) . "&nbsp;&nbsp;"; ?>
</div>
<div id="header-right">
- <?php echo file_get_contents( "/usr/local/etc/ncp-version" ) . "&nbsp;&nbsp;"; ?>
+ <div id="poweroff">
+ <div id="expand">
+ <div id="expandDisplayName" class="icon-power-white"></div>
+ </div>
+ </div>
</div>
</header>
diff --git a/ncp-web/loading-small.gif b/ncp-web/loading-small.gif
index 83587a63..2d04fd0d 100644
--- a/ncp-web/loading-small.gif
+++ b/ncp-web/loading-small.gif
Binary files differ
diff --git a/ncp-web/ncp-launcher.php b/ncp-web/ncp-launcher.php
index f410640b..032b01ef 100644
--- a/ncp-web/ncp-launcher.php
+++ b/ncp-web/ncp-launcher.php
@@ -12,10 +12,10 @@ include ('csrf.php');
session_start();
-if ( !$_POST['ref'] ) exit( '{ "output": "Invalid request" }' );
-
if ( $_POST['action'] == "cfgreq" )
{
+ if ( !$_POST['ref'] ) exit( '{ "output": "Invalid request" }' );
+
//CSFR check
$token = isset($_POST['csrf_token']) ? $_POST['csrf_token'] : '';
if ( empty($token) || !validateCSRFToken($token) )
@@ -64,6 +64,8 @@ if ( $_POST['action'] == "cfgreq" )
else if ( $_POST['action'] == "launch" && $_POST['config'] )
{
+ if ( !$_POST['ref'] ) exit( '{ "output": "Invalid request" }' );
+
// CSRF check
$token = isset($_POST['csrf_token']) ? $_POST['csrf_token'] : '';
if ( empty($token) || !validateCSRFToken($token) )
@@ -100,6 +102,15 @@ else if ( $_POST['action'] == "launch" && $_POST['config'] )
echo json_encode( shell_exec( 'bash -c "sudo /home/www/ncp-launcher.sh ' . $file . '"' ) ) . ' }';
}
+else if ( $_POST['action'] == "poweroff" )
+{
+ // CSRF check
+ $token = isset($_POST['csrf_token']) ? $_POST['csrf_token'] : '';
+ if ( empty($token) || !validateCSRFToken($token) )
+ exit( '{ "output": "Unauthorized request. Try reloading the page" }' );
+ shell_exec( 'bash -c "( sleep 2 && sudo halt ) 2>/dev/null >/dev/null &"' );
+}
+
// License
//
// This script is free software; you can redistribute it and/or modify it
diff --git a/ncp-web/ncp.css b/ncp-web/ncp.css
index 253a0f71..012721dc 100644
--- a/ncp-web/ncp.css
+++ b/ncp-web/ncp.css
@@ -1084,3 +1084,36 @@ select {
.icon-close {
background-image:url('close.svg')
}
+
+#power {
+ display: inline-block;
+ color: rgba(255, 255, 255, 0.7);
+ cursor: pointer;
+ flex: 0 0 auto;
+}
+
+#expand {
+ position: relative;
+ display: flex;
+ align-items: center;
+ padding: 7px 20px 6px 10px;
+ cursor: pointer;
+}
+
+#expand * {
+ cursor: pointer;
+}
+
+#expand:hover img,#expand:focus img,#expand:active img,#expand:hover #expandDisplayName,#expand:focus #expandDisplayName,#expand:active #expandDisplayName {
+ -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)';
+ opacity:1
+}
+
+.icon-power-white {
+ background-image: url('poweroff.svg');
+}
+
+#expand #expandDisplayName {
+ padding: 8px;
+ opacity: 0.6;
+}
diff --git a/ncp-web/ncp.js b/ncp-web/ncp.js
index 5d92bed0..b200c8b0 100644
--- a/ncp-web/ncp.js
+++ b/ncp-web/ncp.js
@@ -81,6 +81,18 @@ $(function()
confLock = false;
}).error( errorMsg );
});
+
+ // Power-off button
+ $( '#poweroff' ).on('click', function(e)
+ {
+ // request
+ $.request('post', 'ncp-launcher.php', { action:'poweroff',
+ csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
+ function success( result )
+ {
+ $('#config-box-title').fill( "Shutting down..." );
+ }).error( errorMsg );
+ } );
});
// License
diff --git a/ncp-web/poweroff.svg b/ncp-web/poweroff.svg
new file mode 100644
index 00000000..6b25d0b9
--- /dev/null
+++ b/ncp-web/poweroff.svg
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="Capa_1"
+ x="0px"
+ y="0px"
+ viewBox="0 0 12.962964 13.196974"
+ xml:space="preserve"
+ sodipodi:docname="on-off-power-button.svg"
+ width="12.962964"
+ height="13.196974"
+ inkscape:version="0.92.1 r"><metadata
+ id="metadata43"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs41" /><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1475"
+ inkscape:window-height="943"
+ id="namedview39"
+ showgrid="false"
+ inkscape:zoom="15.204"
+ inkscape:cx="8.064219"
+ inkscape:cy="2.2776612"
+ inkscape:window-x="2112"
+ inkscape:window-y="99"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="Capa_1" /><g
+ id="g6"
+ transform="matrix(0.03566737,0,0,0.03566737,0.21779251,0.33479739)"
+ style="fill:#ffffff"><path
+ d="m 258.915,27.652 c -1.161,-0.642 -2.53,-0.794 -3.803,-0.428 -1.275,0.367 -2.35,1.226 -2.992,2.387 l -21.758,39.39 c -1.335,2.417 -0.458,5.459 1.96,6.794 37.498,20.713 60.793,60.155 60.793,102.933 0,64.79 -52.71,117.5 -117.5,117.5 -64.79,0 -117.5,-52.71 -117.5,-117.5 0,-42.778 23.294,-82.22 60.792,-102.933 2.418,-1.335 3.294,-4.377 1.96,-6.794 L 99.109,29.611 c -0.642,-1.161 -1.717,-2.02 -2.992,-2.387 -1.272,-0.368 -2.642,-0.214 -3.803,0.428 -55.02,30.391 -89.2,88.28 -89.2,151.076 0,95.117 77.383,172.5 172.5,172.5 95.117,0 172.5,-77.383 172.5,-172.5 0,-62.795 -34.179,-120.685 -89.199,-151.076 z"
+ id="path2"
+ inkscape:connector-curvature="0"
+ style="fill:#ffffff" /><path
+ d="m 153.114,181.16 h 45 c 2.761,0 5,-2.239 5,-5 V 5 c 0,-2.761 -2.239,-5 -5,-5 h -45 c -2.761,0 -5,2.239 -5,5 v 171.16 c 0,2.761 2.239,5 5,5 z"
+ id="path4"
+ inkscape:connector-curvature="0"
+ style="fill:#ffffff" /></g><g
+ id="g8"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g10"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g12"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g14"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g16"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g18"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g20"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g22"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g24"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g26"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g28"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g30"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g32"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g34"
+ transform="translate(-334.95721,-338.03103)" /><g
+ id="g36"
+ transform="translate(-334.95721,-338.03103)" /></svg> \ No newline at end of file
diff --git a/nextcloudpi.sh b/nextcloudpi.sh
index b509878d..ef066106 100644
--- a/nextcloudpi.sh
+++ b/nextcloudpi.sh
@@ -63,7 +63,7 @@ cd $DIR
launch_script $1
EOF
chmod 700 /home/www/ncp-launcher.sh
- echo "www-data ALL = NOPASSWD: /home/www/ncp-launcher.sh" >> /etc/sudoers
+ echo "www-data ALL = NOPASSWD: /home/www/ncp-launcher.sh , /sbin/halt" >> /etc/sudoers
# NEXTCLOUDPI MOTD
##########################################
diff --git a/update.sh b/update.sh
index c05e22e5..7f23a0f4 100755
--- a/update.sh
+++ b/update.sh
@@ -114,6 +114,9 @@ cat $LATEST > $NOTIFIED
EOF
chmod +x /usr/local/bin/ncp-notify-update
+# fix permissions for ncp-web: shutdown button
+sed -i 's|www-data.*|www-data ALL = NOPASSWD: /home/www/ncp-launcher.sh , /sbin/halt|' /etc/sudoers
+
# License
#
# This script is free software; you can redistribute it and/or modify it