Skip to content

Commit

Permalink
New check warnings logic
Browse files Browse the repository at this point in the history
Changes:
- Show warning message on docker, if a new image is available;
- Never show the warning for Nightly or Dev images;
- In docker, never show individual component update warnings;
- simplified footer (logic moved to upgrade_checker file).

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
  • Loading branch information
rdwebdesign committed Aug 24, 2022
1 parent 9be9657 commit a0838b1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 33 deletions.
44 changes: 22 additions & 22 deletions scripts/pi-hole/php/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
// - determines local branch each time,
// - determines local and remote version every 30 minutes
require 'scripts/pi-hole/php/update_checker.php';

if (isset($core_commit) || isset($web_commit) || isset($FTL_commit)) {
$list_class = "list-unstyled";
} else {
$list_class = "list-inline";
}
?>
<footer class="main-footer">
<div class="row row-centered text-center">
Expand All @@ -58,44 +64,38 @@

<div class="row row-centered text-center version-info">
<div class="col-xs-12 col-sm-12 col-md-10">
<?php if (isset($core_commit) || isset($web_commit) || isset($FTL_commit)) { ?>
<ul class="list-unstyled">
<?php if ($docker_current) { ?> <li><strong>Docker Tag</strong> <?php echo $docker_current; ?></li> <?php } ?>
<li><strong>Pi-hole</strong> <?php echo $coreVersionStr; ?></li>
<li><strong>FTL</strong> <?php echo $ftlVersionStr; ?></li>
<li><strong>Web Interface</strong> <?php echo $webVersionStr; ?></li>
</ul>
<?php } else { ?>
<ul class="list-inline">
<ul class="<?php echo $list_class; ?>">
<?php if ($docker_current) { ?>
<li>
<strong>Docker Tag</strong>
<a href="<?php echo $dockerReleasesUrl.'/'.$docker_current; ?>" rel="noopener" target="_blank"><?php echo $docker_current; ?></a>
<?php echo $docker_current; ?>
<?php if ($docker_update) { ?> &middot; <a class="lookatme" lookatme-text="Update available!" href="<?php echo $dockerUrl.'/latest'; ?>" rel="noopener" target="_blank">Update available!</a><?php } ?>
</li>
<?php } ?>
<li>
<strong>Pi-hole</strong>
<a href="<?php echo $coreReleasesUrl.'/'.$core_current; ?>" rel="noopener" target="_blank"><?php echo $core_current; ?></a>
<?php if ($core_update) { ?> &middot; <a class="lookatme" lookatme-text="Update available!" href="<?php echo $coreReleasesUrl.'/latest'; ?>" rel="noopener" target="_blank">Update available!</a><?php } ?>
<?php echo $coreVersionStr; ?>
<?php if ($core_update) { ?> &middot; <a class="lookatme" lookatme-text="Update available!" href="<?php echo $coreUrl.'/latest'; ?>" rel="noopener" target="_blank">Update available!</a><?php } ?>
</li>
<li>
<strong>FTL</strong>
<a href="<?php echo $ftlReleasesUrl.'/'.$FTL_current; ?>" rel="noopener" target="_blank"><?php echo $FTL_current; ?></a>
<?php if ($FTL_update) { ?> &middot; <a class="lookatme" lookatme-text="Update available!" href="<?php echo $ftlReleasesUrl.'/latest'; ?>" rel="noopener" target="_blank">Update available!</a><?php } ?>
<?php echo $ftlVersionStr; ?>
<?php if ($FTL_update) { ?> &middot; <a class="lookatme" lookatme-text="Update available!" href="<?php echo $ftlUrl.'/latest'; ?>" rel="noopener" target="_blank">Update available!</a><?php } ?>
</li>
<li>
<strong>Web Interface</strong>
<a href="<?php echo $webReleasesUrl.'/'.$web_current; ?>" rel="noopener" target="_blank"><?php echo $web_current; ?></a>
<?php if ($web_update) { ?> &middot; <a class="lookatme" lookatme-text="Update available!" href="<?php echo $webReleasesUrl.'/latest'; ?>" rel="noopener" target="_blank">Update available!</a><?php } ?>
<?php echo $webVersionStr; ?>
<?php if ($web_update) { ?> &middot; <a class="lookatme" lookatme-text="Update available!" href="<?php echo $webUrl.'/latest'; ?>" rel="noopener" target="_blank">Update available!</a><?php } ?>
</li>
</ul>
<?php if ($docker_update) { ?>
<p>To install updates, <a href="https://github.com/pi-hole/docker-pi-hole#upgrading-persistence-and-customizations" rel="noopener" target="_blank">replace this old container with a fresh upgraded image</a>.</p>
<?php } elseif ($core_update || $web_update || $FTL_update) { ?>
<p>To install updates, run <code><a href="https://docs.pi-hole.net/main/update/" rel="noopener" target="_blank">pihole -up</a></code>.</p>
<?php } ?>

<?php } ?>
<p style="margin: 15px 0 0;">
<?php if ($docker_update) { ?>
To install updates, <a href="https://github.com/pi-hole/docker-pi-hole#upgrading-persistence-and-customizations" rel="noopener" target="_blank">replace this old container with a fresh upgraded image</a>.
<?php } elseif ($core_update || $web_update || $FTL_update) { ?>
To install updates, run <code><a href="https://docs.pi-hole.net/main/update/" rel="noopener" target="_blank">pihole -up</a></code>.
<?php } ?>
</p>
</div>
</div>
</footer>
Expand Down
36 changes: 25 additions & 11 deletions scripts/pi-hole/php/update_checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,30 @@ function checkUpdate($currentVersion, $latestVersion)
}

// URLs for the links
$coreUrl = 'https://github.com/pi-hole/pi-hole';
$dockerUrl = 'https://github.com/pi-hole/docker-pi-hole';
$ftlUrl = 'https://github.com/pi-hole/FTL';
$webUrl = 'https://github.com/pi-hole/AdminLTE';
$coreReleasesUrl = $coreUrl.'/releases';
$webReleasesUrl = $webUrl.'/releases';
$ftlReleasesUrl = $ftlUrl.'/releases';
$dockerReleasesUrl = $dockerUrl.'/releases';
$coreUrl = 'https://github.com/pi-hole/pi-hole/releases';
$webUrl = 'https://github.com/pi-hole/AdminLTE/releases';
$ftlUrl = 'https://github.com/pi-hole/FTL/releases';
$dockerUrl = 'https://github.com/pi-hole/docker-pi-hole/releases';

// Version strings
$coreVersionStr = $core_current.(isset($core_commit) ? ' ('.$core_branch.', '.$core_commit.')' : '');
$webVersionStr = $web_current.(isset($web_commit) ? ' ('.$web_branch.', '.$web_commit.')' : '');
$ftlVersionStr = $FTL_current.(isset($FTL_commit) ? ' ('.$FTL_branch.', '.$FTL_commit.')' : '');
// If "vDev" show branch/commit, else show link
$coreVersionStr = $core_current;
if (isset($core_commit)) {
$coreVersionStr .= ' ('.$core_branch.', '.$core_commit.')';
} else {
$coreVersionStr = '<a href="'.$coreUrl.'/'.$core_current.'" rel="noopener" target="_blank">'.$core_current.'</a>';
}

$webVersionStr = $web_current;
if (isset($web_commit)) {
$webVersionStr .= ' ('.$web_branch.', '.$web_commit.')';
} else {
$webVersionStr = '<a href="'.$webUrl.'/'.$web_current.'" rel="noopener" target="_blank">'.$web_current.'</a>';
}

$ftlVersionStr = $FTL_current;
if (isset($FTL_commit)) {
$ftlVersionStr .= ' ('.$FTL_branch.', '.$FTL_commit.')';
} else {
$ftlVersionStr = '<a href="'.$ftlUrl.'/'.$FTL_current.'" rel="noopener" target="_blank">'.$FTL_current.'</a>';
}

0 comments on commit a0838b1

Please sign in to comment.