diff --git a/app.go b/app.go index 51bca01..c4c0596 100644 --- a/app.go +++ b/app.go @@ -25,6 +25,7 @@ func NewApp() *App { func (a *App) startup(ctx context.Context) { a.ctx = ctx + runtime.LogInfo(ctx, fmt.Sprintf("Version: %s", "test")) } func (a *App) domReady(ctx context.Context) { @@ -59,15 +60,16 @@ func (a *App) LoadStationFile() station.Definition { a.station = station a.stationHash = calculateSHA256(data) a.client = td2.New(a.ctx, fmt.Sprintf("%x", a.stationHash)) + runtime.LogInfof(a.ctx, "Loaded station file with hash: %s", a.stationHash) return station } -func (a *App) Connect(address string) string { +func (a *App) Connect(address string) error { err := a.client.Connect(address) if err != nil { runtime.LogError(a.ctx, fmt.Sprint(err, address)) - return fmt.Sprintf("%s", err) + return err } go func() { @@ -83,7 +85,7 @@ func (a *App) Connect(address string) string { } }() - return "" + return nil } func (a *App) Disconnect() { diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ffd9004..ab420e3 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -2,17 +2,22 @@ import { ref } from "vue"; import { Connect, Disconnect } from "../wailsjs/go/main/App"; import { useStationStore } from "./stores/station"; +import { LogError, LogInfo } from "../wailsjs/runtime/runtime"; const connected = ref(false); -const stationStore = useStationStore() +const stationStore = useStationStore(); function handleConnect() { if (connected.value) { - connected.value = false - Disconnect() + connected.value = false; + Disconnect(); } else { Connect("127.0.0.1:7424") - connected.value = true + .then(() => { + LogInfo("Connected!"); + connected.value = true; + }) + .catch(LogError); } } @@ -32,7 +37,7 @@ function handleConnect() { :disabled="stationStore.hills.length === 0" class="btn btn-main" > - {{ connected ? 'Disconnect' : 'Connect' }} + {{ connected ? "Disconnect" : "Connect" }}