Show pgweb version on homep age and check for newer releases

This commit is contained in:
Dan Sosedoff 2018-12-12 20:11:35 -06:00
parent 107a3ac6d4
commit 658d14314b
4 changed files with 61 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -571,14 +571,32 @@
margin-top: 50px;
}
.connection-settings h1 {
.connection-settings .header {
margin-bottom: 25px;
}
.connection-settings .header h1 {
text-align: center;
text-shadow: 0px 1px 0px #fff;
margin-bottom: 25px;
color: #999;
font-weight: normal;
}
.connection-settings .header .version {
font-size: 12px;
color: #aaa;
text-align: center;
display: block;
}
.connection-settings .header .update {
font-size: 12px;
text-align: center;
padding: 4px;
margin: 12px 0px;
display: none;
}
.connection-settings form {
background: #f6f6f6;
padding: 25px;

View File

@ -119,7 +119,11 @@
<div id="connection_window">
<div class="connection-settings">
<h1>pgweb</h1>
<div class="header">
<h1>pgweb</h1>
<div class="version"></div>
<div class="update alert alert-warning"></div>
</div>
<form role="form" class="form-horizontal" id="connection_form">
<div class="text-center">

View File

@ -78,6 +78,7 @@ function apiCall(method, path, params, cb) {
});
}
function getInfo(cb) { apiCall("get", "/info", {}, cb); }
function getObjects(cb) { apiCall("get", "/objects", {}, cb); }
function getTables(cb) { apiCall("get", "/tables", {}, cb); }
function getTableRows(table, opts, cb) { apiCall("get", "/tables/" + table + "/rows", opts, cb); }
@ -770,7 +771,36 @@ function addShortcutTooltips() {
}
}
// Get the latest release from Github API
function getLatestReleaseInfo(current) {
try {
$.get("https://api.github.com/repos/sosedoff/pgweb/releases/latest", function(release) {
if (release.name != current.version) {
var message = "Update available. Check out " + release.tag_name + " on <a target='_blank' href='" + release.html_url + "'>Github</a>";
$(".connection-settings .update").html(message).fadeIn();
}
});
}
catch(error) {
console.log("Cant get last release from github:", error);
}
}
function showConnectionSettings() {
// Fetch server info
getInfo(function(data) {
if (data.error) return;
if (!data.version) return;
// Show the current postgres version
$(".connection-settings .version").text("v" + data.version).show();
// Check for updates if running the actual release from Github
if (data.git_sha == "") {
getLatestReleaseInfo(data);
}
});
getBookmarks(function(data) {
// Do not add any bookmarks if we've got an error
if (data.error) {