Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Nov 3, 2024
1 parent 43a41c3 commit 309d64e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions webapp/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@
"ConfigHintNoBatteryInterface": "SoC-basierte Schwellwerte können nur mit konfigurierter Batteriekommunikationsschnittstelle genutzt werden.",
"General": "Allgemein",
"Enable": "Aktiviert",
"GovernInverter": "Steuere {name}",
"VerboseLogging": "@:base.VerboseLogging",
"SolarPassthrough": "Solar-Passthrough",
"EnableSolarPassthrough": "Aktiviere Solar-Passthrough",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@
"ConfigHintNoBatteryInterface": "SoC-based thresholds can only be used if a battery communication interface is configured.",
"General": "General",
"Enable": "Enable",
"GovernInverter": "Govern {name}",
"VerboseLogging": "@:base.VerboseLogging",
"SolarPassthrough": "Solar-Passthrough",
"EnableSolarPassthrough": "Enable Solar-Passthrough",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@
"ConfigHintNoBatteryInterface": "SoC-based thresholds can only be used if a battery communication interface is configured.",
"General": "General",
"Enable": "Enable",
"GovernInverter": "Govern {name}",
"VerboseLogging": "@:base.VerboseLogging",
"SolarPassthrough": "Solar-Passthrough",
"EnableSolarPassthrough": "Enable Solar-Passthrough",
Expand Down
34 changes: 33 additions & 1 deletion webapp/src/views/PowerLimiterAdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
wide
/>

<template v-if="powerLimiterConfigList.enabled" v-for="(proxy, serial) in toggleProxies" :key="serial">

Check failure on line 45 in webapp/src/views/PowerLimiterAdminView.vue

View workflow job for this annotation

GitHub Actions / build

This 'v-if' should be moved to the wrapper element
<InputElement
:label="$t('powerlimiteradmin.GovernInverter', { name: inverterName(serial) })"
v-model="toggleProxies[serial]"
type="checkbox"
wide
/>
</template>

<template v-if="isEnabled()">
<InputElement
:label="$t('powerlimiteradmin.VerboseLogging')"
Expand Down Expand Up @@ -94,6 +103,10 @@
</CardElement>

<template v-if="isEnabled()">
<template v-for="(isInvSelected, serial) in toggleProxies" :key="serial">
<CardElement v-if="isInvSelected" :text="inverterLabel(serial)" textVariant="text-bg-primary" add-space>
</CardElement>
</template>
<CardElement :text="$t('powerlimiteradmin.ManagedInverters')" textVariant="text-bg-primary" add-space>
<div class="row mb-3" v-if="unmanagedInverters.length > 0">
<label for="add_inverter" class="col-sm-4 col-form-label">
Expand Down Expand Up @@ -537,6 +550,7 @@ export default defineComponent({
alertType: 'info',
showAlert: false,
configAlert: false,
toggleProxies: {} as object,
additionalInverterSerial: '',
modalEdit: {} as bootstrap.Modal,
modalDelete: {} as bootstrap.Modal,
Expand Down Expand Up @@ -634,7 +648,7 @@ export default defineComponent({
return hints;
},
isEnabled() {
return this.powerLimiterConfigList.enabled;
return this.powerLimiterConfigList.enabled && Object.values(this.toggleProxies).some(v => v === true);
},
hasPowerMeter() {
return this.powerLimiterMetaData.power_meter_enabled;
Expand All @@ -657,6 +671,20 @@ export default defineComponent({
range(end: number) {
return Array.from(Array(end).keys());
},
inverterName(serial: string) {
if (serial === undefined) {
return 'undefined';
}
const meta = this.powerLimiterMetaData;
if (meta === undefined) {
return 'metadata pending';
}
const inv = meta.inverters[serial];
if (inv === undefined) {
return 'not found';
}
return inv.name;
},
inverterLabel(serial: string) {
if (serial === undefined) {
return 'undefined';
Expand Down Expand Up @@ -761,6 +789,10 @@ export default defineComponent({
.then((response) => handleResponse(response, this.$emitter, this.$router))
.then((data) => {
this.powerLimiterConfigList = data;
this.toggleProxies = Object.keys(this.powerLimiterMetaData.inverters).reduce((acc, key) => {
acc[key] = this.powerLimiterConfigList.inverters.some(inv => inv.serial === key);
return acc;
}, {});
this.dataLoading = false;
});
});
Expand Down

0 comments on commit 309d64e

Please sign in to comment.