feat(history): add energy price history feature

This commit is contained in:
2026-08-02 11:29:58 +02:00
parent 1511de31a8
commit f70f3ab054
20 changed files with 262 additions and 52 deletions
+20 -2
View File
@@ -1,5 +1,23 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue';
import useHistoryViewModel from '../viewmodels/HistoryViewModel';
import moment from 'moment';
const model = useHistoryViewModel();
const date = ref<Date>();
onMounted(() => {
model.getHistoryData(moment().format('YYYY-MM-DD'));
});
watch(date, (value) => {
model.getHistoryData(moment(value).format('YYYY-MM-DD'));
});
</script>
<template>
<div></div>
<div>
<input type="date" v-model="date" />
</div>
</template>
@@ -0,0 +1,26 @@
import { create } from 'axios';
import { ref } from 'vue';
import HistoryData = App.Features.History.Data.HistoryData;
export default function useHistoryViewModel() {
const isLoading = ref<boolean>(false);
const historyData = ref<HistoryData>();
function getHistoryData(date: string) {
isLoading.value = true;
const client = create();
client
.get<HistoryData>('/api/history', {
params: {
date,
},
})
.then((res) => {
historyData.value = res.data;
})
.finally(() => (isLoading.value = false));
}
return { isLoading, historyData, getHistoryData };
}
+43 -28
View File
@@ -1,38 +1,53 @@
declare namespace App {
namespace Data {
export type ElectricityData = {
startDate: string;
endDate: string;
period: string;
marketPrice: number | null;
totalPriceTaxIncluded: number | null;
priceInclHandlingVat: number | null;
priceTaxWithVat: number | null;
pricingProfile: string | null;
carbonFootprintInGram: number | null;
sustainabilityScore: number | null;
startDateDatetime: string;
};
export type GasData = {
startDate: string;
endDate: string;
period: string;
marketPrice: number;
totalPriceTaxIncluded: number;
priceInclHandlingVat: number;
priceTaxWithVat: number;
startDateDatetime: string;
};
}
namespace Features {
namespace Dashboard {
namespace Data {
export type DashboardData = {
electricity: App.Features.Dashboard.Data.ElectricityData;
electricityCheapest: App.Features.Dashboard.Data.ElectricityData | null;
electricityDurable: App.Features.Dashboard.Data.ElectricityData | null;
electricityPriciest: App.Features.Dashboard.Data.ElectricityData | null;
gas: App.Features.Dashboard.Data.GasData;
gasCheapest: App.Features.Dashboard.Data.GasData | null;
gasPriciest: App.Features.Dashboard.Data.GasData | null;
electricity: App.Data.ElectricityData;
electricityCheapest: App.Data.ElectricityData | null;
electricityDurable: App.Data.ElectricityData | null;
electricityPriciest: App.Data.ElectricityData | null;
gas: App.Data.GasData;
gasCheapest: App.Data.GasData | null;
gasPriciest: App.Data.GasData | null;
};
export type ElectricityData = {
startDate: string;
endDate: string;
period: string;
marketPrice: number | null;
totalPriceTaxIncluded: number | null;
priceInclHandlingVat: number | null;
priceTaxWithVat: number | null;
pricingProfile: string | null;
carbonFootprintInGram: number | null;
sustainabilityScore: number | null;
startDateDatetime: string;
}
}
namespace History {
namespace Data {
export type HistoryData = {
electricity: Array<any>;
gas: Array<any>;
};
export type GasData = {
startDate: string;
endDate: string;
period: string;
marketPrice: number;
totalPriceTaxIncluded: number;
priceInclHandlingVat: number;
priceTaxWithVat: number;
startDateDatetime: string;
}
namespace Requests {
export type HistoryRequest = {
date: string | null;
};
}
}
@@ -1,3 +1,3 @@
{
"generated.d.ts": "f593095f6f419a96a4c39c2b93719f9a"
"generated.d.ts": "7ca8a9c7f0ae5e5498bdee87bb2f005d"
}