Show link to latest release if newer one available

This commit is contained in:
phl0
2024-09-12 13:23:01 +02:00
parent 724b7fe1af
commit 7750198bb0
3 changed files with 30 additions and 1 deletions

View File

@@ -22,10 +22,19 @@ class Debug extends CI_Controller
$this->load->model('Debug_model');
$this->load->model('Stations');
$this->load->model('cron_model');
$this->load->model('Update_model');
$footerData = [];
$footerData['scripts'] = ['assets/js/sections/debug.js'];
$data['running_version'] = $this->optionslib->get_option('version');
$data['latest_release'] = $this->Update_model->wavelog_latest_release();
if (version_compare($data['latest_release'], $data['running_version'], '>')) {
$data['newer_version_available'] = true;
} else {
$data['newer_version_available'] = false;
}
$data['stations'] = $this->Stations->all();
$data['qso_total'] = $this->Debug_model->count_all_qso();

View File

@@ -260,4 +260,18 @@ class Update_model extends CI_Model {
$totaltime = ($endtime - $starttime);
return "Records inserted: " . $i . " in " . $totaltime . " seconds <br />";
}
function wavelog_latest_release() {
$latest_tag = null;
$url = "https://api.github.com/repos/wavelog/wavelog/releases";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog Updater');
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
$json = json_decode($result, true);
$latest_tag = $json[0]['tag_name'];
return $latest_tag;
}
}

View File

@@ -25,8 +25,14 @@
<table width="100%">
<tr>
<td><?= __("Version"); ?></td>
<td><?php echo $this->optionslib->get_option('version') . "\n"; ?></td>
<td><?php echo $running_version."\n"; ?></td>
</tr>
<?php if ($newer_version_available) { ?>
<tr>
<td><?= __("Latest Release"); ?></td>
<td><a href="https://github.com/wavelog/wavelog/releases/tag/<?php echo $latest_release; ?>" target="_blank"><?php echo $latest_release."\n"; ?></a></td>
</tr>
<?php } ?>
<tr>
<td><?= __("Language"); ?></td>
<td><?php echo __(ucfirst($this->config->item('language'))) . "\n"; ?></td>