Skip to content

Commit

Permalink
Config UI: device value formatting (evcc-io#17258)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Nov 20, 2024
1 parent 9083a84 commit 5bfa661
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions assets/js/components/Config/DeviceTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
{{ $t(`config.deviceValue.${entry.name}`) }}
</div>
<div
class="value overflow-hidden text-truncate"
class="value overflow-hidden"
:class="{
'value--error': !!entry.error,
'value--warning': entry.warning,
'value--muted': entry.muted || entry.value === false,
'text-truncate': allowTruncate(entry.name),
'flex-shrink-0': !allowTruncate(entry.name),
}"
>
{{ fmtDeviceValue(entry) }}
Expand All @@ -23,7 +25,9 @@
</div>
</template>
<script>
import formatter from "../../mixins/formatter";
import formatter, { POWER_UNIT } from "../../mixins/formatter";
const NO_TRUNCATE = ["phasePowers", "phaseVoltages", "phaseCurrents"];
export default {
name: "DeviceTags",
Expand Down Expand Up @@ -66,7 +70,7 @@ export default {
case "phaseVoltages":
return value.map((v) => this.fmtNumber(v, 0)).join(" · ") + " V";
case "phasePowers":
return value.map((v) => this.fmtW(v)).join(", ");
return value.map((v) => this.fmtW(v, POWER_UNIT.KW, false)).join(" · ") + " kW";
case "chargeStatus":
return this.$t(`config.deviceValue.chargeStatus${value}`);
case "gridPrice":
Expand All @@ -86,6 +90,9 @@ export default {
}
return value;
},
allowTruncate(name) {
return !NO_TRUNCATE.includes(name);
},
},
};
</script>
Expand Down

0 comments on commit 5bfa661

Please sign in to comment.