From 57aa1a4180f26c6566c70c7b3e8d568fc1ed4e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20F=C3=A9lix?= Date: Mon, 15 Jan 2024 00:33:00 +0100 Subject: [PATCH 1/2] feat: :sparkles: disable dots --- src/components/flows/batteryGrid.ts | 3 ++- src/components/flows/batteryToHome.ts | 3 ++- src/components/flows/gridToHome.ts | 3 ++- src/components/flows/solarToBattery.ts | 3 ++- src/components/flows/solarToGrid.ts | 3 ++- src/components/flows/solarToHome.ts | 3 ++- src/components/individualLeftBottomElement.ts | 3 ++- src/components/individualLeftTopElement.ts | 3 ++- src/components/individualRightBottomElement.ts | 3 ++- src/components/individualRightTopElement.ts | 3 ++- src/components/nonFossil.ts | 3 ++- src/localize/languages/cs.json | 3 ++- src/localize/languages/de.json | 1 + src/localize/languages/dk.json | 1 + src/localize/languages/en.json | 1 + src/localize/languages/es.json | 1 + src/localize/languages/fi.json | 1 + src/localize/languages/fr.json | 1 + src/localize/languages/it.json | 1 + src/localize/languages/nl.json | 1 + src/localize/languages/pl.json | 1 + src/localize/languages/pt-BR.json | 1 + src/localize/languages/pt-PT.json | 1 + src/localize/languages/ru.json | 1 + src/localize/languages/sk.json | 1 + src/power-flow-card-plus-config.ts | 1 + src/ui-editor/schema/_schema-all.ts | 8 ++++++-- src/utils/checkShouldShowDots.ts | 5 +++++ 28 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 src/utils/checkShouldShowDots.ts diff --git a/src/components/flows/batteryGrid.ts b/src/components/flows/batteryGrid.ts index 918d5b7..d669bae 100644 --- a/src/components/flows/batteryGrid.ts +++ b/src/components/flows/batteryGrid.ts @@ -5,6 +5,7 @@ import { html, svg } from "lit"; import { styleLine } from "../../utils/styleLine"; import { type Flows } from "./index"; import { checkHasRightIndividual } from "../../utils/computeIndividualPosition"; +import { checkShouldShowDots } from "../../utils/checkShouldShowDots"; type FlowBatteryGridFlows = Pick>; @@ -24,7 +25,7 @@ export const flowBatteryGrid = (config: PowerFlowCardPlusConfig, { battery, grid d="M45,100 v-15 c0,-30 -10,-30 -30,-30 h-20" vector-effect="non-scaling-stroke" > - ${grid.state.toBattery + ${checkShouldShowDots(config) && grid.state.toBattery ? svg`>; @@ -24,7 +25,7 @@ export const flowBatteryToHome = (config: PowerFlowCardPlusConfig, { battery, gr d="M55,100 v-${grid.has ? 15 : 17} c0,-30 10,-30 30,-30 h20" vector-effect="non-scaling-stroke" > - ${battery.state.toHome + ${checkShouldShowDots(config) && battery.state.toHome ? svg` { return grid.has && showLine(config, grid.state.fromGrid) @@ -22,7 +23,7 @@ export const flowGridToHome = (config: PowerFlowCardPlusConfig, { battery, grid, d="M0,${battery.has ? 50 : solar.has ? 56 : 53} H100" vector-effect="non-scaling-stroke" > - ${grid.state.toHome + ${checkShouldShowDots(config) && grid.state.toHome ? svg`>; @@ -24,7 +25,7 @@ export const flowSolarToBattery = (config: PowerFlowCardPlusConfig, { battery, i d="M50,0 V100" vector-effect="non-scaling-stroke" > - ${solar.state.toBattery + ${checkShouldShowDots(config) && solar.state.toBattery ? svg` { return grid.hasReturnToGrid && solar.has && showLine(config, solar.state.toGrid || 0) @@ -22,7 +23,7 @@ export const flowSolarToGrid = (config: PowerFlowCardPlusConfig, { battery, grid d="M${battery.has ? 45 : 47},0 v15 c0,${battery.has ? "30 -10,30 -30,30" : "35 -10,35 -30,35"} h-20" vector-effect="non-scaling-stroke" > - ${solar.state.toGrid && solar.has + ${checkShouldShowDots(config) && solar.state.toGrid && solar.has ? svg` { return solar.has && showLine(config, solar.state.toHome || 0) @@ -22,7 +23,7 @@ export const flowSolarToHome = (config: PowerFlowCardPlusConfig, { battery, grid d="M${battery.has ? 55 : 53},0 v${grid.has ? 15 : 17} c0,${battery.has ? "30 10,30 30,30" : "35 10,35 30,35"} h25" vector-effect="non-scaling-stroke" > - ${solar.state.toHome + ${checkShouldShowDots(config) && solar.state.toHome ? svg` - ${individualObj?.state + ${checkShouldShowDots(config) && individualObj?.state ? svg` - ${individualObj.state + ${checkShouldShowDots(config) && individualObj.state ? svg` - ${individualObj.state + ${checkShouldShowDots(config) && individualObj.state ? svg` - ${individualObj.state + ${checkShouldShowDots(config) && individualObj.state ? svg` - ${nonFossil.has + ${checkShouldShowDots(config) && nonFossil.has ? svg` { + return config.disable_dots !== true; +}; From 09072f0ec03901b989894f72d4f84f1b8ee52362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20F=C3=A9lix?= Date: Mon, 15 Jan 2024 10:06:02 +0100 Subject: [PATCH 2/2] fix: :bug: lines not connecting when no battery connected --- src/components/flows/batteryGrid.ts | 4 ++-- src/components/flows/batteryToHome.ts | 4 ++-- src/components/flows/gridToHome.ts | 4 ++-- src/components/flows/solarToBattery.ts | 4 ++-- src/components/flows/solarToGrid.ts | 4 ++-- src/utils/computeIndividualPosition.ts | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/flows/batteryGrid.ts b/src/components/flows/batteryGrid.ts index 918d5b7..cd21990 100644 --- a/src/components/flows/batteryGrid.ts +++ b/src/components/flows/batteryGrid.ts @@ -4,7 +4,7 @@ import { showLine } from "../../utils/showLine"; import { html, svg } from "lit"; import { styleLine } from "../../utils/styleLine"; import { type Flows } from "./index"; -import { checkHasRightIndividual } from "../../utils/computeIndividualPosition"; +import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition"; type FlowBatteryGridFlows = Pick>; @@ -12,7 +12,7 @@ export const flowBatteryGrid = (config: PowerFlowCardPlusConfig, { battery, grid return grid.has && battery.has && showLine(config, Math.max(grid.state.toBattery || 0, battery.state.toGrid || 0)) ? html`
i?.has), "multi-individual": checkHasRightIndividual(config, individual), })}" diff --git a/src/components/flows/batteryToHome.ts b/src/components/flows/batteryToHome.ts index fd666aa..6faef48 100644 --- a/src/components/flows/batteryToHome.ts +++ b/src/components/flows/batteryToHome.ts @@ -4,7 +4,7 @@ import { showLine } from "../../utils/showLine"; import { html, svg } from "lit"; import { styleLine } from "../../utils/styleLine"; import { type Flows } from "./index"; -import { checkHasRightIndividual } from "../../utils/computeIndividualPosition"; +import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition"; type FlowBatteryToHomeFlows = Pick>; @@ -12,7 +12,7 @@ export const flowBatteryToHome = (config: PowerFlowCardPlusConfig, { battery, gr return battery.has && showLine(config, battery.state.toHome) ? html`
i?.has), "multi-individual": checkHasRightIndividual(config, individual), })}" diff --git a/src/components/flows/gridToHome.ts b/src/components/flows/gridToHome.ts index 122555b..99a9649 100644 --- a/src/components/flows/gridToHome.ts +++ b/src/components/flows/gridToHome.ts @@ -4,13 +4,13 @@ import { showLine } from "../../utils/showLine"; import { html, svg } from "lit"; import { styleLine } from "../../utils/styleLine"; import { type Flows } from "./index"; -import { checkHasRightIndividual } from "../../utils/computeIndividualPosition"; +import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition"; export const flowGridToHome = (config: PowerFlowCardPlusConfig, { battery, grid, individual, solar, newDur }: Flows) => { return grid.has && showLine(config, grid.state.fromGrid) ? html`
i?.has), "multi-individual": checkHasRightIndividual(config, individual), })}" diff --git a/src/components/flows/solarToBattery.ts b/src/components/flows/solarToBattery.ts index 4a421dd..f236d70 100644 --- a/src/components/flows/solarToBattery.ts +++ b/src/components/flows/solarToBattery.ts @@ -4,7 +4,7 @@ import { showLine } from "../../utils/showLine"; import { html, svg } from "lit"; import { styleLine } from "../../utils/styleLine"; import { type Flows } from "./index"; -import { checkHasRightIndividual } from "../../utils/computeIndividualPosition"; +import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition"; type FlowSolarToBatteryFlows = Pick>; @@ -12,7 +12,7 @@ export const flowSolarToBattery = (config: PowerFlowCardPlusConfig, { battery, i return battery.has && solar.has && showLine(config, solar.state.toBattery || 0) ? html`
i?.has), "multi-individual": checkHasRightIndividual(config, individual), })}" diff --git a/src/components/flows/solarToGrid.ts b/src/components/flows/solarToGrid.ts index 60b1784..68cdb44 100644 --- a/src/components/flows/solarToGrid.ts +++ b/src/components/flows/solarToGrid.ts @@ -4,13 +4,13 @@ import { showLine } from "../../utils/showLine"; import { html, svg } from "lit"; import { styleLine } from "../../utils/styleLine"; import { type Flows } from "./index"; -import { checkHasRightIndividual } from "../../utils/computeIndividualPosition"; +import { checkHasBottomIndividual, checkHasRightIndividual } from "../../utils/computeIndividualPosition"; export const flowSolarToGrid = (config: PowerFlowCardPlusConfig, { battery, grid, individual, solar, newDur }: Flows) => { return grid.hasReturnToGrid && solar.has && showLine(config, solar.state.toGrid || 0) ? html`
i?.has), "multi-individual": checkHasRightIndividual(config, individual), })}" diff --git a/src/utils/computeIndividualPosition.ts b/src/utils/computeIndividualPosition.ts index 1106752..650cc72 100644 --- a/src/utils/computeIndividualPosition.ts +++ b/src/utils/computeIndividualPosition.ts @@ -60,4 +60,4 @@ export const checkHasRightIndividual = (config: PowerFlowCardPlusConfig, individ !!getTopRightIndividual(config, individualObjs) || !!getBottomRightIndividual(config, individualObjs); export const checkHasBottomIndividual = (config: PowerFlowCardPlusConfig, individualObjs: IndividualObject[]): boolean => - !!getBottomLeftIndividual(config, individualObjs) || !!getBottomRightIndividual(config, individualObjs); + !!getBottomLeftIndividual(config, individualObjs) || !!getBottomRightIndividual(config, individualObjs); \ No newline at end of file