diff --git a/assets/js/components/HelpModal.vue b/assets/js/components/HelpModal.vue index d649bb9b9..64fe1e185 100644 --- a/assets/js/components/HelpModal.vue +++ b/assets/js/components/HelpModal.vue @@ -136,13 +136,14 @@ - diff --git a/assets/js/components/Helper/SelectGroup.vue b/assets/js/components/Helper/SelectGroup.vue index c3d796a06..0b7f26c16 100644 --- a/assets/js/components/Helper/SelectGroup.vue +++ b/assets/js/components/Helper/SelectGroup.vue @@ -26,7 +26,7 @@ export default defineComponent({ props: { id: String, options: Array as PropType[]>, - modelValue: [Number, String, Boolean], + modelValue: [Number, String, Boolean, null], equalWidth: Boolean, large: Boolean, transparent: Boolean, diff --git a/assets/js/components/Loadpoints/SessionInfo.vue b/assets/js/components/Loadpoints/SessionInfo.vue index 5d6ac39c2..7d9bf301c 100644 --- a/assets/js/components/Loadpoints/SessionInfo.vue +++ b/assets/js/components/Loadpoints/SessionInfo.vue @@ -32,7 +32,7 @@ import LabelAndValue from "../Helper/LabelAndValue.vue"; import CustomSelect from "../Helper/CustomSelect.vue"; import formatter from "@/mixins/formatter"; import { getSessionInfo, setSessionInfo } from "./session"; -import type { CURRENCY, SelectOption } from "@/types/evcc"; +import type { CURRENCY, SelectOption, SessionInfoKey } from "@/types/evcc"; export default defineComponent({ name: "LoadpointSessionInfo", @@ -59,39 +59,44 @@ export default defineComponent({ }; }, computed: { - options() { + options(): Array<{ + key: SessionInfoKey; + value: string; + valueSm?: string; + available?: boolean; + }> { const result = [ { - key: "remaining", + key: "remaining" as const, value: this.fmtDuration(this.chargeRemainingDurationInterpolated), available: this.chargeRemainingDurationInterpolated > 0, }, { - key: "finished", + key: "finished" as const, value: this.fmtHourMinute(this.finishTime), available: this.chargeRemainingDurationInterpolated > 0, }, { - key: "duration", + key: "duration" as const, value: this.fmtDuration(this.chargeDurationInterpolated), }, { - key: "solar", + key: "solar" as const, value: this.solarFormatted, }, { - key: "avgPrice", + key: "avgPrice" as const, value: this.fmtAvgPrice(this.sessionPricePerKWh), valueSm: this.fmtAvgPriceShort(this.sessionPricePerKWh), available: this.tariffGrid !== undefined, }, { - key: "price", + key: "price" as const, value: this.priceFormatted, available: this.tariffGrid !== undefined, }, { - key: "co2", + key: "co2" as const, value: this.fmtCo2Medium(this.sessionCo2PerKWh), valueSm: this.fmtCo2Short(this.sessionCo2PerKWh), available: this.tariffCo2 !== undefined, @@ -100,10 +105,10 @@ export default defineComponent({ // only show options that are available return result.filter(({ available }) => available === undefined || available); }, - optionKeys() { + optionKeys(): SessionInfoKey[] { return this.options.map((option) => option.key); }, - selectOptions(): SelectOption[] { + selectOptions(): SelectOption[] { return this.optionKeys.map((key) => ({ name: this.$t(`main.loadpoint.${key}`), value: key, @@ -151,16 +156,18 @@ export default defineComponent({ return this.fmtPricePerKWh(value, this.currency, true); }, nextSessionInfo() { - const index = this.optionKeys.indexOf(this.selectedKey); + const index = this.selectedKey ? this.optionKeys.indexOf(this.selectedKey) : -1; this.selectedKey = this.optionKeys[index + 1] || this.optionKeys[0]; this.presist(); }, - selectOption(value: string) { + selectOption(value: SessionInfoKey) { this.selectedKey = value; this.presist(); }, presist() { - setSessionInfo(this.id, this.selectedKey); + if (this.selectedKey) { + setSessionInfo(this.id, this.selectedKey); + } }, }, }); diff --git a/assets/js/components/Loadpoints/session.ts b/assets/js/components/Loadpoints/session.ts index 29aafa900..56a56da68 100644 --- a/assets/js/components/Loadpoints/session.ts +++ b/assets/js/components/Loadpoints/session.ts @@ -1,10 +1,11 @@ import settings from "@/settings"; +import type { SessionInfoKey } from "@/types/evcc"; -export function getSessionInfo(index: number, fallback?: string) { - return settings.sessionInfo[index - 1] || fallback; +export function getSessionInfo(index: number): SessionInfoKey | undefined { + return settings.sessionInfo[index - 1]; } -export function setSessionInfo(index: number, value: string) { +export function setSessionInfo(index: number, value: SessionInfoKey) { const clone = [...settings.sessionInfo]; clone[index - 1] = value; clone.map((v) => v || ""); diff --git a/assets/js/components/Savings/Savings.vue b/assets/js/components/Savings/Savings.vue index 17db3a73a..0cecbde66 100644 --- a/assets/js/components/Savings/Savings.vue +++ b/assets/js/components/Savings/Savings.vue @@ -209,7 +209,7 @@ import Tile from "./Tile.vue"; import LiveCommunity from "./LiveCommunity.vue"; import TelemetrySettings from "../TelemetrySettings.vue"; import CustomSelect from "../Helper/CustomSelect.vue"; -import settings from "@/settings"; +import settings from "@/settings.ts"; import api, { allowClientError } from "@/api.ts"; import { docsPrefix } from "@/i18n.ts"; import { defineComponent, type PropType } from "vue"; diff --git a/assets/js/components/Sessions/SessionTable.vue b/assets/js/components/Sessions/SessionTable.vue index f6da566eb..e05577fe5 100644 --- a/assets/js/components/Sessions/SessionTable.vue +++ b/assets/js/components/Sessions/SessionTable.vue @@ -161,7 +161,7 @@ import { defineComponent, type PropType } from "vue"; import CustomSelect from "../Helper/CustomSelect.vue"; import formatter, { POWER_UNIT } from "@/mixins/formatter"; import breakpoint from "@/mixins/breakpoint.ts"; -import settings from "@/settings"; +import settings from "@/settings.ts"; import type { CURRENCY } from "@/types/evcc"; import type { Session, Column } from "./types"; @@ -187,7 +187,7 @@ export default defineComponent({ emits: ["show-session"], data() { return { - selectedColumns: settings.sessionColumns, + selectedColumns: [] as string[], }; }, computed: { @@ -417,7 +417,7 @@ export default defineComponent({ .filter(this.filterByVehicle) .filter((s) => !loadpoint || s.loadpoint === loadpoint).length; }, - selectColumnPosition(index: number, value: Column) { + selectColumnPosition(index: number, value: string) { this.selectedColumns[index] = value; settings.sessionColumns = [...this.selectedColumns]; }, diff --git a/assets/js/components/TelemetrySettings.vue b/assets/js/components/TelemetrySettings.vue index a973ea606..e54980db9 100644 --- a/assets/js/components/TelemetrySettings.vue +++ b/assets/js/components/TelemetrySettings.vue @@ -30,12 +30,14 @@ -