FreeDATA/gui/src/components/main_startup_check.vue

289 lines
10 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { Modal } from "bootstrap";
import { onMounted } from "vue";
2023-11-13 12:48:02 +00:00
import main_rig_control from "./main_rig_control.vue";
import main_audio from "./main_audio.vue";
import infoScreen_updater from "./infoScreen_updater.vue";
2023-11-13 12:48:02 +00:00
2023-11-13 17:50:46 +00:00
import { getModemVersion, saveModemConfig } from "../js/api";
2023-11-13 16:30:23 +00:00
import { setActivePinia } from "pinia";
import pinia from "../store/index";
setActivePinia(pinia);
import { useSettingsStore } from "../store/settingsStore.js";
const settings = useSettingsStore(pinia);
import { useAudioStore } from "../store/audioStore.js";
const audio = useAudioStore(pinia);
import { useStateStore } from "../store/stateStore.js";
const state = useStateStore(pinia);
import { startModem, stopModem } from "../js/api";
import { getModemConfig } from "../js/api";
2023-11-13 17:50:46 +00:00
const version = import.meta.env.PACKAGE_VERSION;
2023-11-13 12:48:02 +00:00
// start modemCheck modal once on startup
onMounted(() => {
2023-11-13 16:30:23 +00:00
getModemConfig();
2023-11-13 17:50:46 +00:00
getModemVersion();
new Modal("#modemCheck", {}).show();
});
2023-11-13 16:30:23 +00:00
2023-11-13 16:41:56 +00:00
function getModemState() {
2023-11-13 16:30:23 +00:00
// Returns active/inactive if modem is running for modem status label
2023-11-13 16:41:56 +00:00
if (state.is_modem_running == true) return "Active";
else return "Inactive";
2023-11-13 16:30:23 +00:00
}
2023-11-13 19:07:31 +00:00
function getNetworkState() {
// Returns active/inactive if modem is running for modem status label
if (state.modem_connection === "connected") return "Connected";
else return "Disconnected";
}
</script>
2023-11-13 06:20:46 +00:00
<template>
2023-11-13 06:21:13 +00:00
<div
2023-11-13 16:30:23 +00:00
class="modal modal-lg fade"
id="modemCheck"
2023-11-13 06:21:13 +00:00
data-bs-backdrop="static"
data-bs-keyboard="false"
tabindex="-1"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">Modem check</h1>
2023-11-13 06:21:13 +00:00
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
2023-11-13 12:48:02 +00:00
<div class="accordion" id="startupCheckAccordion">
<!-- Network Section -->
2023-11-13 06:21:13 +00:00
<div class="accordion-item">
<h2 class="accordion-header">
<button
class="accordion-button collapsed"
type="button"
2023-11-13 12:48:02 +00:00
data-bs-target="#networkStatusCollapse"
2023-11-13 06:21:13 +00:00
data-bs-toggle="collapse"
>
2023-11-13 19:12:09 +00:00
Network
<span
class="badge ms-2 bg-success"
:class="
2023-11-13 19:07:31 +00:00
state.modem_connection === 'connected'
? 'bg-success'
: 'bg-danger'
"
2023-11-13 19:12:09 +00:00
>{{ getNetworkState() }}</span
>
2023-11-13 06:21:13 +00:00
</button>
</h2>
<div
id="networkStatusCollapse"
class="accordion-collapse collapse"
>
2023-11-13 06:21:13 +00:00
<div class="accordion-body">
2023-11-13 19:07:31 +00:00
<div class="input-group input-group-sm mb-1">
2023-11-13 19:12:09 +00:00
<span class="input-group-text" style="width: 180px"
>Modem port</span
>
<input
type="text"
class="form-control"
placeholder="modem port"
id="modem_port"
maxlength="5"
max="65534"
min="1025"
@change="saveModemConfig()"
v-model="settings.modem_port"
/>
</div>
2023-11-13 19:07:31 +00:00
2023-11-13 19:12:09 +00:00
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" style="width: 180px"
>Modem host</span
>
<input
type="text"
class="form-control"
placeholder="modem host"
id="modem_port"
@change="saveModemConfig"
v-model="settings.modem_host"
/>
</div>
2023-11-13 06:21:13 +00:00
Placeholder content for this accordion, which is intended to
demonstrate the <code>.accordion-flush</code> class. This is
the first item's accordion body.
</div>
</div>
</div>
2023-11-13 12:48:02 +00:00
<!-- Modem Section -->
2023-11-13 06:21:13 +00:00
<div class="accordion-item">
<h2 class="accordion-header">
<button
class="accordion-button collapsed"
type="button"
2023-11-13 12:48:02 +00:00
data-bs-target="#modemStatusCollapse"
2023-11-13 06:21:13 +00:00
data-bs-toggle="collapse"
>
2023-11-13 16:41:56 +00:00
Modem
<span
class="badge ms-2"
:class="
state.is_modem_running === true
? 'bg-success'
: 'bg-danger'
"
>{{ getModemState() }}</span
>
2023-11-13 06:21:13 +00:00
</button>
</h2>
2023-11-13 12:48:02 +00:00
<div id="modemStatusCollapse" class="accordion-collapse collapse">
2023-11-13 06:21:13 +00:00
<div class="accordion-body">
2023-11-13 16:30:23 +00:00
<div class="input-group input-group-sm mb-1">
<label class="input-group-text w-25">Modem control</label>
<label class="input-group-text">
2023-11-13 16:41:56 +00:00
<button
type="button"
id="startModem"
class="btn btn-sm btn-outline-success"
data-bs-toggle="tooltip"
data-bs-trigger="hover"
data-bs-html="false"
title="Start the Modem. Please set your audio and radio settings first!"
@click="startModem"
v-bind:class="{
disabled: state.is_modem_running === true,
}"
>
<i class="bi bi-play-fill"></i>
</button> </label
><label class="input-group-text">
<button
type="button"
id="stopModem"
class="btn btn-sm btn-outline-danger"
data-bs-toggle="tooltip"
data-bs-trigger="hover"
data-bs-html="false"
title="Stop the Modem."
@click="stopModem"
v-bind:class="{
disabled: state.is_modem_running === false,
}"
>
<i class="bi bi-stop-fill"></i>
</button>
</label>
</div>
<!-- Audio Input Device -->
<div class="input-group input-group-sm mb-1">
<label class="input-group-text w-25">Input device</label>
<select
class="form-select form-select-sm"
id="rx_audio"
aria-label=".form-select-sm"
@change="saveModemConfig"
v-model="settings.input_device"
v-html="audio.getInputDevices()"
></select>
2023-11-13 16:30:23 +00:00
</div>
2023-11-13 16:41:56 +00:00
<!-- Audio Output Device -->
<div class="input-group input-group-sm mb-1">
<label class="input-group-text w-25">Output device</label>
<select
class="form-select form-select-sm"
id="tx_audio"
aria-label=".form-select-sm"
@change="saveModemConfig"
v-model="settings.output_device"
v-html="audio.getOutputDevices()"
></select>
</div>
2023-11-13 06:21:13 +00:00
</div>
</div>
</div>
2023-11-13 12:48:02 +00:00
<!-- Radio Control Section -->
2023-11-13 06:21:13 +00:00
<div class="accordion-item">
<h2 class="accordion-header">
<button
class="accordion-button collapsed"
type="button"
2023-11-13 12:48:02 +00:00
data-bs-target="#radioControlCollapse"
2023-11-13 06:21:13 +00:00
data-bs-toggle="collapse"
>
Radio control
<span class="badge ms-2 bg-danger">Disconnected</span>
</button>
</h2>
<div
id="radioControlCollapse"
class="accordion-collapse collapse"
>
2023-11-13 06:21:13 +00:00
<div class="accordion-body">
<main_rig_control />
2023-11-13 06:21:13 +00:00
</div>
</div>
</div>
2023-11-13 18:02:04 +00:00
<!-- Version Section -->
<div class="accordion-item">
2023-11-13 17:50:46 +00:00
<h2 class="accordion-header">
<button
class="accordion-button collapsed"
type="button"
data-bs-target="#versionCheckCollapse"
data-bs-toggle="collapse"
>
Version
<span class="badge ms-2 bg-warning">Update needed</span>
</button>
</h2>
<div
id="versionCheckCollapse"
class="accordion-collapse collapse"
>
<div class="accordion-body">
<button
2023-11-13 18:02:04 +00:00
class="btn btn-secondary btn-sm ms-1 me-1"
type="button"
disabled
>
GUI version | {{ version }}
</button>
2023-11-13 17:50:46 +00:00
2023-11-13 18:02:04 +00:00
<button
class="btn btn-secondary btn-sm ms-1 me-1"
type="button"
disabled
>
Modem version | {{ state.modem_version }}
</button>
2023-11-13 17:50:46 +00:00
<infoScreen_updater />
</div>
</div>
</div>
2023-11-13 06:21:13 +00:00
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">
Continue
</button>
2023-11-13 06:21:13 +00:00
</div>
2023-11-13 06:20:46 +00:00
</div>
</div>
</div>
</template>