write plumbing to & from CLI installer

This commit is contained in:
Brad Warren
2025-10-30 11:51:57 -07:00
committed by Brad Warren
parent bc9022530a
commit ef006d83a6
2 changed files with 63 additions and 14 deletions

View File

@@ -1,13 +1,27 @@
<script lang="ts">
import { invoke } from '@tauri-apps/api/core';
import { listen } from '@tauri-apps/api/event';
let name = $state('');
let greetMsg = $state('');
let buttonEnabled = $state(true);
let installerArgs = $state('');
let installerOutput = $state('');
async function greet(event: Event) {
listen<string>('installer-output', (event) => {
installerOutput += event.payload;
});
async function run_installer(event: Event) {
event.preventDefault();
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
greetMsg = await invoke('greet', { name });
buttonEnabled = false;
installerOutput = '';
try {
await invoke('install_rayhunter', { args: installerArgs });
} catch (error) {
installerOutput +=
'Rayhunter GUI installer encountered an internal error. Error was:\n';
installerOutput += error;
}
buttonEnabled = true;
}
</script>
@@ -63,15 +77,19 @@
</a>
</div>
</div>
<form class="flex justify-center pt-5" onsubmit={greet}>
<form class="flex justify-center pt-5" onsubmit={run_installer}>
<input
class="mr-1 px-5 py-2 rounded-lg shadow-md"
placeholder="Enter CLI installer args..."
bind:value={name}
bind:value={installerArgs}
/>
<button class="cursor-pointer px-5 py-2 rounded-lg shadow-md" type="submit">Run</button>
<button
class="{buttonEnabled ? 'cursor-pointer' : ''} px-5 py-2 rounded-lg shadow-md"
disabled={!buttonEnabled}
type="submit">Run</button
>
</form>
<p class="p-4">Installer output:</p>
<p class="px-5 py-2 rounded-lg shadow-md whitespace-pre-line">
{greetMsg}
<p class="bg-gray-100 px-5 py-2 rounded-lg shadow-md whitespace-pre-line">
{installerOutput}
</p>