Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Sep 9, 2024
1 parent 1f511c0 commit 302adfd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "time"
type RelayType string

var (
Version = "1.1.5-dev"
Version = "1.1.5"
GitBranch string
GitRevision string
BuildTime string
Expand Down
52 changes: 50 additions & 2 deletions internal/web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@
<li>StartTime: {{.StartTime}}</li>
</ul>
</div>
<div class="mt-4">
<p>Latest Version: <span id="latestVersion">Checking...</span></p>
<p id="updateMessage" style="display: none;"></p>
</div>
</div>
<footer class="card-footer">
<button class="button is-danger is-outlined card-footer-item" id="reloadButton">
<span class="icon"><i class="fas fa-sync-alt"></i></span>
<span>Reload Config</span>
<span>Reload Configuration</span>
</button>
<button class="button is-info is-outlined card-footer-item" id="checkUpdateButton">
<span class="icon"><i class="fas fa-download"></i></span>
<span>Check for Updates</span>
</button>
</footer>
</div>
Expand All @@ -46,7 +54,20 @@

<script>
$(document).ready(function () {
// Reload config button click event
// Add this function to compare version strings
function compareVersions(v1, v2) {
const v1Parts = v1.replace('v', '').split('.');
const v2Parts = v2.replace('v', '').split('.');
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
const v1Part = parseInt(v1Parts[i] || 0);
const v2Part = parseInt(v2Parts[i] || 0);
if (v1Part > v2Part) return 1;
if (v1Part < v2Part) return -1;
}
return 0;
}

// Reload configuration button click event
$('#reloadButton').click(function () {
$.ajax({
type: 'POST',
Expand All @@ -59,6 +80,33 @@
},
});
});

// Check for updates button click event
$('#checkUpdateButton').click(function () {
$.ajax({
url: 'https://api.github.com/repos/Ehco1996/ehco/releases/latest',
type: 'GET',
dataType: 'json',
success: function (data) {
var latestVersion = data.tag_name;
$('#latestVersion').text(latestVersion);
var currentVersion = '{{.Version}}';
if (compareVersions(latestVersion, currentVersion) > 0) {
var releaseUrl = data.html_url;
var updateMessage = 'New version available: ' + latestVersion +
'. Please update manually from: <a href="' + releaseUrl + '" target="_blank">' + releaseUrl + '</a>';
$('#updateMessage').html(updateMessage).show();
alert('New version available: ' + latestVersion + '. Please check the update message for details.');
} else {
$('#updateMessage').hide();
alert('You have the latest version');
}
},
error: function () {
alert('Failed to check for updates. Please try again later.');
},
});
});
});
</script>
</body>
Expand Down

0 comments on commit 302adfd

Please sign in to comment.