Fixing updates
This commit is contained in:
parent
3e2437144c
commit
67a5c2e480
|
|
@ -7,10 +7,11 @@
|
|||
</head>
|
||||
<body>
|
||||
<span id="loading">Loading...</span>
|
||||
|
||||
<div style="display: none" id="panel">
|
||||
|
||||
<div id="update-panel">Checking for updates...</div>
|
||||
|
||||
<hr>
|
||||
Selected networks:
|
||||
<table id="net-table">
|
||||
<tr>
|
||||
|
|
@ -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(`<span style="color:red;">Error checking updates</span>`);
|
||||
} else if (state === false) {
|
||||
$("#update-panel").html(`<span style="color:black;">There is no updates</span>`);
|
||||
} else if (state === true) {
|
||||
$("#update-panel").html(`<span style="color:green;">Some updates are available</span> <button>Update</button>`);
|
||||
$("#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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
})();
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue