From 9eb5e33652a213cef74d1a81c6763cd6a347cd12 Mon Sep 17 00:00:00 2001 From: Maschga <88616799+Maschga@users.noreply.github.com> Date: Mon, 31 Mar 2025 18:39:19 +0200 Subject: [PATCH] chore: typescript, rewrite charging plans (#20036) Co-authored-by: Michael Geers --- .../js/components/ChargingPlans/Arrival.vue | 24 +-- .../ChargingPlans/ChargingPlan.stories.js | 55 ------ .../ChargingPlans/ChargingPlan.stories.ts | 56 ++++++ .../components/ChargingPlans/ChargingPlan.vue | 137 ++++++++------- .../ChargingPlans/PlanRepeatingSettings.vue | 46 ++--- .../ChargingPlans/PlanStaticSettings.vue | 38 +++-- .../ChargingPlans/PlansRepeatingSettings.vue | 23 +-- .../ChargingPlans/PlansSettings.vue | 159 ++++++++++-------- .../ChargingPlans/Preview.stories.js | 114 ------------- .../ChargingPlans/Preview.stories.ts | 117 +++++++++++++ .../components/ChargingPlans/Preview.test.js | 136 --------------- .../components/ChargingPlans/Preview.test.ts | 140 +++++++++++++++ .../js/components/ChargingPlans/Preview.vue | 63 +++---- .../js/components/ChargingPlans/Warnings.vue | 52 +++--- assets/js/components/ChargingPlans/types.d.ts | 45 +++++ assets/js/components/Forecast/Details.vue | 4 +- assets/js/components/Helper/CustomSelect.vue | 15 +- assets/js/components/Tariff/TariffChart.vue | 4 +- assets/js/mixins/formatter.ts | 13 +- assets/js/store.ts | 1 + assets/js/types/evcc.ts | 52 +++++- assets/js/types/vue.d.ts | 1 + eslint.config.mjs | 11 +- package-lock.json | 10 ++ package.json | 4 +- 25 files changed, 743 insertions(+), 577 deletions(-) delete mode 100644 assets/js/components/ChargingPlans/ChargingPlan.stories.js create mode 100644 assets/js/components/ChargingPlans/ChargingPlan.stories.ts delete mode 100644 assets/js/components/ChargingPlans/Preview.stories.js create mode 100644 assets/js/components/ChargingPlans/Preview.stories.ts delete mode 100644 assets/js/components/ChargingPlans/Preview.test.js create mode 100644 assets/js/components/ChargingPlans/Preview.test.ts create mode 100644 assets/js/components/ChargingPlans/types.d.ts diff --git a/assets/js/components/ChargingPlans/Arrival.vue b/assets/js/components/ChargingPlans/Arrival.vue index 549f9a163..82cfe338e 100644 --- a/assets/js/components/ChargingPlans/Arrival.vue +++ b/assets/js/components/ChargingPlans/Arrival.vue @@ -59,11 +59,13 @@ - diff --git a/assets/js/components/ChargingPlans/ChargingPlan.stories.js b/assets/js/components/ChargingPlans/ChargingPlan.stories.js deleted file mode 100644 index ed5452e8f..000000000 --- a/assets/js/components/ChargingPlans/ChargingPlan.stories.js +++ /dev/null @@ -1,55 +0,0 @@ -import ChargingPlan from "./ChargingPlan.vue"; - -const hoursFromNow = (hours) => { - const now = new Date(); - now.setHours(now.getHours() + hours); - return now.toISOString(); -}; - -export default { - title: "ChargingPlans/ChargingPlan", - component: ChargingPlan, - parameters: { - layout: "centered", - }, - argTypes: { - id: { control: "text" }, - effectivePlanTime: { control: "text" }, - effectivePlanSoc: { control: "number" }, - planEnergy: { control: "number" }, - socBasedCharging: { control: "boolean" }, - socBasedPlanning: { control: "boolean" }, - vehicleSoc: { control: "number" }, - }, -}; - -const Template = (args) => ({ - components: { ChargingPlan }, - setup() { - return { args }; - }, - template: '', -}); - -export const None = Template.bind({}); -None.args = { - id: "1", -}; - -export const SocBasedCharging = Template.bind({}); -SocBasedCharging.args = { - id: "1", - effectivePlanTime: hoursFromNow(4), - effectivePlanSoc: 77, - socBasedCharging: true, - socBasedPlanning: true, -}; - -export const EnergyBasedCharging = Template.bind({}); -EnergyBasedCharging.args = { - id: "1", - effectivePlanTime: hoursFromNow(12), - planEnergy: 77, - socBasedCharging: false, - socBasedPlanning: false, -}; diff --git a/assets/js/components/ChargingPlans/ChargingPlan.stories.ts b/assets/js/components/ChargingPlans/ChargingPlan.stories.ts new file mode 100644 index 000000000..945d57676 --- /dev/null +++ b/assets/js/components/ChargingPlans/ChargingPlan.stories.ts @@ -0,0 +1,56 @@ +import ChargingPlan from "./ChargingPlan.vue"; +import type { Meta, StoryFn } from "@storybook/vue3"; + +const hoursFromNow = (hours: number) => { + const now = new Date(); + now.setHours(now.getHours() + hours); + return now.toISOString(); +}; + +export default { + title: "ChargingPlans/ChargingPlan", + component: ChargingPlan, + parameters: { + layout: "centered", + }, + argTypes: { + id: { control: "text" }, + effectivePlanTime: { control: "text" }, + effectivePlanSoc: { control: "number" }, + planEnergy: { control: "number" }, + socBasedCharging: { control: "boolean" }, + socBasedPlanning: { control: "boolean" }, + vehicleSoc: { control: "number" }, + }, +} as Meta; + +const Template: StoryFn = (args) => ({ + components: { ChargingPlan }, + setup() { + return { args }; + }, + template: '', +}); + +export const None = Template.bind({}); +None.args = { + id: "1", +}; + +export const SocBasedCharging = Template.bind({}); +SocBasedCharging.args = { + id: "1", + effectivePlanTime: hoursFromNow(4), + effectivePlanSoc: 77, + socBasedCharging: true, + socBasedPlanning: true, +}; + +export const EnergyBasedCharging = Template.bind({}); +EnergyBasedCharging.args = { + id: "1", + effectivePlanTime: hoursFromNow(12), + planEnergy: 77, + socBasedCharging: false, + socBasedPlanning: false, +}; diff --git a/assets/js/components/ChargingPlans/ChargingPlan.vue b/assets/js/components/ChargingPlans/ChargingPlan.vue index b6cd3f5f9..579b53eff 100644 --- a/assets/js/components/ChargingPlans/ChargingPlan.vue +++ b/assets/js/components/ChargingPlans/ChargingPlan.vue @@ -102,7 +102,7 @@ -