From 4d458198c195cf7ff66e7623f3e0212ff1a9ba1d Mon Sep 17 00:00:00 2001 From: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com> Date: Mon, 8 Jan 2024 08:32:56 -0500 Subject: [PATCH] Fix bug with saving general settings not using tempSettingsStruct and using store values instead (#1131) residual from #1075 closes #1129 --- .../src/components/settings/NetworkingCard.vue | 16 +++++++++++++++- .../src/stores/settings/GeneralSettingsStore.ts | 14 +------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/photon-client/src/components/settings/NetworkingCard.vue b/photon-client/src/components/settings/NetworkingCard.vue index ee29190108..d8a9973c6a 100644 --- a/photon-client/src/components/settings/NetworkingCard.vue +++ b/photon-client/src/components/settings/NetworkingCard.vue @@ -68,8 +68,22 @@ const settingsHaveChanged = (): boolean => { const saveGeneralSettings = () => { const changingStaticIp = useSettingsStore().network.connectionType === NetworkConnectionType.Static; + // replace undefined members with empty strings for backend + const payload = { + connectionType: tempSettingsStruct.value.connectionType, + hostname: tempSettingsStruct.value.hostname, + networkManagerIface: tempSettingsStruct.value.networkManagerIface || "", + ntServerAddress: tempSettingsStruct.value.ntServerAddress, + runNTServer: tempSettingsStruct.value.runNTServer, + setDHCPcommand: tempSettingsStruct.value.setDHCPcommand || "", + setStaticCommand: tempSettingsStruct.value.setStaticCommand || "", + shouldManage: tempSettingsStruct.value.shouldManage, + shouldPublishProto: tempSettingsStruct.value.shouldPublishProto, + staticIp: tempSettingsStruct.value.staticIp + }; + useSettingsStore() - .saveGeneralSettings() + .updateGeneralSettings(payload) .then((response) => { useStateStore().showSnackbarMessage({ message: response.data.text || response.data, diff --git a/photon-client/src/stores/settings/GeneralSettingsStore.ts b/photon-client/src/stores/settings/GeneralSettingsStore.ts index a04d2af558..c7fc264dfc 100644 --- a/photon-client/src/stores/settings/GeneralSettingsStore.ts +++ b/photon-client/src/stores/settings/GeneralSettingsStore.ts @@ -105,19 +105,7 @@ export const useSettingsStore = defineStore("settings", { this.network = data.networkSettings; this.currentFieldLayout = data.atfl; }, - saveGeneralSettings() { - const payload: Required = { - connectionType: this.network.connectionType, - hostname: this.network.hostname, - networkManagerIface: this.network.networkManagerIface || "", - ntServerAddress: this.network.ntServerAddress, - runNTServer: this.network.runNTServer, - setDHCPcommand: this.network.setDHCPcommand || "", - setStaticCommand: this.network.setStaticCommand || "", - shouldManage: this.network.shouldManage, - shouldPublishProto: this.network.shouldPublishProto, - staticIp: this.network.staticIp - }; + updateGeneralSettings(payload: Required) { return axios.post("/settings/general", payload); }, /**