mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-08 15:08:42 +00:00
Add GUI error display and non-interactive quickstart
This commit is contained in:
@@ -3,6 +3,16 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>VoxVera GUI</title>
|
<title>VoxVera GUI</title>
|
||||||
|
<style>
|
||||||
|
#log {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 5px;
|
||||||
|
height: 150px;
|
||||||
|
overflow-y: auto;
|
||||||
|
background: #f8f8f8;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>VoxVera</h1>
|
<h1>VoxVera</h1>
|
||||||
@@ -20,6 +30,7 @@
|
|||||||
<button type="button" id="quickstart">Generate & Serve</button>
|
<button type="button" id="quickstart">Generate & Serve</button>
|
||||||
</form>
|
</form>
|
||||||
<p id="onion-address"></p>
|
<p id="onion-address"></p>
|
||||||
|
<pre id="log"></pre>
|
||||||
<script>
|
<script>
|
||||||
async function load() {
|
async function load() {
|
||||||
const cfg = await window.voxvera.loadConfig();
|
const cfg = await window.voxvera.loadConfig();
|
||||||
@@ -43,6 +54,15 @@
|
|||||||
window.voxvera.onOnionUrl(url => {
|
window.voxvera.onOnionUrl(url => {
|
||||||
document.getElementById('onion-address').textContent = `Onion address: ${url}`;
|
document.getElementById('onion-address').textContent = `Onion address: ${url}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.voxvera.onLog((msg, isErr) => {
|
||||||
|
const container = document.getElementById('log');
|
||||||
|
const span = document.createElement('span');
|
||||||
|
if (isErr) span.style.color = 'red';
|
||||||
|
span.textContent = msg;
|
||||||
|
container.appendChild(span);
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -42,21 +42,37 @@ ipcMain.handle('run-quickstart', async (_, config) => {
|
|||||||
);
|
);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
const proc = spawn(voxveraPath, ['--config', configPath, 'quickstart']);
|
const args = ['--config', configPath, 'quickstart', '--non-interactive'];
|
||||||
|
const proc = spawn(voxveraPath, args);
|
||||||
proc.stdout.on('data', data => {
|
proc.stdout.on('data', data => {
|
||||||
const line = data.toString();
|
const line = data.toString();
|
||||||
process.stdout.write(line);
|
process.stdout.write(line);
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.webContents.send('log', { text: line, isError: false });
|
||||||
|
}
|
||||||
const m = line.match(/Onion URL:\s*(https?:\/\/[a-z0-9.-]+\.onion)/i);
|
const m = line.match(/Onion URL:\s*(https?:\/\/[a-z0-9.-]+\.onion)/i);
|
||||||
if (m && mainWindow) {
|
if (m && mainWindow) {
|
||||||
mainWindow.webContents.send('onion-url', m[1]);
|
mainWindow.webContents.send('onion-url', m[1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
proc.stderr.on('data', data => {
|
proc.stderr.on('data', data => {
|
||||||
process.stderr.write(data);
|
const line = data.toString();
|
||||||
|
process.stderr.write(line);
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.webContents.send('log', { text: line, isError: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
proc.on('close', code => {
|
||||||
|
if (code !== 0) {
|
||||||
|
dialog.showErrorBox('voxvera error', `voxvera exited with code ${code}.`);
|
||||||
|
}
|
||||||
|
resolve(code);
|
||||||
|
});
|
||||||
|
proc.on('error', err => {
|
||||||
|
dialog.showErrorBox('voxvera error', err.message);
|
||||||
|
resolve(-1);
|
||||||
});
|
});
|
||||||
proc.on('close', code => resolve(code));
|
|
||||||
proc.on('error', err => reject(err));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -3,5 +3,6 @@ const { contextBridge, ipcRenderer } = require('electron');
|
|||||||
contextBridge.exposeInMainWorld('voxvera', {
|
contextBridge.exposeInMainWorld('voxvera', {
|
||||||
loadConfig: () => ipcRenderer.invoke('load-config'),
|
loadConfig: () => ipcRenderer.invoke('load-config'),
|
||||||
quickstart: (config) => ipcRenderer.invoke('run-quickstart', config),
|
quickstart: (config) => ipcRenderer.invoke('run-quickstart', config),
|
||||||
onOnionUrl: (cb) => ipcRenderer.on('onion-url', (_, url) => cb(url))
|
onOnionUrl: (cb) => ipcRenderer.on('onion-url', (_, url) => cb(url)),
|
||||||
|
onLog: (cb) => ipcRenderer.on('log', (_, data) => cb(data.text, data.isError))
|
||||||
});
|
});
|
||||||
|
@@ -406,7 +406,9 @@ def main(argv=None):
|
|||||||
|
|
||||||
sub.add_parser('import', help='Batch import JSON files from imports/')
|
sub.add_parser('import', help='Batch import JSON files from imports/')
|
||||||
sub.add_parser('serve', help='Serve flyer over OnionShare using config')
|
sub.add_parser('serve', help='Serve flyer over OnionShare using config')
|
||||||
sub.add_parser('quickstart', help='Init, build and serve in sequence')
|
p_quickstart = sub.add_parser('quickstart', help='Init, build and serve in sequence')
|
||||||
|
p_quickstart.add_argument('--non-interactive', action='store_true',
|
||||||
|
help='Skip interactive prompts and use existing config')
|
||||||
sub.add_parser('check', help='Check for required external dependencies')
|
sub.add_parser('check', help='Check for required external dependencies')
|
||||||
|
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
@@ -429,7 +431,15 @@ def main(argv=None):
|
|||||||
elif args.command == 'import':
|
elif args.command == 'import':
|
||||||
import_configs()
|
import_configs()
|
||||||
elif args.command == 'quickstart':
|
elif args.command == 'quickstart':
|
||||||
interactive_update(config_path)
|
if not args.non_interactive:
|
||||||
|
if not sys.stdin.isatty():
|
||||||
|
print(
|
||||||
|
"Error: quickstart requires an interactive terminal. "
|
||||||
|
"Use --non-interactive or run 'voxvera init' first.",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
interactive_update(config_path)
|
||||||
build_assets(config_path)
|
build_assets(config_path)
|
||||||
serve(config_path)
|
serve(config_path)
|
||||||
elif args.command == 'check':
|
elif args.command == 'check':
|
||||||
|
Reference in New Issue
Block a user