+
+
+
+
{
+ if (!deepEqual(newValue[paramName], oldValue[paramName])) {
+ this.applyServiceDefault(paramName);
+ }
+ });
+ },
+ deep: true,
+ },
},
methods: {
reset() {
@@ -700,19 +733,16 @@ export default defineComponent({
}
this.serviceValuesTimer = setTimeout(async () => {
this.serviceValues = await fetchServiceValues(this.templateParams, this.values);
- this.applyServiceDefaults();
}, 500);
},
- applyServiceDefaults() {
- // Auto-apply single service values when field is empty and required
- Object.keys(this.serviceValues).forEach((paramName) => {
- const values = this.serviceValues[paramName];
- const param = this.templateParams.find((p) => p.Name === paramName);
- // Only auto-apply if exactly one value is returned, field is empty, and field is required
- if (values?.length === 1 && !this.values[paramName] && param?.Required) {
- this.values[paramName] = values[0];
- }
- });
+ applyServiceDefault(paramName: string) {
+ // Auto-apply single service value when field is empty and required
+ const values = this.serviceValues[paramName];
+ const param = this.templateParams.find((p) => p.Name === paramName);
+ // Only auto-apply if exactly one value is returned, field is empty, and field is required
+ if (values?.length === 1 && !this.values[paramName] && param?.Required) {
+ this.values[paramName] = values[0];
+ }
},
},
});
diff --git a/assets/js/components/Config/DeviceModal/index.ts b/assets/js/components/Config/DeviceModal/index.ts
index 3962008da..b6f1fa536 100644
--- a/assets/js/components/Config/DeviceModal/index.ts
+++ b/assets/js/components/Config/DeviceModal/index.ts
@@ -116,10 +116,11 @@ export function customChargerName(type: ConfigType, isHeating: boolean) {
export async function loadServiceValues(path: string) {
try {
- const response = await api.get(`/config/service/${path}`);
+ const response = await api.get(`/config/service/${path}`, {
+ validateStatus: (status) => status >= 200 && status < 500,
+ });
return (response.data as string[]) || [];
- } catch (e) {
- console.error(e);
+ } catch {
return [];
}
}
@@ -169,7 +170,10 @@ export const fetchServiceValues = async (
return;
}
const url = endpoint.url(params);
- result[endpoint.name] = await loadServiceValues(url);
+ const data = await loadServiceValues(url);
+ if (data) {
+ result[endpoint.name] = data;
+ }
})
);