22 lines
969 B
JavaScript
22 lines
969 B
JavaScript
import {JSONRPC} from "/assets/jrpc.js";
|
|
|
|
(async function () {
|
|
$("#panel").prepend(`<div id="update-panel">Checking for updates...</div><hr>`);
|
|
let state = (await JSONRPC.__invoke("updates::check"));
|
|
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 {
|
|
alert(await JSONRPC.__invoke("updates::install"));
|
|
} finally {
|
|
setTimeout(() => location.reload(), 1000);
|
|
}
|
|
});
|
|
}
|
|
})(); |