Skip to content

Commit 01ad28e

Browse files
cshagenLKuemmel
authored andcommitted
Colors theme fixes & Soc-Editor (openWB#2230)
* fix chargepoint display and usage graph * fix powergraph axis and soc display * add soc editor to vehicle list
1 parent 4dcb5d4 commit 01ad28e

14 files changed

Lines changed: 145 additions & 68 deletions

File tree

packages/modules/web_themes/colors/source/src/components/chargePointList/CPChargePoint.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@
235235
).toFixed(1) + ' ct'
236236
: '-'
237237
}}
238-
239238
<i
240239
v-if="props.chargepoint.etActive"
241240
class="fa-solid fa-sm fas fa-edit ms-2"

packages/modules/web_themes/colors/source/src/components/chargePointList/cpSimpleList/CpsListItem2.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const statusColor = computed(() => {
170170
const modeStyle = computed(() => {
171171
switch (props.chargepoint.chargeMode) {
172172
case 'stop':
173-
return { 'background-color': 'var(--fg)' }
173+
return { 'background-color': 'var(--color-input)' }
174174
default:
175175
return {
176176
'background-color': chargemodes[props.chargepoint.chargeMode].color,

packages/modules/web_themes/colors/source/src/components/chargePointList/model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ export class Vehicle {
274274
this.id = index
275275
}
276276
private _chargeTemplateId = 0
277+
isSocConfigured = false
278+
isSocManual = false
277279
get chargeTemplateId() {
278280
return this._chargeTemplateId
279281
}

packages/modules/web_themes/colors/source/src/components/chargePointList/processMessages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ export function processVehicleMessages(topic: string, message: string) {
173173
cp.isSocManual = config.type == 'manual'
174174
}
175175
})
176+
vehicles[index].isSocConfigured = config.type !== null
177+
vehicles[index].isSocManual = config.type == 'manual'
176178
} else {
177179
// console.warn('Ignored vehicle message [' + topic + ']=' + message)
178180
}

packages/modules/web_themes/colors/source/src/components/powerGraph/PgSoc.vue

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
<template>
22
<svg x="0" :width="props.width">
3-
<path
4-
:id="'soc-' + vID"
5-
.origin="autozoom"
6-
class="soc-baseline"
7-
:d="myline"
8-
stroke="var(--color-bg)"
9-
stroke-width="1"
10-
fill="none"
11-
/>
12-
<path
13-
:id="'socdashes-' + vID"
14-
class="soc-dashes"
15-
:d="myline"
16-
:stroke="cpColor"
17-
stroke-width="1"
18-
:style="{ strokeDasharray: '3,3' }"
19-
fill="none"
20-
/>
21-
<text
22-
class="cpname"
23-
:x="nameX"
24-
:y="nameY"
25-
:style="{ fill: cpColor, fontSize: 10 }"
26-
:text-anchor="textPosition"
27-
>
28-
{{ vName }}
29-
</text>
3+
<g>
4+
<path
5+
:id="'soc-' + vID"
6+
.origin="autozoom"
7+
class="soc-baseline"
8+
:d="myline"
9+
stroke="var(--color-bg)"
10+
stroke-width="1"
11+
fill="none"
12+
/>
13+
<path
14+
:id="'socdashes-' + vID"
15+
class="soc-dashes"
16+
:d="myline"
17+
:stroke="cpColor"
18+
stroke-width="1"
19+
:style="{ strokeDasharray: '3,3' }"
20+
fill="none"
21+
/>
22+
<text
23+
class="cpname"
24+
:x="nameX"
25+
:y="nameY"
26+
:style="{ fill: cpColor, fontSize: 10 }"
27+
:text-anchor="textPosition"
28+
>
29+
{{ vName }}
30+
</text>
31+
</g>
3032
</svg>
3133
</template>
3234

@@ -75,7 +77,6 @@ const myline = computed(() => {
7577
: d['soc' + topVehicles.value[1]!],
7678
) ?? yScale.value(0),
7779
)
78-
7980
let p = path(graphData.data)
8081
return p ? p : ''
8182
})
@@ -116,11 +117,11 @@ const cpColor = computed(() => {
116117
const nameX = computed(() => {
117118
switch (props.order) {
118119
case 0:
119-
return 3
120+
return 3 // first vehicle
120121
case 1:
121-
return props.width - 3
122+
return props.width - 3 // 2nd vehicle
122123
case 2:
123-
return props.width / 2
124+
return props.width / 2 // battery
124125
default:
125126
return 0 // error
126127
}
@@ -130,15 +131,16 @@ const nameY = computed(() => {
130131
if (graphData.data.length > 0) {
131132
let index: number
132133
switch (props.order) {
133-
case 0:
134-
index = graphData.data.length - 1
134+
case 0: // 1st vehicle
135+
index = 0
135136
return yScale.value(
136137
graphData.data[index]['soc' + topVehicles.value[0]] + 2,
137138
)
138139
case 1:
139-
index = 0
140-
return yScale.value(
141-
graphData.data[index]['soc' + topVehicles.value[1]] + 2,
140+
index = graphData.data.length - 1
141+
return Math.max(
142+
12,
143+
yScale.value(graphData.data[index]['soc' + topVehicles.value[1]] + 2),
142144
)
143145
case 2:
144146
index = Math.round(graphData.data.length / 2)

packages/modules/web_themes/colors/source/src/components/powerGraph/PgSourceGraph.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,17 @@ const keysToUse = computed(() => {
103103
if (globalConfig.showInverters) {
104104
const pattern = /pv\d+/
105105
if (graphData.data.length > 0) {
106-
additionalKeys = Object.keys(graphData.data[0]).reduce(
107-
(list: string[], element: string) => {
108-
if (element.match(pattern)) {
109-
list.push(element)
106+
/* additionalKeys = Object.keys(graphData.data[0]).reduce(
107+
(list: string[], itemKey: string) => {
108+
if (itemKey.match(pattern)) {
109+
list.push(itemKey)
110110
}
111111
return list
112112
},
113113
[],
114+
) */
115+
additionalKeys = Object.keys(graphData.data[0]).filter((itemKey) =>
116+
itemKey.match(pattern),
114117
)
115118
}
116119
}

packages/modules/web_themes/colors/source/src/components/powerGraph/PgUsageGraph.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,18 @@ const keysToUse = computed(() => {
141141
const pattern = /cp\d+/
142142
let additionalKeys: string[] = []
143143
if (graphData.data.length > 0) {
144-
additionalKeys = Object.keys(graphData.data[0]).reduce(
145-
(list: string[], element: string) => {
146-
if (element.match(pattern)) {
147-
list.push(element)
148-
}
149-
return list
150-
},
151-
[],
144+
additionalKeys = Object.keys(graphData.data[0]).filter((itemKey) =>
145+
itemKey.match(pattern),
152146
)
153147
}
154148
additionalKeys.forEach((key, i) => {
155149
k.splice(idx + i, 0, key)
156-
colors[key] = chargePoints[+key.slice(2)]?.color ?? 'black'
150+
colors[key] =
151+
chargePoints[+key.slice(2)]?.color ?? 'var(--color-charging)'
157152
})
158-
if (globalConfig.showInverters) {
153+
/* if (globalConfig.showInverters) {
159154
k.push('evuOut')
160-
}
155+
} */
161156
return k
162157
}
163158
})

packages/modules/web_themes/colors/source/src/components/powerGraph/PgXAxis.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:transform="'translate(' + 0 + ',' + (height / 2 + 9) + ')'"
66
></g>
77
</svg>
8-
<svg :x="props.margin.left" :width="props.width">
8+
<svg :x="0" :width="props.width">
99
<g :transform="'translate(' + margin.left + ',' + margin.top + ')'">
1010
<g
1111
id="PGXAxis"

packages/modules/web_themes/colors/source/src/components/powerGraph/PowerGraph.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
:stack-order="globalConfig.usageStackOrder"
5050
/>
5151
<PgXAxis
52-
:width="width - margin.left - 2 * margin.right"
52+
:width="width - margin.left - margin.right"
5353
:height="height - margin.top - margin.bottom"
5454
:margin="margin"
5555
/>

packages/modules/web_themes/colors/source/src/components/vehicleList/VlVehicle.vue

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,21 @@
1212
>
1313
</InfoItem>
1414
<InfoItem heading="Ladestand:" :small="true" class="grid-col-4">
15-
{{ Math.round(props.vehicle.soc) }} %
15+
<BatterySymbol :soc="soc ?? 0" color="var(--color-fg)" class="me-2" />
16+
<i
17+
v-if="vehicle.isSocManual"
18+
class="fa-solid fa-sm fas fa-edit"
19+
type="button"
20+
:style="{ color: 'var(--color-fg)' }"
21+
@click="editSoc = !editSoc"
22+
/>
23+
<i
24+
v-if="!vehicle.isSocManual"
25+
type="button"
26+
class="fa-solid fa-sm"
27+
:class="spinsymbol"
28+
@click="loadSoc"
29+
/>
1630
</InfoItem>
1731
<InfoItem
1832
heading="Reichweite:"
@@ -21,19 +35,46 @@
2135
>
2236
{{ Math.round(props.vehicle.range) }} km
2337
</InfoItem>
38+
<div
39+
v-if="editSoc"
40+
class="socEditor rounded mt-2 d-flex flex-column align-items-center grid-col-12 grid-left"
41+
>
42+
<span class="d-flex m-1 p-0 socEditTitle">Ladestand einstellen:</span>
43+
<span class="d-flex justify-content-stretch align-items-center">
44+
<span>
45+
<RangeInput
46+
id="manualSoc"
47+
v-model="manualSoc"
48+
:min="0"
49+
:max="100"
50+
:step="1"
51+
unit="%"
52+
/>
53+
</span>
54+
</span>
55+
<span
56+
type="button"
57+
class="fa-solid d-flex fa-lg me-2 mb-3 align-self-end fa-circle-check"
58+
@click="setSoc"
59+
/>
60+
</div>
2461
</div>
2562
</WbSubwidget>
2663
</template>
2764
<script setup lang="ts">
28-
import { computed } from 'vue'
65+
import { computed, ref } from 'vue'
66+
import { chargePoints } from '@/components/chargePointList/model'
2967
import InfoItem from '../shared/InfoItem.vue'
3068
import WbSubwidget from '../shared/WbSubwidget.vue'
69+
import BatterySymbol from '../shared/BatterySymbol.vue'
70+
import RangeInput from '../shared/RangeInput.vue'
3171
import type { Vehicle } from '@/components/chargePointList/model.ts'
72+
import { updateServer } from '@/assets/js/sendMessages'
3273
3374
const props = defineProps<{
3475
vehicle: Vehicle
3576
}>()
36-
77+
const editSoc = ref(false)
3778
const statusString = computed(() => {
3879
let result = 'Unterwegs'
3980
let cp = props.vehicle.chargepoint
@@ -46,7 +87,6 @@ const statusString = computed(() => {
4687
}
4788
return result
4889
})
49-
5090
const statusColor = computed(() => {
5191
let cp = props.vehicle.chargepoint
5292
if (cp != undefined) {
@@ -63,6 +103,36 @@ const statusColor = computed(() => {
63103
return 'var(--color-axis)'
64104
}
65105
})
106+
const soc = computed(() => {
107+
return props.vehicle.soc
108+
})
109+
function loadSoc() {
110+
if (props.vehicle.chargepoint != undefined) {
111+
updateServer('socUpdate', 1, props.vehicle.id)
112+
chargePoints[props.vehicle.chargepoint.id].waitingForSoc = true
113+
}
114+
}
115+
function setSoc() {
116+
updateServer('setSoc', manualSoc.value, props.vehicle.id)
117+
editSoc.value = false
118+
}
119+
const manualSoc = computed({
120+
get() {
121+
return props.vehicle.soc
122+
},
123+
set(s: number) {
124+
if (props.vehicle.chargepoint != undefined) {
125+
chargePoints[props.vehicle.chargepoint.id].soc = s
126+
}
127+
},
128+
})
129+
const spinsymbol = computed(() => {
130+
return props.vehicle.chargepoint
131+
? props.vehicle.chargepoint.waitingForSoc
132+
? 'fa-spinner fa-spin'
133+
: 'fa-sync'
134+
: ''
135+
})
66136
</script>
67137
<style scoped>
68138
.idWbBadge {
@@ -75,4 +145,8 @@ const statusColor = computed(() => {
75145
.vehiclename {
76146
font-size: var(--font-medium);
77147
}
148+
.socEditor {
149+
border: 1px solid var(--color-menu);
150+
justify-self: stretch;
151+
}
78152
</style>

0 commit comments

Comments
 (0)