TeaSpeak-Client/modules/core/app-updater/ui/index.ts
2019-06-26 22:09:01 +02:00

51 lines
2.0 KiB
TypeScript

import * as electron from "electron";
import * as $ from "jquery";
import {Version} from "../../../shared/version";
electron.ipcRenderer.on('status-update', (event, progress) => {
if(!$(".info").is(":visible")) {
$(".page").hide();
$(".info").show()
}
$(".progress").attr("value", progress * 100);
});
electron.ipcRenderer.on('status-update-text', (event, text) => {
if(!$(".info").is(":visible")) {
$(".page").hide();
$(".info").show()
}
$(".state").html(text);
});
electron.ipcRenderer.on('status-error', (event, text) => {
console.log("Got error %s", text);
$(".page").hide();
$(".error").show().html(text);
});
electron.ipcRenderer.on('status-confirm-execute', (event, callback_name) => {
$(".page").hide();
$(".confirm-restart").show();
$(".button-execute").on('click', event => electron.ipcRenderer.send(callback_name, true))
});
electron.ipcRenderer.on('status-confirm-update', (event, callback_name, current: Version, version: Version) => {
console.dir(callback_name);
console.dir(version);
$(".page").hide();
$(".config-update").show();
$(".target-version").text(version.major + "." + version.minor + "." + version.patch + (version.build > 0 ? " (" + version.build + ")" : ""));
$(".current-version").text(current.major + "." + current.minor + "." + current.patch + (current.build > 0 ? " (" + current.build + ")" : ""));
$(".button-update").on('click', event => electron.ipcRenderer.send(callback_name, true));
$(".button-cancel").on('click', event => electron.ipcRenderer.send(callback_name, false));
});
/*
const set_text = text => window.webContents.send('status-update-text', text);
const set_error = text => window.webContents.send('status-error', text);
const set_confirm_restart = () => window.webContents.send('status-confirm-restart');
const set_progress = progress => window.webContents.send('status-update', progress);
const await_exit = () => { return new Promise(resolve => window.on('closed', resolve))};
*/