Planner: show planned slots without tariff (#7833)
This commit is contained in:
parent
e4e91fd652
commit
1e6da3670a
4 changed files with 20 additions and 13 deletions
|
|
@ -128,7 +128,7 @@ export default {
|
|||
timeTooFarInTheFuture: function () {
|
||||
if (this.tariff?.rates) {
|
||||
const lastRate = this.tariff.rates[this.tariff.rates.length - 1];
|
||||
if (lastRate.end) {
|
||||
if (lastRate?.end) {
|
||||
const end = new Date(lastRate.end);
|
||||
return this.selectedTargetTime >= end;
|
||||
}
|
||||
|
|
@ -201,13 +201,18 @@ export default {
|
|||
!isNaN(this.selectedTargetTime)
|
||||
) {
|
||||
try {
|
||||
const opts = {
|
||||
params: { targetTime: this.selectedTargetTime },
|
||||
};
|
||||
this.plan = (
|
||||
await api.get(`loadpoints/${this.id}/target/plan`, opts)
|
||||
await api.get(`loadpoints/${this.id}/target/plan`, {
|
||||
params: { targetTime: this.selectedTargetTime },
|
||||
})
|
||||
).data.result;
|
||||
this.tariff = (await api.get(`tariff/planner`)).data.result;
|
||||
|
||||
const tariffRes = await api.get(`tariff/planner`, {
|
||||
validateStatus: function (status) {
|
||||
return status >= 200 && status < 500;
|
||||
},
|
||||
});
|
||||
this.tariff = tariffRes.status === 404 ? { rates: [] } : tariffRes.data.result;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<div class="label">{{ $t("main.targetChargePlan.chargeDuration") }}</div>
|
||||
<div class="value text-primary">{{ planDuration }}</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<div v-if="hasTariff" class="text-end">
|
||||
<div class="label">
|
||||
<span v-if="activeSlot">{{ activeSlotName }}</span>
|
||||
<span v-else-if="isCo2">{{ $t("main.targetChargePlan.co2Label") }}</span>
|
||||
|
|
@ -46,6 +46,9 @@ export default {
|
|||
isCo2() {
|
||||
return this.unit === CO2_UNIT;
|
||||
},
|
||||
hasTariff() {
|
||||
return this.rates?.length > 1;
|
||||
},
|
||||
avgPrice() {
|
||||
let hourSum = 0;
|
||||
let priceSum = 0;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
@click="selectSlot(index)"
|
||||
>
|
||||
<div class="slot-bar" :style="priceStyle(slot.price)">
|
||||
<span v-if="slot.price === undefined" class="unknown">?</span>
|
||||
<span v-if="slot.price === undefined && avgPrice" class="unknown">?</span>
|
||||
</div>
|
||||
<div class="slot-label">
|
||||
{{ slot.startHour }}
|
||||
|
|
@ -89,9 +89,8 @@ export default {
|
|||
},
|
||||
priceStyle(price) {
|
||||
const value = price === undefined ? this.avgPrice : price;
|
||||
return {
|
||||
height: `${(100 / this.maxPrice) * value}%`,
|
||||
};
|
||||
const height = value ? `${(100 / this.maxPrice) * value}%` : "100%";
|
||||
return { height };
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -190,13 +190,13 @@ func tariffHandler(site site.API) http.HandlerFunc {
|
|||
|
||||
t := site.GetTariff(tariff)
|
||||
if t == nil {
|
||||
jsonError(w, http.StatusBadRequest, errors.New("tariff not available"))
|
||||
jsonError(w, http.StatusNotFound, errors.New("tariff not available"))
|
||||
return
|
||||
}
|
||||
|
||||
rates, err := t.Rates()
|
||||
if err != nil {
|
||||
jsonError(w, http.StatusBadRequest, err)
|
||||
jsonError(w, http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue