diff --git a/freedata_gui/src/components/settings_station.vue b/freedata_gui/src/components/settings_station.vue index 2f596b19..4b2889ef 100644 --- a/freedata_gui/src/components/settings_station.vue +++ b/freedata_gui/src/components/settings_station.vue @@ -114,16 +114,18 @@ + + id="myGrid" + v-model="settings.remote.STATION.mygrid" + type="text" + class="form-control" + :placeholder="$t('settings.station.locator_placeholder')" + maxlength="6" + aria-label="Station Grid Locator" + @change="checkGridsquare" +/> + @@ -220,7 +222,7 @@ import { onMounted } from "vue"; import { settingsStore as settings, onChange, getRemote } from "../store/settingsStore.js"; import { validateCallsignWithoutSSID } from "../js/freedata"; import * as bootstrap from "bootstrap"; - +import i18next from "../js/i18n"; // Initialize Bootstrap tooltips onMounted(() => { @@ -228,6 +230,25 @@ onMounted(() => { [...tooltipTriggerList].forEach(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)); }); + +function checkGridsquare(e) { + let value = e.target.value.trim(); + const regex = /^[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2})?$/; + + if (regex.test(value)) { + let formatted = + value.substring(0, 2).toUpperCase() + + value.substring(2, 4) + + (value.length === 6 ? value.substring(4, 6).toLowerCase() : ""); + + settings.remote.STATION.mygrid = formatted; + onChange(); + } else { + alert(i18next.t('settings.station.locator_error')); + } +} + + // Function to validate and update callsign function validateCall() { let call = settings.remote.STATION.mycall; diff --git a/freedata_gui/src/locales/en_English.json b/freedata_gui/src/locales/en_English.json index 5a34e612..f301c4ab 100644 --- a/freedata_gui/src/locales/en_English.json +++ b/freedata_gui/src/locales/en_English.json @@ -242,6 +242,7 @@ "callsignssid_help": "Set a SSID for this station", "locator": "Grid Locator / Maidenhead", "locator_help": "Enter a grid locator (Max 6 chars; shorter will randomize)", + "locator_error": "Enter a correct grid locator, like JN12ea or JN12!", "locator_placeholder": "Your grid locator", "respondtocq": "Respond to CQ callings with a QRV reply", "respondtocq_help": "QRV reply sent with random delay", diff --git a/freedata_gui/src/store/settingsStore.js b/freedata_gui/src/store/settingsStore.js index 2af49c9d..0db4bc0e 100644 --- a/freedata_gui/src/store/settingsStore.js +++ b/freedata_gui/src/store/settingsStore.js @@ -109,7 +109,6 @@ export const settingsStore = reactive({ ...defaultConfig, local: localConfig }); // Function to handle remote configuration changes export function onChange() { - console.log("hier sind wir....."); let remote_config = settingsStore.remote; let blacklistContent = remote_config.STATION.callsign_blacklist; // Check if the content is a string