mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix some minor issues with cost display in energy sources table (#17452)
This commit is contained in:
parent
bde93c44bd
commit
6653a8f634
@ -80,6 +80,10 @@ export class HuiEnergySourcesTableCard
|
|||||||
let totalWater = 0;
|
let totalWater = 0;
|
||||||
let totalWaterCost = 0;
|
let totalWaterCost = 0;
|
||||||
|
|
||||||
|
let hasGridCost = false;
|
||||||
|
let hasGasCost = false;
|
||||||
|
let hasWaterCost = false;
|
||||||
|
|
||||||
let totalGridCompare = 0;
|
let totalGridCompare = 0;
|
||||||
let totalGridCostCompare = 0;
|
let totalGridCostCompare = 0;
|
||||||
let totalSolarCompare = 0;
|
let totalSolarCompare = 0;
|
||||||
@ -477,6 +481,7 @@ export class HuiEnergySourcesTableCard
|
|||||||
) || 0
|
) || 0
|
||||||
: null;
|
: null;
|
||||||
if (cost !== null) {
|
if (cost !== null) {
|
||||||
|
hasGridCost = true;
|
||||||
totalGridCost += cost;
|
totalGridCost += cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,6 +580,7 @@ export class HuiEnergySourcesTableCard
|
|||||||
) || 0) * -1
|
) || 0) * -1
|
||||||
: null;
|
: null;
|
||||||
if (cost !== null) {
|
if (cost !== null) {
|
||||||
|
hasGridCost = true;
|
||||||
totalGridCost += cost;
|
totalGridCost += cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,14 +692,16 @@ export class HuiEnergySourcesTableCard
|
|||||||
? html`<td
|
? html`<td
|
||||||
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
||||||
>
|
>
|
||||||
${formatNumber(
|
${hasGridCost
|
||||||
totalGridCostCompare,
|
? formatNumber(
|
||||||
this.hass.locale,
|
totalGridCostCompare,
|
||||||
{
|
this.hass.locale,
|
||||||
style: "currency",
|
{
|
||||||
currency: this.hass.config.currency!,
|
style: "currency",
|
||||||
}
|
currency: this.hass.config.currency!,
|
||||||
)}
|
}
|
||||||
|
)
|
||||||
|
: ""}
|
||||||
</td>`
|
</td>`
|
||||||
: ""}`
|
: ""}`
|
||||||
: ""}
|
: ""}
|
||||||
@ -706,10 +714,12 @@ export class HuiEnergySourcesTableCard
|
|||||||
? html`<td
|
? html`<td
|
||||||
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
||||||
>
|
>
|
||||||
${formatNumber(totalGridCost, this.hass.locale, {
|
${hasGridCost
|
||||||
style: "currency",
|
? formatNumber(totalGridCost, this.hass.locale, {
|
||||||
currency: this.hass.config.currency!,
|
style: "currency",
|
||||||
})}
|
currency: this.hass.config.currency!,
|
||||||
|
})
|
||||||
|
: ""}
|
||||||
</td>`
|
</td>`
|
||||||
: ""}
|
: ""}
|
||||||
</tr>`
|
</tr>`
|
||||||
@ -737,6 +747,7 @@ export class HuiEnergySourcesTableCard
|
|||||||
0
|
0
|
||||||
: null;
|
: null;
|
||||||
if (cost !== null) {
|
if (cost !== null) {
|
||||||
|
hasGasCost = true;
|
||||||
totalGasCost += cost;
|
totalGasCost += cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,14 +846,16 @@ export class HuiEnergySourcesTableCard
|
|||||||
? html`<td
|
? html`<td
|
||||||
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
||||||
>
|
>
|
||||||
${formatNumber(
|
${hasGasCost
|
||||||
totalGasCostCompare,
|
? formatNumber(
|
||||||
this.hass.locale,
|
totalGasCostCompare,
|
||||||
{
|
this.hass.locale,
|
||||||
style: "currency",
|
{
|
||||||
currency: this.hass.config.currency!,
|
style: "currency",
|
||||||
}
|
currency: this.hass.config.currency!,
|
||||||
)}
|
}
|
||||||
|
)
|
||||||
|
: ""}
|
||||||
</td>`
|
</td>`
|
||||||
: ""}`
|
: ""}`
|
||||||
: ""}
|
: ""}
|
||||||
@ -855,10 +868,12 @@ export class HuiEnergySourcesTableCard
|
|||||||
? html`<td
|
? html`<td
|
||||||
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
||||||
>
|
>
|
||||||
${formatNumber(totalGasCost, this.hass.locale, {
|
${hasGasCost
|
||||||
style: "currency",
|
? formatNumber(totalGasCost, this.hass.locale, {
|
||||||
currency: this.hass.config.currency!,
|
style: "currency",
|
||||||
})}
|
currency: this.hass.config.currency!,
|
||||||
|
})
|
||||||
|
: ""}
|
||||||
</td>`
|
</td>`
|
||||||
: ""}
|
: ""}
|
||||||
</tr>`
|
</tr>`
|
||||||
@ -886,6 +901,7 @@ export class HuiEnergySourcesTableCard
|
|||||||
0
|
0
|
||||||
: null;
|
: null;
|
||||||
if (cost !== null) {
|
if (cost !== null) {
|
||||||
|
hasWaterCost = true;
|
||||||
totalWaterCost += cost;
|
totalWaterCost += cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -984,14 +1000,16 @@ export class HuiEnergySourcesTableCard
|
|||||||
? html`<td
|
? html`<td
|
||||||
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
||||||
>
|
>
|
||||||
${formatNumber(
|
${hasWaterCost
|
||||||
totalWaterCostCompare,
|
? formatNumber(
|
||||||
this.hass.locale,
|
totalWaterCostCompare,
|
||||||
{
|
this.hass.locale,
|
||||||
style: "currency",
|
{
|
||||||
currency: this.hass.config.currency!,
|
style: "currency",
|
||||||
}
|
currency: this.hass.config.currency!,
|
||||||
)}
|
}
|
||||||
|
)
|
||||||
|
: ""}
|
||||||
</td>`
|
</td>`
|
||||||
: ""}`
|
: ""}`
|
||||||
: ""}
|
: ""}
|
||||||
@ -1004,16 +1022,18 @@ export class HuiEnergySourcesTableCard
|
|||||||
? html`<td
|
? html`<td
|
||||||
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
||||||
>
|
>
|
||||||
${formatNumber(totalWaterCost, this.hass.locale, {
|
${hasWaterCost
|
||||||
style: "currency",
|
? formatNumber(totalWaterCost, this.hass.locale, {
|
||||||
currency: this.hass.config.currency!,
|
style: "currency",
|
||||||
})}
|
currency: this.hass.config.currency!,
|
||||||
|
})
|
||||||
|
: ""}
|
||||||
</td>`
|
</td>`
|
||||||
: ""}
|
: ""}
|
||||||
</tr>`
|
</tr>`
|
||||||
: ""}
|
: ""}
|
||||||
${[totalGasCost, totalWaterCost, totalGridCost].filter(Boolean)
|
${[hasGasCost, hasWaterCost, hasGridCost].filter(Boolean).length >
|
||||||
.length > 1
|
1
|
||||||
? html`<tr class="mdc-data-table__row total">
|
? html`<tr class="mdc-data-table__row total">
|
||||||
<td class="mdc-data-table__cell"></td>
|
<td class="mdc-data-table__cell"></td>
|
||||||
<th class="mdc-data-table__cell" scope="row">
|
<th class="mdc-data-table__cell" scope="row">
|
||||||
@ -1022,9 +1042,7 @@ export class HuiEnergySourcesTableCard
|
|||||||
)}
|
)}
|
||||||
</th>
|
</th>
|
||||||
${compare
|
${compare
|
||||||
? html`${showCosts
|
? html`<td class="mdc-data-table__cell"></td>
|
||||||
? html`<td class="mdc-data-table__cell"></td>`
|
|
||||||
: ""}
|
|
||||||
<td
|
<td
|
||||||
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
class="mdc-data-table__cell mdc-data-table__cell--numeric"
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user