Config UI: add advanced fields, add general vehicle properties (#15038)
This commit is contained in:
parent
581f70e559
commit
cf8f73f2b0
10 changed files with 504 additions and 80 deletions
|
|
@ -250,6 +250,10 @@ a:hover {
|
|||
--bs-btn-hover-border-color: var(--bs-gray-medium);
|
||||
}
|
||||
|
||||
.btn-link:hover {
|
||||
color: var(--bs-primary);
|
||||
}
|
||||
|
||||
.dark .btn-outline-secondary {
|
||||
--bs-btn-color: var(--bs-gray-bright);
|
||||
--bs-btn-border-color: var(--bs-gray-bright);
|
||||
|
|
|
|||
|
|
@ -80,26 +80,25 @@
|
|||
:defaultPort="modbus.Port"
|
||||
:capabilities="modbusCapabilities"
|
||||
/>
|
||||
<FormRow
|
||||
v-for="param in templateParams"
|
||||
:id="`meterParam${param.Name}`"
|
||||
<PropertyEntry
|
||||
v-for="param in normalParams"
|
||||
:key="param.Name"
|
||||
:optional="!param.Required"
|
||||
:label="param.Description || `[${param.Name}]`"
|
||||
:help="param.Description === param.Help ? undefined : param.Help"
|
||||
:example="param.Example"
|
||||
>
|
||||
<PropertyField
|
||||
:id="`meterParam${param.Name}`"
|
||||
v-model="values[param.Name]"
|
||||
:masked="param.Mask"
|
||||
:property="param.Name"
|
||||
:type="param.Type"
|
||||
class="me-2"
|
||||
:required="param.Required"
|
||||
:validValues="param.ValidValues"
|
||||
/>
|
||||
</FormRow>
|
||||
:id="`meterParam${param.Name}`"
|
||||
v-bind="param"
|
||||
v-model="values[param.Name]"
|
||||
/>
|
||||
|
||||
<PropertyCollapsible>
|
||||
<template v-if="advancedParams.length" #advanced>
|
||||
<PropertyEntry
|
||||
v-for="param in advancedParams"
|
||||
:key="param.Name"
|
||||
:id="`meterParam${param.Name}`"
|
||||
v-bind="param"
|
||||
v-model="values[param.Name]"
|
||||
/>
|
||||
</template>
|
||||
</PropertyCollapsible>
|
||||
|
||||
<TestResult
|
||||
v-if="templateName"
|
||||
|
|
@ -158,7 +157,8 @@
|
|||
|
||||
<script>
|
||||
import FormRow from "./FormRow.vue";
|
||||
import PropertyField from "./PropertyField.vue";
|
||||
import PropertyEntry from "./PropertyEntry.vue";
|
||||
import PropertyCollapsible from "./PropertyCollapsible.vue";
|
||||
import TestResult from "./TestResult.vue";
|
||||
import api from "../../api";
|
||||
import test from "./mixins/test";
|
||||
|
|
@ -171,9 +171,18 @@ function sleep(ms) {
|
|||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
const CUSTOM_FIELDS = ["usage", "modbus"];
|
||||
|
||||
export default {
|
||||
name: "MeterModal",
|
||||
components: { FormRow, PropertyField, Modbus, TestResult, AddDeviceButton },
|
||||
components: {
|
||||
FormRow,
|
||||
PropertyEntry,
|
||||
Modbus,
|
||||
TestResult,
|
||||
AddDeviceButton,
|
||||
PropertyCollapsible,
|
||||
},
|
||||
mixins: [test],
|
||||
props: {
|
||||
id: Number,
|
||||
|
|
@ -215,18 +224,20 @@ export default {
|
|||
return this.products.filter((p) => p.group === "generic");
|
||||
},
|
||||
templateParams() {
|
||||
const params = this.template?.Params || [];
|
||||
return (
|
||||
params
|
||||
// deprecated fields
|
||||
.filter((p) => !p.Deprecated)
|
||||
// remove usage option
|
||||
.filter((p) => p.Name !== "usage")
|
||||
// remove modbus, handles separately
|
||||
.filter((p) => p.Name !== "modbus")
|
||||
// capacity only for battery meters
|
||||
.filter((p) => this.meterType === "battery" || p.Name !== "capacity")
|
||||
);
|
||||
return (this.template?.Params || [])
|
||||
.filter((p) => !CUSTOM_FIELDS.includes(p.Name))
|
||||
.map((p) => {
|
||||
if (this.meterType === "battery" && p.Name === "capacity") {
|
||||
p.Advanced = false;
|
||||
}
|
||||
return p;
|
||||
});
|
||||
},
|
||||
normalParams() {
|
||||
return this.templateParams.filter((p) => !p.Advanced);
|
||||
},
|
||||
advancedParams() {
|
||||
return this.templateParams.filter((p) => p.Advanced);
|
||||
},
|
||||
modbus() {
|
||||
const params = this.template?.Params || [];
|
||||
|
|
|
|||
62
assets/js/components/Config/PropertyCollapsible.vue
Normal file
62
assets/js/components/Config/PropertyCollapsible.vue
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<template>
|
||||
<div v-if="$slots.advanced || $slots.more">
|
||||
<button
|
||||
class="btn btn-link btn-sm text-gray px-0 border-0 d-flex align-items-center mb-2"
|
||||
:class="open ? 'text-primary' : ''"
|
||||
type="button"
|
||||
@click="toggle"
|
||||
>
|
||||
<span v-if="open">Hide advanced settings</span>
|
||||
<span v-else>Show advanced settings</span>
|
||||
<DropdownIcon class="icon" :class="{ iconUp: open }" />
|
||||
</button>
|
||||
|
||||
<Transition>
|
||||
<div v-if="open" class="pt-2">
|
||||
<slot name="advanced"></slot>
|
||||
<hr v-if="$slots.advanced && $slots.more" class="my-5" />
|
||||
<slot name="more"></slot>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DropdownIcon from "../MaterialIcon/Dropdown.vue";
|
||||
|
||||
export default {
|
||||
name: "PropertyCollapsible",
|
||||
components: { DropdownIcon },
|
||||
data() {
|
||||
return { open: false };
|
||||
},
|
||||
|
||||
methods: {
|
||||
toggle() {
|
||||
this.open = !this.open;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.icon {
|
||||
transform: rotate(0deg);
|
||||
transition: transform var(--evcc-transition-medium) ease;
|
||||
}
|
||||
.iconUp {
|
||||
transform: rotate(-180deg);
|
||||
}
|
||||
.v-enter-active,
|
||||
.v-leave-active {
|
||||
transition:
|
||||
transform var(--evcc-transition-medium) ease,
|
||||
opacity var(--evcc-transition-medium) ease;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.v-enter-from,
|
||||
.v-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-0.5rem);
|
||||
}
|
||||
</style>
|
||||
53
assets/js/components/Config/PropertyEntry.vue
Normal file
53
assets/js/components/Config/PropertyEntry.vue
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<template>
|
||||
<FormRow
|
||||
:id="id"
|
||||
:optional="!Required"
|
||||
:label="Description || `[${Name}]`"
|
||||
:help="Description === Help ? undefined : Help"
|
||||
:example="Example"
|
||||
>
|
||||
<PropertyField
|
||||
:id="id"
|
||||
v-model="value"
|
||||
:masked="Mask"
|
||||
:property="Name"
|
||||
:type="Type"
|
||||
class="me-2"
|
||||
:required="Required"
|
||||
:validValues="ValidValues"
|
||||
/>
|
||||
</FormRow>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FormRow from "./FormRow.vue";
|
||||
import PropertyField from "./PropertyField.vue";
|
||||
|
||||
export default {
|
||||
name: "PropertyEntry",
|
||||
components: { FormRow, PropertyField },
|
||||
props: {
|
||||
id: String,
|
||||
Name: String,
|
||||
Required: Boolean,
|
||||
Description: String,
|
||||
Help: String,
|
||||
Example: String,
|
||||
Type: String,
|
||||
Mask: Boolean,
|
||||
ValidValues: Array,
|
||||
modelValue: [String, Number, Boolean, Object],
|
||||
},
|
||||
emits: ["update:modelValue"],
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
this.$emit("update:modelValue", value);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div v-if="unit" class="input-group" :class="short ? 'w-50' : ''">
|
||||
<div v-if="unitValue" class="input-group" :class="sizeClass">
|
||||
<input
|
||||
:id="id"
|
||||
v-model="value"
|
||||
|
|
@ -9,8 +9,9 @@
|
|||
:required="required"
|
||||
:aria-describedby="id + '_unit'"
|
||||
class="form-control"
|
||||
:class="{ 'text-end': endAlign }"
|
||||
/>
|
||||
<span :id="id + '_unit'" class="input-group-text">{{ unit }}</span>
|
||||
<span :id="id + '_unit'" class="input-group-text">{{ unitValue }}</span>
|
||||
</div>
|
||||
<div v-else-if="icons" class="d-flex flex-wrap">
|
||||
<div
|
||||
|
|
@ -34,24 +35,39 @@
|
|||
:for="`icon_${key}`"
|
||||
:aria-label="key"
|
||||
>
|
||||
<VehicleIcon :name="key" />
|
||||
<VehicleIcon v-if="key" :name="key" />
|
||||
<shopicon-regular-minus v-else></shopicon-regular-minus>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="!selectMode" class="me-2 mb-2 d-flex align-items-end">
|
||||
<a :id="id" class="text-muted" href="#" @click.prevent="toggleSelectMode">change</a>
|
||||
</div>
|
||||
</div>
|
||||
<select v-else-if="select" :id="id" v-model="value" class="form-select">
|
||||
<SelectGroup
|
||||
v-else-if="boolean"
|
||||
:id="id"
|
||||
class="w-50"
|
||||
v-model="value"
|
||||
:options="[
|
||||
{ value: false, name: $t('config.options.boolean.no') },
|
||||
{ value: true, name: $t('config.options.boolean.yes') },
|
||||
]"
|
||||
/>
|
||||
<select v-else-if="select" :id="id" v-model="value" class="form-select" :class="sizeClass">
|
||||
<option v-if="!required" value="">---</option>
|
||||
<option v-for="{ key, name } in selectOptions" :key="key" :value="key">
|
||||
{{ name }}
|
||||
</option>
|
||||
<template v-for="({ key, name }, idx) in selectOptions">
|
||||
<option v-if="key !== null && name !== null" :key="key" :value="key">
|
||||
{{ name }}
|
||||
</option>
|
||||
<hr v-else :key="idx" />
|
||||
</template>
|
||||
</select>
|
||||
<textarea
|
||||
v-else-if="textarea"
|
||||
:id="id"
|
||||
v-model="value"
|
||||
class="form-control"
|
||||
:class="sizeClass"
|
||||
:type="inputType"
|
||||
:placeholder="placeholder"
|
||||
:required="required"
|
||||
|
|
@ -62,26 +78,32 @@
|
|||
:id="id"
|
||||
v-model="value"
|
||||
class="form-control"
|
||||
:class="short ? 'w-50' : ''"
|
||||
:class="sizeClass"
|
||||
:type="inputType"
|
||||
:step="step"
|
||||
:placeholder="placeholder"
|
||||
:required="required"
|
||||
:autocomplete="masked ? 'off' : null"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import "@h2d2/shopicons/es/regular/minus";
|
||||
import VehicleIcon from "../VehicleIcon";
|
||||
import SelectGroup from "../SelectGroup.vue";
|
||||
|
||||
export default {
|
||||
name: "PropertyField",
|
||||
components: { VehicleIcon },
|
||||
components: { VehicleIcon, SelectGroup },
|
||||
props: {
|
||||
id: String,
|
||||
property: String,
|
||||
masked: Boolean,
|
||||
placeholder: String,
|
||||
type: String,
|
||||
unit: String,
|
||||
size: String,
|
||||
scale: Number,
|
||||
required: Boolean,
|
||||
validValues: { type: Array, default: () => [] },
|
||||
modelValue: [String, Number, Boolean, Object],
|
||||
|
|
@ -95,21 +117,33 @@ export default {
|
|||
if (this.masked) {
|
||||
return "password";
|
||||
}
|
||||
if (["Number", "Float"].includes(this.type)) {
|
||||
if (["Number", "Float", "Duration"].includes(this.type)) {
|
||||
return "number";
|
||||
}
|
||||
return "text";
|
||||
},
|
||||
short() {
|
||||
sizeClass() {
|
||||
if (this.size) {
|
||||
return this.size;
|
||||
}
|
||||
if (["Number", "Float", "Duration"].includes(this.type)) {
|
||||
return "w-50 w-min-200";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
endAlign() {
|
||||
return ["Number", "Float", "Duration"].includes(this.type);
|
||||
},
|
||||
step() {
|
||||
if (this.type === "Float") {
|
||||
if (this.type === "Float" || this.type === "Duration") {
|
||||
return "any";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
unit() {
|
||||
unitValue() {
|
||||
if (this.unit) {
|
||||
return this.unit;
|
||||
}
|
||||
if (this.property === "capacity") {
|
||||
return "kWh";
|
||||
}
|
||||
|
|
@ -119,29 +153,68 @@ export default {
|
|||
return this.property === "icon";
|
||||
},
|
||||
textarea() {
|
||||
return ["accessToken", "refreshToken"].includes(this.property);
|
||||
return ["accessToken", "refreshToken", "identifiers"].includes(this.property);
|
||||
},
|
||||
boolean() {
|
||||
return this.type === "Bool";
|
||||
},
|
||||
array() {
|
||||
return this.type === "StringList";
|
||||
},
|
||||
select() {
|
||||
return this.validValues.length > 0;
|
||||
},
|
||||
selectOptions() {
|
||||
// If the valid values are already in the correct format, return them
|
||||
if (this.validValues[0].key && this.validValues[0].name) {
|
||||
if (typeof this.validValues[0] === "object") {
|
||||
return this.validValues;
|
||||
}
|
||||
|
||||
let values = [...this.validValues];
|
||||
|
||||
if (this.icons && !this.required) {
|
||||
values = ["", ...values];
|
||||
}
|
||||
|
||||
// Otherwise, convert them to the correct format
|
||||
return this.validValues.map((value) => ({
|
||||
return values.map((value) => ({
|
||||
key: value,
|
||||
name: this.$t(`config.options.${this.property}.${value}`),
|
||||
name: this.$t(`config.options.${this.property}.${value || "none"}`),
|
||||
}));
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
// use first option if no value is set
|
||||
if (this.selectOptions.length > 0 && !this.modelValue) {
|
||||
return this.required ? this.selectOptions[0].key : "";
|
||||
}
|
||||
|
||||
if (this.scale) {
|
||||
return this.modelValue * this.scale;
|
||||
}
|
||||
|
||||
if (this.boolean) {
|
||||
return this.modelValue === true;
|
||||
}
|
||||
|
||||
if (this.array) {
|
||||
return Array.isArray(this.modelValue) ? this.modelValue.join("\n") : "";
|
||||
}
|
||||
|
||||
return this.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
this.$emit("update:modelValue", value);
|
||||
let newValue = value;
|
||||
|
||||
if (this.scale) {
|
||||
newValue = value / this.scale;
|
||||
}
|
||||
|
||||
if (this.array) {
|
||||
newValue = value ? value.split("\n") : [];
|
||||
}
|
||||
|
||||
this.$emit("update:modelValue", newValue);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -164,4 +237,13 @@ input[type="number"]::-webkit-inner-spin-button {
|
|||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
.w-min-100 {
|
||||
min-width: min(100px, 100%);
|
||||
}
|
||||
.w-min-150 {
|
||||
min-width: min(150px, 100%);
|
||||
}
|
||||
.w-min-200 {
|
||||
min-width: min(200px, 100%);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -66,26 +66,138 @@
|
|||
</optgroup>
|
||||
</select>
|
||||
</FormRow>
|
||||
<FormRow
|
||||
v-for="param in templateParams"
|
||||
:id="`vehicleParam${param.Name}`"
|
||||
|
||||
<PropertyEntry
|
||||
v-for="param in normalParams"
|
||||
:key="param.Name"
|
||||
:optional="!param.Required"
|
||||
:label="param.Description || `[${param.Name}]`"
|
||||
:help="param.Description === param.Help ? undefined : param.Help"
|
||||
:example="param.Example"
|
||||
>
|
||||
<PropertyField
|
||||
:id="`vehicleParam${param.Name}`"
|
||||
v-model="values[param.Name]"
|
||||
:masked="param.Mask"
|
||||
:property="param.Name"
|
||||
:type="param.Type"
|
||||
class="me-2"
|
||||
:required="param.Required"
|
||||
:validValues="param.ValidValues"
|
||||
/>
|
||||
</FormRow>
|
||||
:id="`vehicleParam${param.Name}`"
|
||||
v-bind="param"
|
||||
v-model="values[param.Name]"
|
||||
/>
|
||||
|
||||
<PropertyCollapsible>
|
||||
<template v-if="advancedParams.length" #advanced>
|
||||
<PropertyEntry
|
||||
v-for="param in advancedParams"
|
||||
:key="param.Name"
|
||||
:id="`vehicleParam${param.Name}`"
|
||||
v-bind="param"
|
||||
v-model="values[param.Name]"
|
||||
/>
|
||||
</template>
|
||||
<template #more>
|
||||
<h6 class="mt-3">Charging settings</h6>
|
||||
<FormRow
|
||||
id="vehicleParamMode"
|
||||
label="Default mode"
|
||||
help="Charging point mode when connecting this vehicle."
|
||||
>
|
||||
<PropertyField
|
||||
id="vehicleParamMode"
|
||||
v-model="values.mode"
|
||||
type="String"
|
||||
class="w-100"
|
||||
:valid-values="[
|
||||
{ key: 'off', name: $t('main.mode.off') },
|
||||
{ key: 'pv', name: $t('main.mode.pv') },
|
||||
{ key: 'minpv', name: $t('main.mode.minpv') },
|
||||
{ key: 'now', name: $t('main.mode.now') },
|
||||
]"
|
||||
/>
|
||||
</FormRow>
|
||||
<FormRow
|
||||
id="vehicleParamPhases"
|
||||
label="Maximum phases"
|
||||
help="How many phases can this vehicle charge with? Used to calculate required minimum solar surplus and plan duration."
|
||||
>
|
||||
<SelectGroup
|
||||
id="vehicleParamPhases"
|
||||
class="w-100"
|
||||
v-model="values.phases"
|
||||
:options="[
|
||||
{ name: '1-phase', value: '1' },
|
||||
{ name: '2-phases', value: '2' },
|
||||
{ name: '3-phases', value: undefined },
|
||||
]"
|
||||
/>
|
||||
</FormRow>
|
||||
<div class="row mb-3">
|
||||
<FormRow
|
||||
id="vehicleParamMinCurrent"
|
||||
label="Minimum current"
|
||||
class="col-sm-6 mb-sm-0"
|
||||
:help="
|
||||
values.minCurrent && values.minCurrent < 6
|
||||
? 'Only go below 6 A if you know what you\'re doing.'
|
||||
: null
|
||||
"
|
||||
>
|
||||
<PropertyField
|
||||
id="vehicleParamMinCurrent"
|
||||
v-model="values.minCurrent"
|
||||
type="Float"
|
||||
unit="A"
|
||||
size="w-25 w-min-200"
|
||||
class="me-2"
|
||||
/>
|
||||
</FormRow>
|
||||
|
||||
<FormRow
|
||||
id="vehicleParamMaxCurrent"
|
||||
label="Maximum current"
|
||||
class="col-sm-6 mb-sm-0"
|
||||
:help="
|
||||
values.minCurrent &&
|
||||
values.maxCurrent &&
|
||||
values.maxCurrent < values.minCurrent
|
||||
? 'Must be greater than minimum current.'
|
||||
: null
|
||||
"
|
||||
>
|
||||
<PropertyField
|
||||
id="vehicleParamMaxCurrent"
|
||||
v-model="values.maxCurrent"
|
||||
type="Float"
|
||||
unit="A"
|
||||
size="w-25 w-min-200"
|
||||
class="me-2"
|
||||
/>
|
||||
</FormRow>
|
||||
</div>
|
||||
|
||||
<!-- todo: only show when multiple loadpoints exist -->
|
||||
<FormRow
|
||||
id="vehicleParamPriority"
|
||||
label="Priority"
|
||||
help="Changes the charging point priority when connecting this vehicle."
|
||||
>
|
||||
<PropertyField
|
||||
id="vehicleParamPriority"
|
||||
v-model="values.priority"
|
||||
type="Number"
|
||||
size="w-100"
|
||||
class="me-2"
|
||||
:valid-values="priorityOptions"
|
||||
required
|
||||
/>
|
||||
</FormRow>
|
||||
|
||||
<FormRow
|
||||
id="vehicleParamIdentifiers"
|
||||
label="RFID identifiers"
|
||||
help="List of RFID strings to identify the vehicle. One per line. See the current identifier on the configuration overview."
|
||||
>
|
||||
<PropertyField
|
||||
id="vehicleParamIdentifiers"
|
||||
v-model="values.identifiers"
|
||||
type="StringList"
|
||||
property="identifiers"
|
||||
size="w-100"
|
||||
class="me-2"
|
||||
/>
|
||||
</FormRow>
|
||||
</template>
|
||||
</PropertyCollapsible>
|
||||
|
||||
<TestResult
|
||||
v-if="templateName"
|
||||
|
|
@ -146,6 +258,9 @@
|
|||
import FormRow from "./FormRow.vue";
|
||||
import PropertyField from "./PropertyField.vue";
|
||||
import TestResult from "./TestResult.vue";
|
||||
import SelectGroup from "../SelectGroup.vue";
|
||||
import PropertyEntry from "./PropertyEntry.vue";
|
||||
import PropertyCollapsible from "./PropertyCollapsible.vue";
|
||||
import api from "../../api";
|
||||
import test from "./mixins/test";
|
||||
|
||||
|
|
@ -155,9 +270,18 @@ function sleep(ms) {
|
|||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
const CUSTOM_FIELDS = ["minCurrent", "maxCurrent", "priority", "identifiers", "phases", "mode"];
|
||||
|
||||
export default {
|
||||
name: "VehicleModal",
|
||||
components: { FormRow, PropertyField, TestResult },
|
||||
components: {
|
||||
FormRow,
|
||||
PropertyField,
|
||||
TestResult,
|
||||
SelectGroup,
|
||||
PropertyCollapsible,
|
||||
PropertyEntry,
|
||||
},
|
||||
mixins: [test],
|
||||
props: {
|
||||
id: Number,
|
||||
|
|
@ -183,15 +307,21 @@ export default {
|
|||
};
|
||||
},
|
||||
templateParams() {
|
||||
const params = this.template?.Params || [];
|
||||
const filteredParams = params.filter((p) => !p.Advanced || p.Name === "icon");
|
||||
const adjustedParams = filteredParams.map((p) => {
|
||||
if (p.Name === "title" || p.Name === "icon") {
|
||||
p.Required = true;
|
||||
}
|
||||
return p;
|
||||
});
|
||||
return adjustedParams;
|
||||
return (this.template?.Params || [])
|
||||
.filter((p) => !CUSTOM_FIELDS.includes(p.Name))
|
||||
.map((p) => {
|
||||
if (p.Name === "title" || p.Name === "icon") {
|
||||
p.Required = true;
|
||||
p.Advanced = false;
|
||||
}
|
||||
return p;
|
||||
});
|
||||
},
|
||||
normalParams() {
|
||||
return this.templateParams.filter((p) => !p.Advanced);
|
||||
},
|
||||
advancedParams() {
|
||||
return this.templateParams.filter((p) => p.Advanced);
|
||||
},
|
||||
apiData() {
|
||||
return {
|
||||
|
|
@ -205,6 +335,13 @@ export default {
|
|||
isDeletable() {
|
||||
return !this.isNew;
|
||||
},
|
||||
priorityOptions() {
|
||||
const result = Array.from({ length: 11 }, (_, i) => ({ key: i, name: `${i}` }));
|
||||
result[0].name = "0 (default)";
|
||||
result[0].key = undefined;
|
||||
result[10].name = "10 (highest)";
|
||||
return result;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
isModalVisible(visible) {
|
||||
|
|
|
|||
17
assets/js/components/MaterialIcon/Dropdown.vue
Normal file
17
assets/js/components/MaterialIcon/Dropdown.vue
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<template>
|
||||
<svg :style="svgStyle" viewBox="0 0 24 24">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M11.475 14.475L7.85 10.85q-.075-.075-.112-.162T7.7 10.5q0-.2.138-.35T8.2 10h7.6q.225 0 .363.15t.137.35q0 .05-.15.35l-3.625 3.625q-.125.125-.25.175T12 14.7t-.275-.05t-.25-.175"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import icon from "../../mixins/icon";
|
||||
|
||||
export default {
|
||||
name: "Dropdown",
|
||||
mixins: [icon],
|
||||
};
|
||||
</script>
|
||||
|
|
@ -170,6 +170,10 @@ title = "Network"
|
|||
|
||||
[config.options]
|
||||
|
||||
[config.options.boolean]
|
||||
no = "no"
|
||||
yes = "yes"
|
||||
|
||||
[config.options.endianness]
|
||||
big = "big-endian"
|
||||
little = "little-endian"
|
||||
|
|
|
|||
|
|
@ -84,4 +84,21 @@ test.describe("battery meter", async () => {
|
|||
|
||||
await expect(page.getByTestId("battery")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("advanced fields", async ({ page }) => {
|
||||
await page.goto("/#/config");
|
||||
await login(page);
|
||||
await enableExperimental(page);
|
||||
|
||||
await page.getByRole("button", { name: "Add solar or battery" }).click();
|
||||
|
||||
const meterModal = page.getByTestId("meter-modal");
|
||||
await meterModal.getByRole("button", { name: "Add battery meter" }).click();
|
||||
await meterModal.getByLabel("Manufacturer").selectOption("OpenEMS");
|
||||
await expect(meterModal.getByLabel("Password optional")).not.toBeVisible();
|
||||
await page.getByRole("button", { name: "Show advanced settings" }).click();
|
||||
await expect(meterModal.getByLabel("Password optional")).toBeVisible();
|
||||
await page.getByRole("button", { name: "Hide advanced settings" }).click();
|
||||
await expect(meterModal.getByLabel("Password optional")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -130,4 +130,41 @@ test.describe("vehicles", async () => {
|
|||
await expect(page.getByTestId("vehicle").nth(0)).toHaveText(/YAML Bike/);
|
||||
await expect(page.getByTestId("vehicle").nth(1)).toHaveText(/Green Car/);
|
||||
});
|
||||
|
||||
test("advanced fields", async ({ page }) => {
|
||||
await page.goto("/#/config");
|
||||
await login(page);
|
||||
await enableExperimental(page);
|
||||
|
||||
await page.getByTestId("add-vehicle").click();
|
||||
const vehicleModal = page.getByTestId("vehicle-modal");
|
||||
|
||||
// generic
|
||||
await vehicleModal.getByLabel("Manufacturer").selectOption("Generic vehicle");
|
||||
await expect(vehicleModal.getByLabel("Title")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Car")).toBeVisible(); // icon
|
||||
await expect(vehicleModal.getByLabel("Battery capacity")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Show advanced settings" }).click();
|
||||
await expect(vehicleModal.getByLabel("Default mode")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Maximum phases")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Minimum current")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Maximum current")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Priority")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("RFID identifiers")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Hide advanced settings" }).click();
|
||||
await expect(vehicleModal.getByLabel("Default mode")).not.toBeVisible();
|
||||
|
||||
// polestar template
|
||||
await vehicleModal.getByLabel("Manufacturer").selectOption("Polestar");
|
||||
await expect(vehicleModal.getByLabel("Username")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Password")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Cache optional")).not.toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Default mode")).not.toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Show advanced settings" }).click();
|
||||
await expect(vehicleModal.getByLabel("Cache optional")).toBeVisible();
|
||||
await expect(vehicleModal.getByLabel("Default mode")).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue