Skip to content

Commit

Permalink
ncp-web: click version for changelog. click new version notification …
Browse files Browse the repository at this point in the history
…to nc-update
  • Loading branch information
nacho committed Sep 10, 2017
1 parent ea5bbb4 commit fab1815
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 19 deletions.
20 changes: 11 additions & 9 deletions ncp-web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
Expand All @@ -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" ) . "&nbsp;&nbsp;"; ?>
<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">
Expand Down
16 changes: 16 additions & 0 deletions ncp-web/ncp.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
53 changes: 43 additions & 10 deletions ncp-web/ncp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,23 +57,17 @@ $(function()
confLock = true;

$( '#' + selectedID ).set('-active');
this.set( '+active' );

var that = this;
$.request('post', 'ncp-launcher.php', { action:'cfgreq',
ref:this.get('.id') ,
csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
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 );

Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit fab1815

Please sign in to comment.