FreeDATA/gui/src/components/main_startup_check.vue

447 lines
16 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 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);
2023-11-18 15:53:54 +00:00
import { settingsStore as settings} from "../store/settingsStore.js";
2023-11-13 16:30:23 +00:00
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";
2023-11-17 21:35:52 +00:00
import { getModemConfig, getModemCurrentState } from "../js/api";
2023-11-13 16:30:23 +00:00
2023-11-15 03:00:04 +00:00
import { startRigctld, stopRigctld } from "../js/deprecated_daemon";
2023-11-13 17:50:46 +00:00
const version = import.meta.env.PACKAGE_VERSION;
2023-11-15 22:04:18 +00:00
var updateAvailable = process.env.FDUpdateAvail;
2023-11-13 17:50:46 +00:00
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-17 21:35:52 +00:00
getModemCurrentState();
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";
}
2023-11-15 03:00:04 +00:00
function getRigControlStuff() {
switch (settings.radiocontrol) {
case "disabled":
return true;
case "rigctld":
if (state.rigctld_started == "true") {
2023-11-15 03:00:04 +00:00
return true;
} else {
return false;
}
case "tci":
return true;
break;
default:
console.error("Unknown radio control mode " + settings.radiocontrol);
return "Unknown control type";
2023-11-15 03:00:04 +00:00
}
}
function testHamlib() {
2023-11-15 03:00:04 +00:00
alert("Not yet implemented.");
}
</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">
<span class="input-group-text w-25">Modem port</span>
2023-11-13 19:12:09 +00:00
<input
type="text"
class="form-control"
2023-11-13 20:18:59 +00:00
placeholder="modem port (def 5000)"
2023-11-13 19:12:09 +00:00
id="modem_port"
maxlength="5"
max="65534"
min="1025"
@change="saveSettingsToFile()"
2023-11-13 19:12:09 +00:00
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 w-25">Modem host</span>
2023-11-13 19:12:09 +00:00
<input
type="text"
class="form-control"
2023-11-13 20:18:59 +00:00
placeholder="modem host (default 127.0.0.1)"
2023-11-13 19:12:09 +00:00
id="modem_port"
@change="saveSettingsToFile()"
2023-11-13 19:12:09 +00:00
v-model="settings.modem_host"
/>
</div>
2023-11-13 06:21:13 +00:00
</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"
:class="
getRigControlStuff() === true ? 'bg-success' : 'bg-danger'
"
>{{
getRigControlStuff() === true ? "Online" : "Offline"
}}</span
>
2023-11-13 06:21:13 +00:00
</button>
</h2>
<div
id="radioControlCollapse"
class="accordion-collapse collapse"
>
2023-11-13 06:21:13 +00:00
<div class="accordion-body">
2023-11-15 03:00:04 +00:00
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" style="width: 180px"
>Rig control method</span
>
2023-11-15 03:00:04 +00:00
<select
class="form-select form-select-sm"
aria-label=".form-select-sm"
id="rigcontrol_radiocontrol"
@change="saveModemConfig"
v-model="settings.radiocontrol"
>
<option selected value="disabled">
Disabled (no rig control; use with VOX)
</option>
<option selected value="rigctld">Rigctld (Hamlib)</option>
<option selected value="tci">TCI</option>
</select>
</div>
<div
:class="settings.radiocontrol == 'rigctld' ? '' : 'd-none'"
>
<!-- Shown when rigctld is selected-->
<div class="input-group input-group-sm mb-1">
<label class="input-group-text w-25"
>Rigctld control</label
2023-11-15 03:00:04 +00:00
>
<label class="input-group-text">
<button
type="button"
class="btn btn-sm btn-outline-success"
data-bs-toggle="tooltip"
data-bs-trigger="hover"
data-bs-html="false"
title="Start rigctld"
@click="startRigctld"
v-bind:class="{
disabled: state.rigctld_started == 'true',
}"
>
<i class="bi bi-play-fill"></i>
</button> </label
><label class="input-group-text">
<button
type="button"
class="btn btn-sm btn-outline-danger"
data-bs-toggle="tooltip"
data-bs-trigger="hover"
data-bs-html="false"
title="Stop rigctld"
@click="stopRigctld"
v-bind:class="{
disabled:
state.rigctld_started == 'false' ||
state.rigctld_started === undefined,
}"
>
<i class="bi bi-stop-fill"></i>
</button>
</label>
<label class="input-group-text">
<button
type="button"
id="testHamlib"
class="btn btn-sm btn-outline-secondary"
data-bs-placement="bottom"
data-bs-toggle="tooltip"
data-bs-trigger="hover"
data-bs-html="true"
@click="testHamlib"
title="Test your hamlib settings and toggle PTT once. Button will become <strong class='text-success'>green</strong> on success and <strong class='text-danger'>red</strong> if fails."
>
PTT test
</button>
</label>
</div>
2023-11-15 03:00:04 +00:00
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" style="width: 180px"
>Radio port</span
>
2023-11-15 03:00:04 +00:00
<select
class="form-select form-select-sm"
aria-label=".form-select-sm"
id="hamlib_deviceport"
style="width: 7rem"
@change="saveModemConfig"
></select>
</div>
</div>
<div :class="settings.radiocontrol == 'tci' ? '' : 'd-none'">
2023-11-15 03:00:04 +00:00
<!-- Shown when tci is selected-->
2023-11-15 03:00:04 +00:00
<div class="input-group input-group-sm mb-1">
<span class="input-group-text w-25">TCI IP address</span>
<input
type="text"
class="form-control"
placeholder="TCI IP"
id="rigcontrol_tci_ip"
aria-label="Device IP"
v-model="settings.tci_ip"
@change="saveModemConfig"
/>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text w-25">TCI port</span>
<input
type="text"
class="form-control"
placeholder="TCI port"
id="rigcontrol_tci_port"
aria-label="Device Port"
v-model="settings.tci_port"
@change="saveModemConfig"
/>
</div>
</div>
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
2023-11-15 22:04:48 +00:00
<span
class="badge ms-2"
:class="
updateAvailable === '1' ? 'bg-warning' : 'bg-success'
"
>
{{
updateAvailable === "1"
? "Update available ! ! ! !"
: "Current"
}}</span
>
2023-11-13 17:50:46 +00:00
</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-15 22:04:18 +00:00
<div :class="updateAvailable === '1' ? '' : 'd-none'">
2023-11-15 22:04:48 +00:00
<infoScreen_updater />
</div>
2023-11-15 22:04:18 +00:00
</div>
2023-11-13 17:50:46 +00:00
</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>