API: generate /api/state documentation from UI types (#32431)
Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
parent
c7c744f54e
commit
c3f3384bfc
44 changed files with 8757 additions and 3347 deletions
|
|
@ -38,9 +38,7 @@ import formatter from "@/mixins/formatter";
|
|||
import minuteTicker from "@/mixins/minuteTicker";
|
||||
import { optionStep, fmtEnergy } from "@/utils/energyOptions.ts";
|
||||
import { defineComponent, type PropType } from "vue";
|
||||
import type { CURRENCY, Vehicle } from "@/types/evcc";
|
||||
import type { PlanStrategy } from "./types";
|
||||
import type { Forecast } from "@/types/evcc.ts";
|
||||
import type { CURRENCY, Forecast, PlanStrategy, Vehicle } from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ChargingPlan",
|
||||
|
|
|
|||
|
|
@ -47,13 +47,17 @@ import GenericModal from "../Helper/GenericModal.vue";
|
|||
import PlansSettings from "./PlansSettings.vue";
|
||||
import api from "@/api";
|
||||
import type {
|
||||
CURRENCY,
|
||||
Forecast,
|
||||
PlanStrategy,
|
||||
RepeatingPlan,
|
||||
SMART_COST_TYPE,
|
||||
StaticEnergyPlan,
|
||||
StaticPlan,
|
||||
StaticSocPlan,
|
||||
} from "./types";
|
||||
import type { CURRENCY, Forecast, SMART_COST_TYPE, UiLoadpoint, Vehicle } from "@/types/evcc";
|
||||
UiLoadpoint,
|
||||
Vehicle,
|
||||
} from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ChargingPlanModal",
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import formatter from "@/mixins/formatter";
|
||||
import type { PlanStrategy } from "./types";
|
||||
import type { PlanStrategy } from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ChargingPlanStrategy",
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import PlanRepeatingSettings from "./PlanRepeatingSettings.vue";
|
|||
import deepEqual from "@/utils/deepEqual";
|
||||
import formatter from "@/mixins/formatter";
|
||||
import { defineComponent, type PropType } from "vue";
|
||||
import type { RepeatingPlan } from "./types";
|
||||
import type { RepeatingPlan } from "@/types/evcc";
|
||||
|
||||
const DEFAULT_WEEKDAYS = [1, 2, 3, 4, 5];
|
||||
const DEFAULT_TARGET_TIME = "07:00";
|
||||
|
|
|
|||
|
|
@ -81,16 +81,18 @@ import api from "@/api";
|
|||
import deepEqual from "@/utils/deepEqual";
|
||||
import { debounceLeading } from "@/utils/debounceLeading";
|
||||
import { defineComponent, type PropType } from "vue";
|
||||
import type { Vehicle, CURRENCY, Forecast } from "@/types/evcc";
|
||||
import type {
|
||||
StaticPlan,
|
||||
RepeatingPlan,
|
||||
PlanWrapper,
|
||||
StaticSocPlan,
|
||||
StaticEnergyPlan,
|
||||
CURRENCY,
|
||||
Forecast,
|
||||
PlanResponse,
|
||||
PlanStrategy,
|
||||
} from "./types";
|
||||
PlanWrapper,
|
||||
RepeatingPlan,
|
||||
StaticEnergyPlan,
|
||||
StaticPlan,
|
||||
StaticSocPlan,
|
||||
Vehicle,
|
||||
} from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ChargingPlansSettings",
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent, type PropType } from "vue";
|
||||
import formatter from "@/mixins/formatter";
|
||||
import type { PlanWrapper } from "./types";
|
||||
import type { Tariff } from "@/types/evcc";
|
||||
import type { PlanWrapper, Tariff } from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ChargingPlanWarnings",
|
||||
|
|
|
|||
39
assets/js/components/ChargingPlans/types.d.ts
vendored
39
assets/js/components/ChargingPlans/types.d.ts
vendored
|
|
@ -1,39 +0,0 @@
|
|||
import type { Rate } from "@/types/evcc";
|
||||
|
||||
export interface RepeatingPlan {
|
||||
weekdays: number[];
|
||||
time: string;
|
||||
tz: string; // timezone like "Europe/Berlin"
|
||||
soc: number;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export interface PlanWrapper {
|
||||
planId: number;
|
||||
planTime: Date;
|
||||
duration: number;
|
||||
plan: Rate[] | null;
|
||||
power: number;
|
||||
}
|
||||
|
||||
export interface PlanResponse {
|
||||
status: number;
|
||||
data: PlanWrapper;
|
||||
}
|
||||
|
||||
export type StaticPlan = StaticSocPlan | StaticEnergyPlan;
|
||||
|
||||
export interface StaticSocPlan {
|
||||
soc: number;
|
||||
time: Date;
|
||||
}
|
||||
|
||||
export interface StaticEnergyPlan {
|
||||
energy: number;
|
||||
time: Date;
|
||||
}
|
||||
|
||||
export interface PlanStrategy {
|
||||
continuous: boolean;
|
||||
precondition: number;
|
||||
}
|
||||
|
|
@ -42,9 +42,8 @@ import "chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm";
|
|||
import { registerChartComponents, commonOptions } from "../Sessions/chartConfig";
|
||||
import formatter, { POWER_UNIT } from "@/mixins/formatter";
|
||||
import colors, { lighterColor } from "@/colors";
|
||||
import type { CURRENCY } from "@/types/evcc";
|
||||
import type { CURRENCY, ForecastSlot, SolarDetails, TimeseriesEntry } from "@/types/evcc";
|
||||
import { ForecastType, highestSlotIndexByDay } from "@/utils/forecast";
|
||||
import type { ForecastSlot, SolarDetails, TimeseriesEntry } from "./types";
|
||||
|
||||
registerChartComponents([
|
||||
BarController,
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent, type PropType } from "vue";
|
||||
import formatter from "@/mixins/formatter";
|
||||
import type { CURRENCY } from "@/types/evcc";
|
||||
import type { ForecastSlot } from "./types";
|
||||
import type { CURRENCY, ForecastSlot } from "@/types/evcc";
|
||||
import { isStaticTariff } from "@/utils/forecast";
|
||||
|
||||
const MAX_HOURS = 96;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ import {
|
|||
import colors, { lighterColor } from "@/colors";
|
||||
import formatter from "@/mixins/formatter";
|
||||
import chartMixin from "./chartMixin";
|
||||
import type { CURRENCY } from "@/types/evcc";
|
||||
import type { ForecastSlot } from "./types";
|
||||
import type { CURRENCY, ForecastSlot } from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "PriceChart",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import colors, { lighterColor } from "@/colors";
|
|||
import formatter, { POWER_UNIT } from "@/mixins/formatter";
|
||||
import chartMixin from "./chartMixin";
|
||||
import { highestSlotIndexByDay } from "@/utils/forecast";
|
||||
import type { SolarDetails, TimeseriesEntry } from "./types";
|
||||
import type { SolarDetails, TimeseriesEntry } from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "SolarChart",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent, type PropType } from "vue";
|
||||
import formatter, { POWER_UNIT } from "@/mixins/formatter";
|
||||
import type { SolarDetails } from "./types";
|
||||
import type { SolarDetails } from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "SolarDetails",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import {
|
|||
import colors from "@/colors";
|
||||
import formatter from "@/mixins/formatter";
|
||||
import chartMixin from "./chartMixin";
|
||||
import type { ForecastSlot } from "./types";
|
||||
import type { ForecastSlot } from "@/types/evcc";
|
||||
|
||||
export type ValueChartType = "co2" | "temperature";
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent, type PropType } from "vue";
|
||||
import formatter from "@/mixins/formatter";
|
||||
import type { ForecastSlot } from "./types";
|
||||
import type { ForecastSlot } from "@/types/evcc";
|
||||
import type { ValueChartType } from "./ValueChart.vue";
|
||||
|
||||
const MAX_HOURS = 96;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as echarts from "echarts/core";
|
||||
import colors from "@/colors";
|
||||
import escapeHtml from "@/utils/escapeHtml";
|
||||
import type { ForecastSlot } from "./types";
|
||||
import type { ForecastSlot } from "@/types/evcc";
|
||||
import { BarChart, LineChart } from "echarts/charts";
|
||||
import {
|
||||
GridComponent,
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
export function isForecastSlot(obj?: TimeseriesEntry | ForecastSlot): obj is ForecastSlot {
|
||||
return (obj as ForecastSlot).start !== undefined;
|
||||
}
|
||||
|
||||
export interface TimeseriesEntry {
|
||||
val: number;
|
||||
ts: string;
|
||||
}
|
||||
|
||||
export interface ForecastSlot {
|
||||
start: string;
|
||||
end: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface EnergyByDay {
|
||||
energy: number;
|
||||
complete: boolean;
|
||||
}
|
||||
|
||||
export interface SolarDetails {
|
||||
scale?: number;
|
||||
today?: EnergyByDay;
|
||||
tomorrow?: EnergyByDay;
|
||||
dayAfterTomorrow?: EnergyByDay;
|
||||
timeseries?: TimeseriesEntry[];
|
||||
}
|
||||
|
|
@ -129,9 +129,9 @@ import type {
|
|||
SMART_COST_TYPE,
|
||||
BATTERY_MODE,
|
||||
LoadpointUi,
|
||||
PlanStrategy,
|
||||
LoadpointSuggestion,
|
||||
} from "@/types/evcc";
|
||||
import type { PlanStrategy } from "@/components/ChargingPlans/types";
|
||||
|
||||
export default defineComponent({
|
||||
name: "Loadpoint",
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ import { defineComponent, type PropType } from "vue";
|
|||
import api from "@/api";
|
||||
import { setLoadpointLastSmartCostLimit } from "@/uiLoadpoints";
|
||||
import settings from "@/settings";
|
||||
import { type CURRENCY, SMART_COST_TYPE } from "@/types/evcc";
|
||||
import { type ForecastSlot } from "../Forecast/types";
|
||||
import { type CURRENCY, type ForecastSlot, SMART_COST_TYPE } from "@/types/evcc";
|
||||
|
||||
export default defineComponent({
|
||||
name: "SmartCostLimit",
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export default defineComponent({
|
|||
},
|
||||
vehicleOptions(): SelectOption<string>[] {
|
||||
return this.vehicles.map((v) => ({
|
||||
name: v.name,
|
||||
name: v.name ?? "",
|
||||
value: v.title,
|
||||
}));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@ import {
|
|||
type VehicleStatus,
|
||||
type Vehicle,
|
||||
type LoadpointUi,
|
||||
type PlanStrategy,
|
||||
type LoadpointSuggestion,
|
||||
} from "@/types/evcc";
|
||||
import type { PlanStrategy } from "@/components/ChargingPlans/types";
|
||||
import BatteryBoostButton from "../Loadpoints/BatteryBoostButton.vue";
|
||||
import type ChargingPlanModal from "../ChargingPlans/ChargingPlanModal.vue";
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
import type { ForecastSlot, TimeseriesEntry, SolarDetails } from "../components/Forecast/types";
|
||||
import type { ForecastSlot, TimeseriesEntry, SolarDetails } from "@/types/evcc";
|
||||
import deepCopy from "./deepClone";
|
||||
|
||||
export enum ForecastType {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue