diff options
-rw-r--r-- | ncp-web/index.php | 20 | ||||
-rw-r--r-- | ncp-web/ncp.css | 16 | ||||
-rw-r--r-- | ncp-web/ncp.js | 53 |
3 files changed, 70 insertions, 19 deletions
diff --git a/ncp-web/index.php b/ncp-web/index.php index 988f64e1..5b43c034 100644 --- a/ncp-web/index.php +++ b/ncp-web/index.php @@ -47,8 +47,8 @@ if ( $ret == 0 ) { echo '<div id="notification">'; - echo '<div class="row type-error closeable">'; - echo "<a target=\"_blank\" href=\"https://github.com/nextcloud/nextcloudpi/blob/devel/changelog.md\">version " . file_get_contents( "/var/run/.ncp-latest-version" ) . " is available</a>"; + echo '<div id="update-notification" class="row type-error closeable">'; + echo "version " . file_get_contents( "/var/run/.ncp-latest-version" ) . " is available"; echo '<a class="action close icon-close" href="#" alt="Dismiss"></a>'; echo '</div>'; echo '</div>'; @@ -58,13 +58,15 @@ <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" target="_blank"> - <div class="logo-icon"> - <h1 class="hidden-visually">NextCloudPi</h1> - </div> - </a> - <?php echo file_get_contents( "/usr/local/etc/ncp-version" ) . " "; ?> + <a href="https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/" + id="nextcloudpi" tabindex="1" target="_blank"> + <div class="logo-icon"> + <h1 class="hidden-visually">NextCloudPi</h1> + </div> + </a> + <a id=versionlink target="_blank" href="https://github.com/nextcloud/nextcloudpi/blob/devel/changelog.md"> + <?php echo file_get_contents( "/usr/local/etc/ncp-version" ) ?> + </a> </div> <div id="header-right"> <div id="poweroff"> diff --git a/ncp-web/ncp.css b/ncp-web/ncp.css index 284a7d89..c04f8790 100644 --- a/ncp-web/ncp.css +++ b/ncp-web/ncp.css @@ -1133,3 +1133,19 @@ select { padding: 8px; opacity: 0.6; } + +a#versionlink{ + border:0; + color:white; + text-decoration:none; + cursor:pointer +} + +#update-notification { + cursor: pointer; +} + +/* lower version link */ +#header #header-left { + align-items:baseline +} diff --git a/ncp-web/ncp.js b/ncp-web/ncp.js index a41d5cde..11df76a8 100644 --- a/ncp-web/ncp.js +++ b/ncp-web/ncp.js @@ -17,6 +17,18 @@ function errorMsg() $('#config-box').fill( "Something went wrong. Try refreshing the page" ); } +function cfgreqReceive( result ) +{ + var ret = $.parseJSON( result ); + if ( ret.token ) + $('#csrf-token').set( { value: ret.token } ); + $('#circle-retstatus').hide(); + $('#config-box').ht( ret.output ); + $('#config-box-title').fill( $( '#' + selectedID + '-desc' ).get( '.value' ) ); + $('#config-box-info' ).fill( $( '#' + selectedID + '-info' ).get( '.value' ) ); + $('#config-box-wrapper').show(); +} + $(function() { // Event source to receive process output in real time @@ -45,8 +57,6 @@ $(function() confLock = true; $( '#' + selectedID ).set('-active'); - this.set( '+active' ); - var that = this; $.request('post', 'ncp-launcher.php', { action:'cfgreq', ref:this.get('.id') , @@ -54,14 +64,10 @@ $(function() function success( result ) { selectedID = that.get('.id'); - var ret = $.parseJSON( result ); - if ( ret.token ) - $('#csrf-token').set( { value: ret.token } ); - $('#circle-retstatus').hide(); - $('#config-box').ht( ret.output ); - $('#config-box-title').fill( $( '#' + selectedID + '-desc' ).get( '.value' ) ); - $('#config-box-info' ).fill( $( '#' + selectedID + '-info' ).get( '.value' ) ); - $('#config-box-wrapper').show(); + that.set( '+active' ); + + cfgreqReceive( result ); + confLock = false; }).error( errorMsg ); @@ -114,6 +120,33 @@ $(function() }).error( errorMsg ); }); + // Update notification + $( '#notification' ).on('click', function(e) + { + if ( confLock ) return; + confLock = true; + + $( '#' + selectedID ).set('-active'); + + // request + $.request('post', 'ncp-launcher.php', { action:'cfgreq', + ref:'nc-update' , + csrf_token: $( '#csrf-token' ).get( '.value' ) }).then( + function success( result ) + { + selectedID = 'nc-update'; + $( '#nc-update' ).set( '+active' ); + + cfgreqReceive( result ); + + confLock = false; + } + ).error( errorMsg ); + + //clear details box + $('#details-box').hide( '' ); + } ); + // Power-off button $( '#poweroff' ).on('click', function(e) { |