From 4a0c15b61be0b23a070b1b1e6bdf2fd8e0e5eac4 Mon Sep 17 00:00:00 2001 From: Craig Schardt Date: Sat, 20 Jan 2024 18:46:47 -0600 Subject: [PATCH] Disable the network controls when networkingIsDisabled is true (#1118) * commented controls that should depend on networkingIsDisabled * add the thing * fix Manage Device Networking showing disabled * commented controls that should depend on networkingIsDisabled * add the thing * fix Manage Device Networking showing disabled * Hide the settings that aren't available when networking is disabled * Update NetworkingCard.vue * Update NetworkingCard.vue --------- Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com> --- .../components/settings/NetworkingCard.vue | 45 ++++++++++++++----- photon-client/src/types/SettingTypes.ts | 6 ++- .../configuration/PhotonConfiguration.java | 2 + 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/photon-client/src/components/settings/NetworkingCard.vue b/photon-client/src/components/settings/NetworkingCard.vue index d8a9973c6..82c6a17a1 100644 --- a/photon-client/src/components/settings/NetworkingCard.vue +++ b/photon-client/src/components/settings/NetworkingCard.vue @@ -5,12 +5,11 @@ import PvInput from "@/components/common/pv-input.vue"; import PvRadio from "@/components/common/pv-radio.vue"; import PvSwitch from "@/components/common/pv-switch.vue"; import PvSelect from "@/components/common/pv-select.vue"; -import { NetworkConnectionType, type NetworkSettings } from "@/types/SettingTypes"; +import { type ConfigurableNetworkSettings, NetworkConnectionType } from "@/types/SettingTypes"; import { useStateStore } from "@/stores/StateStore"; // Copy object to remove reference to store -const tempSettingsStruct = ref(Object.assign({}, useSettingsStore().network)); - +const tempSettingsStruct = ref(Object.assign({}, useSettingsStore().network)); const resetTempSettingsStruct = () => { tempSettingsStruct.value = Object.assign({}, useSettingsStore().network); }; @@ -58,7 +57,6 @@ const settingsHaveChanged = (): boolean => { a.runNTServer !== b.runNTServer || a.shouldManage !== b.shouldManage || a.shouldPublishProto !== b.shouldPublishProto || - a.canManage !== b.canManage || a.networkManagerIface !== b.networkManagerIface || a.setStaticCommand !== b.setStaticCommand || a.setDHCPcommand !== b.setDHCPcommand @@ -91,7 +89,10 @@ const saveGeneralSettings = () => { }); // Update the local settings cause the backend checked their validity. Assign is to deref value - useSettingsStore().network = Object.assign({}, tempSettingsStruct.value); + useSettingsStore().network = { + ...useSettingsStore().network, + ...Object.assign({}, tempSettingsStruct.value) + }; }) .catch((error) => { resetTempSettingsStruct(); @@ -162,42 +163,63 @@ watchEffect(() => { The NetworkTables Server Address is not set or is invalid. NetworkTables is unable to connect. Advanced Networking { v-show=" !useSettingsStore().networkInterfaceNames.length && tempSettingsStruct.shouldManage && - tempSettingsStruct.canManage + useSettingsStore().network.canManage && + !useSettingsStore().network.networkingDisabled " rounded color="red" diff --git a/photon-client/src/types/SettingTypes.ts b/photon-client/src/types/SettingTypes.ts index f9509db18..701e46a1c 100644 --- a/photon-client/src/types/SettingTypes.ts +++ b/photon-client/src/types/SettingTypes.ts @@ -45,9 +45,13 @@ export interface NetworkSettings { setStaticCommand?: string; setDHCPcommand?: string; networkInterfaceNames: NetworkInterfaceType[]; + networkingDisabled: boolean; } -export type ConfigurableNetworkSettings = Omit; +export type ConfigurableNetworkSettings = Omit< + NetworkSettings, + "canManage" | "networkInterfaceNames" | "networkingDisabled" +>; export interface LightingSettings { supported: boolean; diff --git a/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java b/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java index 9fb3ec4a7..d867b6dcf 100644 --- a/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java +++ b/photon-core/src/main/java/org/photonvision/common/configuration/PhotonConfiguration.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.stream.Collectors; import org.photonvision.PhotonVersion; import org.photonvision.common.hardware.Platform; +import org.photonvision.common.networking.NetworkManager; import org.photonvision.common.networking.NetworkUtils; import org.photonvision.common.util.SerializationUtils; import org.photonvision.jni.RknnDetectorJNI; @@ -121,6 +122,7 @@ public class PhotonConfiguration { // Hack active interfaces into networkSettings var netConfigMap = networkConfig.toHashMap(); netConfigMap.put("networkInterfaceNames", NetworkUtils.getAllWiredInterfaces()); + netConfigMap.put("networkingDisabled", NetworkManager.getInstance().networkingIsDisabled); settingsSubmap.put("networkSettings", netConfigMap);