feature: convert heater, fan & sensor names

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej 2021-01-19 21:57:59 +01:00
parent a6c4dd75f1
commit d767f50bbb
3 changed files with 20 additions and 17 deletions

View File

@ -57,7 +57,7 @@
<v-col class="pl-8 pr-0 flex-grow-0 py-2colHeaterIcons">
<v-icon :color="heater.color">mdi-{{ heater.icon }}</v-icon>
</v-col>
<v-col class="py-2 font-weight-bold">{{ heater.name }}</v-col>
<v-col class="py-2 font-weight-bold">{{ convertName(heater.name) }}</v-col>
<v-col class="py-2 text-center d-none d-sm-block"><small>{{ heater.target > 0 ? (heater.power !== null ? (heater.power > 0 ? (heater.power * 100).toFixed(0)+'%' : "0%") : "active") : "off" }}</small></v-col>
<v-col class="py-2 text-center">{{ heater.temperature ? heater.temperature.toFixed(1) : 0 }}°C</v-col>
<v-col class="text-center py-2 pr-8 vertical_align_center">
@ -71,7 +71,7 @@
<v-col class="flex-grow-0 py-2 pl-8 pr-0 colHeaterIcons">
<v-icon :color="(fan.target ? 'grey lighten-5' : 'grey darken-2')" :class="(fan.speed ? ' icon-rotate' : '')">mdi-fan</v-icon>
</v-col>
<v-col class="py-2 font-weight-bold">{{ fan.name }}</v-col>
<v-col class="py-2 font-weight-bold">{{ convertName(fan.name) }}</v-col>
<v-col class="py-2 text-center d-none d-sm-block"><small>{{ fan.target > 0 && fan.speed > 0 ? (fan.speed * 100).toFixed(0)+"%" : (fan.target > 0 ? "standby" : "off") }}</small></v-col>
<v-col class="py-2 text-center">{{ fan.temperature ? fan.temperature.toFixed(1) : 0}}°C</v-col>
<v-col class="text-center py-2 pr-8 pr-0 vertical_align_center">
@ -85,7 +85,7 @@
<v-col class="flex-grow-0 py-2 pl-8 pr-0 colHeaterIcons">
<v-icon color="grey darken-2" :title="'min: '+sensor.min_temp+'° / max: '+sensor.max_temp+'°'">{{ sensor.icon }}</v-icon>
</v-col>
<v-col class="py-2 font-weight-bold">{{ sensor.name }}</v-col>
<v-col class="py-2 font-weight-bold">{{ convertName(sensor.name) }}</v-col>
<v-col class="py-2 d-none d-sm-block"><span>&nbsp;</span></v-col>
<v-col class="py-2 text-center">
<v-tooltip top>
@ -118,6 +118,7 @@
import { mapState, mapGetters } from 'vuex'
import toolInput from '../../inputs/ToolInput'
import TempChart from '@/components/charts/TempChart'
import {convertName} from "@/plugins/helpers"
export default {
components: {
@ -160,6 +161,7 @@
},
methods: {
convertName: convertName,
preheat(preset) {
for (const [name, attributes] of Object.entries(preset.values)) {
if (attributes.bool) {

View File

@ -10,7 +10,7 @@
<v-col>
<v-subheader class="_fan-slider-subheader">
<v-icon small :class="'mr-2 '+(value ? 'icon-rotate' : '')" v-if="type !== 'output_pin'">mdi-fan</v-icon>
<span>{{ convertName }}</span>
<span>{{ convertName(this.name) }}</span>
<v-spacer></v-spacer>
<span class="font-weight-bold" v-if="!controllable || (controllable && pwm)">{{ Math.round(value*100) }} %</span>
<v-icon v-if="controllable && !pwm" @click="switchOutputPin">{{ value ? "mdi-toggle-switch" : "mdi-toggle-switch-off-outline" }}</v-icon>
@ -40,6 +40,8 @@
<script>
import {convertName} from "@/plugins/helpers";
export default {
data: function() {
return {
@ -77,20 +79,8 @@
default: 1
},
},
computed: {
convertName() {
let tmp = this.name
let output = ""
tmp = tmp.replaceAll("_", " ")
tmp.split(" ").forEach(split => {
output += " "+split.charAt(0).toUpperCase() + split.slice(1)
})
output = output.slice(1)
return output;
}
},
methods: {
convertName: convertName,
sendCmd() {
let gcode = "";

View File

@ -36,4 +36,15 @@ export function formatConsoleMessage(message) {
message = message.replace(/(?:\r\n|\r|\n)/g, '<br>')
return message;
}
export function convertName(name) {
let output = ""
name = name.replaceAll("_", " ")
name.split(" ").forEach(split => {
output += " "+split.charAt(0).toUpperCase() + split.slice(1)
})
output = output.slice(1)
return output;
}