diff --git a/utils/assets/index.html b/utils/assets/index.html
index cb36a3f..431ad0d 100644
--- a/utils/assets/index.html
+++ b/utils/assets/index.html
@@ -7,10 +7,11 @@
Loading...
+
Checking for updates...
-
+
Selected networks:
@@ -93,7 +94,7 @@
self.prop("disabled", true);
(async function () {
try {
- alert( await JSONRPC.__invoke("restart_quagga"));
+ alert(await JSONRPC.__invoke("restart_quagga"));
} finally {
setTimeout(() => {
self.prop("disabled", false);
@@ -103,8 +104,26 @@
})();
}
});
- (async function(){
- alert(await JSONRPC.__invoke("checkUpdates"));
+ (async function () {
+ let state = (await JSONRPC.__invoke("checkUpdates"));
+ if (state === null) {
+ $("#update-panel").html(`Error checking updates`);
+ } else if (state === false) {
+ $("#update-panel").html(`There is no updates`);
+ } else if (state === true) {
+ $("#update-panel").html(`Some updates are available `);
+ $("#update-panel button").click(async function () {
+ $("#panel").hide();
+ $("#loading").show().text("Installing updates...");
+ try {
+ console.log(await JSONRPC.__invoke("installUpdates"));
+ } finally {
+ setTimeout(() => location.reload(), 10000);
+ }
+ });
+
+
+ }
})();
});
diff --git a/utils/server.php b/utils/server.php
index 38b3d15..7e237c5 100644
--- a/utils/server.php
+++ b/utils/server.php
@@ -68,8 +68,18 @@ try {
public function checkUpdates()
{
$this->checkAuth();
- $data = shell_exec("git --no-pager fetch --dry-run --porcelain --verbose 2>&1");
- return $data;
+ $data = str_replace("=","",@shell_exec("git --no-pager fetch --dry-run --porcelain --verbose 2>&1 | grep refs"));
+ $parts = explode(" ", trim($data));
+ if(count($parts) < 3){
+ return null;
+ }
+
+ return $parts[0] != $parts[1];
+ }
+
+ public function installUpdates()
+ {
+ return @shell_exec("git --no-pager pull --verbose 2>&1");
}