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

30 lines
1.2 KiB
TypeScript

import { shell, ipcRenderer } from "electron";
function open_issue_tracker() {
shell.openExternal("https://github.com/TeaSpeak/TeaClient/issues");
}
function set_dump_error_flag(flag: boolean) {
for(const node of document.getElementsByClassName("error-show") as HTMLCollectionOf<HTMLElement>)
node.style.display = flag ? "block" : "none";
for(const node of document.getElementsByClassName("error-hide") as HTMLCollectionOf<HTMLElement>)
node.style.display = flag ? "none" : "block";
}
function set_dump_url(url: string) {
for(const crash_path_node of document.getElementsByClassName("crash-dump-directory") as HTMLCollectionOf<HTMLElement>) {
crash_path_node.textContent = url;
crash_path_node.onclick = () => shell.showItemInFolder(url);
}
set_dump_error_flag(false);
}
function set_dump_error(error: string) {
set_dump_error_flag(true);
for(const node of document.getElementsByClassName("crash-dump-error") as HTMLCollectionOf<HTMLElement>)
node.textContent = error;
}
ipcRenderer.on('dump-url', (event, url) => set_dump_url(url));
ipcRenderer.on('dump-error', (event, error) => set_dump_error(error));