Skip to content

Commit

Permalink
ncp-web: added nc-config and helper buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Apr 3, 2018
1 parent d133c73 commit 30da787
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bin/ncp-diag
Expand Up @@ -50,7 +50,7 @@ echo "HTTPD service|$( pgrep -c apache2 &>/dev/null && echo up || echo down )"
echo "PHP service|$( pgrep -c php-fpm &>/dev/null && echo up || echo down )"
echo "MariaDB service|$( pgrep -c mysqld &>/dev/null && echo up || echo down )"
echo "Redis service|$( pgrep -c redis-server &>/dev/null && echo up || echo down )"
echo "Postfix service|$( postfix status &>/dev/null && echo up || echo down )"
echo "Postfix service|$( pgrep -fc postfix &>/dev/null && echo up || echo down )"

# WAN
echo "internet check|$( ping -W 2 -w 1 -q github.com &>/dev/null && echo ok || echo no } )"
Expand Down
8 changes: 6 additions & 2 deletions changelog.md
@@ -1,7 +1,11 @@

[v0.53.10](https://github.com/nextcloud/nextcloudpi/commit/dce58cc) (2018-04-03) ncp-web: implement dashboard
[v0.53.12](https://github.com/nextcloud/nextcloudpi/commit/4e597b9) (2018-04-03) ncp-web: added nc-config and helper buttons

[v0.53.9](https://github.com/nextcloud/nextcloudpi/commit/486d6ef) (2018-04-02) SSH: stop service upon activation
[v0.53.11](https://github.com/nextcloud/nextcloudpi/commit/42adfb3) (2018-04-03) ncp-web: fix glitch showing power dialog

[v0.53.10](https://github.com/nextcloud/nextcloudpi/commit/96a8c73) (2018-04-03) ncp-web: implement dashboard

[v0.53.9 ](https://github.com/nextcloud/nextcloudpi/commit/486d6ef) (2018-04-02) SSH: stop service upon activation

[v0.53.8 ](https://github.com/nextcloud/nextcloudpi/commit/afd2c8e) (2018-04-02) ncp-web: fix update notification

Expand Down
59 changes: 59 additions & 0 deletions ncp-web/img/info-white.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions ncp-web/img/nc-button.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ncp-web/img/settings-white.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 41 additions & 12 deletions ncp-web/index.php
Expand Up @@ -100,8 +100,7 @@

<header role="banner"><div id="header">
<div id="header-left">
<a href="https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/"
id="nextcloudpi" tabindex="1">
<a href="https://ownyourbits.com" id="nextcloudpi" target="_blank" tabindex="1">
<div class="logo-icon">
<h1 class="hidden-visually">NextCloudPi</h1>
</div>
Expand All @@ -111,11 +110,18 @@
</a>
</div>
<div id="header-right">
<div id="dashboard-btn">
<div id="expand">
<div class="icon-dashboard"></div>
<a href="https://ownyourbits.com" id="nextcloud-btn" target="_blank" tabindex="1">
<div id="nc-button">
<div id="expand">
<div class="icon-nc-white"></div>
</div>
</div>
</div>
</a>
<div id="dashboard-btn">
<div id="expand">
<div class="icon-dashboard"></div>
</div>
</div>
<?php
if ( file_exists( 'wizard' ) )
echo <<<HTML
Expand All @@ -127,13 +133,25 @@
</div>
</a>
HTML;
?>
<div id="poweroff">
<div id="expand">
<div class="icon-power-white"></div>
</div>
?>
<div id="config-btn">
<div id="expand">
<div class="icon-config"></div>
</div>
</div>
<a href="https://github.com/nextcloud/nextcloudpi/wiki" target="_blank" tabindex="1">
<div id="nc-button">
<div id="expand">
<div class="icon-nc-info"></div>
</div>
</div>
</a>
<div id="poweroff">
<div id="expand">
<div class="icon-power-white"></div>
</div>
</div>
</div>
</header>

<div id="content-wrapper">
Expand Down Expand Up @@ -199,8 +217,19 @@
<h2 class="text-title"><?php echo $l->__("System Info"); ?></h2>
<div id="dashboard-suggestions" class="table-wrapper"></div>
<div id="dashboard-table" class="outputbox table-wrapper"></div>
<div id="loading-info-gif"> <img src="img/loading-small.gif"> </div>
</div>

<div id="nc-config-wrapper" class="hidden">
<h2 class="text-title"><?php echo $l->__("Nextcloud configuration"); ?></h2>
<div id="nc-config-box" class="table-wrapper">
<?php
$config = file_get_contents( '/var/www/nextcloud/config/config.php' );
$config = str_replace( "\n", "<br>", $config );
echo "$config";
?>
</div>
</div>
<div id="loading-info-gif"> <img src="img/loading-small.gif"> </div>
</div>

<div id="poweroff-dialog" class='dialog primary hidden'>
Expand Down
3 changes: 1 addition & 2 deletions ncp-web/ncp-launcher.php
Expand Up @@ -190,10 +190,9 @@

// return JSON
echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
echo ' "ref": " ' . $_POST['ref'] . '",';
echo ' "table": ' . json_encode( $table ) . ' , ';
echo ' "suggestions": ' . json_encode( $suggestions ) . ' , ';
echo ' "ret": "' . $ret . '" }';
echo ' "ret": "' . $ret . '" }';
}
}

Expand Down
14 changes: 13 additions & 1 deletion ncp-web/ncp.css
Expand Up @@ -1118,7 +1118,15 @@ select {
.icon-power-white {
background-image: url('img/poweroff.svg');
}

.icon-nc-white {
background-image: url('img/nc-button.svg');
}
.icon-nc-info {
background-image: url('img/info-white.svg');
}
.icon-config {
background-image: url('img/settings-white.svg');
}
.icon-reboot-white {
background-image: url('img/reboot.svg');
}
Expand Down Expand Up @@ -1283,6 +1291,10 @@ a#versionlink:hover {
margin-bottom: 1em;
}

#nc-config-box {
color: gray;
}

.hidden {
display:none
}
Expand Down
30 changes: 20 additions & 10 deletions ncp-web/ncp.js
Expand Up @@ -17,19 +17,28 @@ function errorMsg()
$('#config-box').fill( "Something went wrong. Try refreshing the page" );
}

function switch_to_section( name )
{
$( '#config-wrapper' ).hide();
$( '#dashboard-wrapper' ).hide();
$( '#nc-config-wrapper' ).hide();
$( '#' + name + '-wrapper' ).show();
$( '#' + selectedID ).set('-active');
selectedID = null;
}

function cfgreqReceive( result )
{
var ret = $.parseJSON( result );
if ( ret.token )
$('#csrf-token').set( { value: ret.token } );

$('#details-box' ).hide();
$('#dashboard-wrapper').hide();
$('#circle-retstatus').hide();
$('#config-box').ht( ret.output );
$('#config-box-title' ).fill( $( '#' + selectedID + '-desc' ).get( '.value' ) );
$('#config-box-info-txt' ).fill( $( '#' + selectedID + '-info' ).get( '.value' ) );
$('#config-wrapper').show();
switch_to_section( 'config' );
$('#config-box-wrapper').show();
$('#config-extra-info').set( { $display: 'inline-block' } );
$('#config-extra-info').up().set( '@href', 'https://github.com/nextcloud/nextcloudpi/wiki/Configuration-Reference#' + selectedID );
Expand Down Expand Up @@ -78,11 +87,9 @@ $(function()
csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
function success( result )
{
cfgreqReceive( result );
selectedID = that.get('.id');
that.set( '+active' );

cfgreqReceive( result );

confLock = false;
}).error( errorMsg );
});
Expand Down Expand Up @@ -300,7 +307,7 @@ $(function()
} );

// click to nextcloud button
$('#nextcloudpi').set( '@href', window.location.protocol + '//' + window.location.hostname );
$('#nextcloud-btn').set( '@href', window.location.protocol + '//' + window.location.hostname );

// load dashboard info
$.request('post', 'ncp-launcher.php', { action: 'info',
Expand All @@ -319,10 +326,13 @@ $(function()
// dashboard button
$( '#dashboard-btn' ).on('click', function(e)
{
$( '#config-wrapper' ).hide();
$( '#dashboard-wrapper' ).show();
$( '#' + selectedID ).set('-active');
selectedID = null;
switch_to_section( 'dashboard' );
} );

// config button
$( '#config-btn' ).on('click', function(e)
{
switch_to_section( 'nc-config' );
} );
} );

Expand Down

0 comments on commit 30da787

Please sign in to comment.