-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support simple and advanced mode for EM initial values config (frontend)
fix #633
- Loading branch information
Showing
4 changed files
with
114 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/frontend/src/channels/params/channel-params-electricity-meter-initial-value.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<div> | ||
<dl v-if="advancedModeAvailable" class="mb-3"> | ||
<dd>{{ $t('Set different values for each phase') }}</dd> | ||
<dt class="text-center"> | ||
<Toggler v-model="advancedMode"/> | ||
</dt> | ||
</dl> | ||
<div v-if="advancedMode"> | ||
<div class="form-group" v-for="phaseNumber in enabledPhases" :key="`phase-${phaseNumber}`"> | ||
<label :for="`initial-value-${phaseNumber}`">{{ $t('Phase {phaseNumber}', {phaseNumber}) }}</label> | ||
<span class="input-group"> | ||
<input type="number" | ||
step="0.001" | ||
min="-10000000" | ||
:id="`initial-value-${phaseNumber}`" | ||
max="10000000" | ||
class="form-control" | ||
v-model="value[phaseNumber]"> | ||
<span class="input-group-addon"> | ||
kWh | ||
</span> | ||
</span> | ||
</div> | ||
</div> | ||
<div class="form-group" v-else> | ||
<label for="initial-value">{{ $t('Value added') }}</label> | ||
<span class="input-group"> | ||
<input type="number" | ||
step="0.001" | ||
min="-10000000" | ||
id="initial-value" | ||
max="10000000" | ||
class="form-control" | ||
v-model="value" | ||
@change="$emit('change')"> | ||
<span class="input-group-addon"> | ||
kWh | ||
</span> | ||
</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Toggler from "@/common/gui/toggler"; | ||
export default { | ||
components: {Toggler}, | ||
props: { | ||
channel: Object, | ||
value: [Number, Object], | ||
counterName: String, | ||
}, | ||
data() { | ||
return {}; | ||
}, | ||
methods: {}, | ||
computed: { | ||
advancedMode: { | ||
get() { | ||
return typeof this.value === 'object'; | ||
}, | ||
set(value) { | ||
if (value) { | ||
const defaultInitialValue = this.value || 0; | ||
const valueForPhases = {}; | ||
for (let phaseNo of this.enabledPhases) { | ||
valueForPhases['' + phaseNo] = defaultInitialValue; | ||
} | ||
this.$emit('input', valueForPhases); | ||
} else { | ||
const defaultInitialValue = this.value[this.enabledPhases[0]] || 0; | ||
this.$emit('input', defaultInitialValue); | ||
} | ||
} | ||
}, | ||
enabledPhases() { | ||
return this.channel.config.enabledPhases || [1, 2, 3]; | ||
}, | ||
advancedModeAvailable() { | ||
return !['forwardActiveEnergyBalanced', 'reverseActiveEnergyBalanced'].includes(this.counterName); | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters