Skip to content

Commit

Permalink
v4.0.27-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
jemu75 committed Mar 16, 2024
1 parent ae4e95d commit 0a8dcd5
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 85 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ Ersetzungen bieten die Möglichkeit, Werte innerhalb von Element-Definitionen zu
|%n(2)|als Zahl mit 2 Nachkommastellen zurück|
|%n(0,1)|als Ganzzahl mit einem **Offset** von +1 zurück|
|%n(1,-1.5)|als Zahl mit einer Nachkommastelle und einem **Offset** von -1,5 zurück|
|%n(1,0,true)|verhindert, dass die Zahl in das lokale Zahlenformat umgewandelt wird|
|%d()|als Zeitstempel im gewählten Sprachschema zurück|
|%d(time)|als Zeitwert im gewählten Sprachschema zurück|
|%d(date)|als Datum im gewählten Sprachschema zurück|
Expand All @@ -182,7 +181,6 @@ Ersetzungen bieten die Möglichkeit, Werte innerhalb von Element-Definitionen zu
|`state::%s`|on|on|
|`temperature::%n(0)`|12.5|13|
|`desired-temp::%n(1,2)`|22.5|24,5|Komma und tausender Trennzeichen abhängig vom Sprachschema|
|`desired-temp::%n(1,0,true)`|22.48|22.5|Zahl wird nicht in lokales Format gewandelt|
|`state-ts::%d()`|2023-12-17 17:53:32|17.12.2023 17:53:32|abhängig vom Sprachschema|
|`state-ts::%d(time)`|2023-12-17 17:53:32|17:53:32|abhängig vom Sprachschema|
|`state-ts::%d(date)`|2023-12-17 17:53:32|17.12.2023|abhängig vom Sprachschema|
Expand Down
6 changes: 6 additions & 0 deletions public/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v4.0.27-beta (16.03.2024)
## Core
- replacer %n option noLocaleNumber deprecated -> removed!
- bugfix for update readings directly
## Panel
- bugfix for hide/show Levels
# v4.0.26-beta (13.03.2024)
## Core
- bugfix for spaces at readings
Expand Down
62 changes: 31 additions & 31 deletions src/components/PanelCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { computed, onMounted, ref } from 'vue'
import { computed, watch, onMounted, ref } from 'vue'
import { useFhemStore } from '@/stores/fhem'
import PanelMain from './PanelMain.vue'
Expand Down Expand Up @@ -35,48 +35,48 @@
return fhem.handleDefs(item.panel.status.title, ['title'],[''])
})
const expand = computed(() => {
return fhem.handleDefs(item.panel.panel.expandable, ['expandable','expanded','maximizable'],[false, false, false])
})
const expanded = ref(expand.value.expanded)
const levelOpts = ref(fhem.handleDefs(item.panel.panel.expandable, ['expandable','expanded','maximizable'],[false, false, false]))
const expandIcon = computed(() => {
let res = null
watch(item.panel.main, (newVal) => {
let activeLevels = levelsActive(newVal)
if(expand.value.expandable) res = expanded.value ? 'mdi-arrow-collapse' : 'mdi-arrow-expand'
if(!expand.value.expandable && !expand.value.expanded && item.panel.main.length > 1) res = 'mdi-swap-vertical'
return res
if(levelOpts.value.activeLevels.join('-') !== activeLevels.join('-')) {
levelOpts.value.activeLevels = activeLevels
levelClick()
}
})
const levelsActive = computed(() => {
function levelsActive(obj) {
let res = []
for(const [idx, lvl] of Object.entries(item.panel.main)) {
for(const [idx, lvl] of Object.entries(obj)) {
if(fhem.handleDefs(lvl.level.show, ['show'], [true]).show) res.push(Number(idx))
}
return res
})
}
function levelSwitch(init) {
let idx = -1
function levelClick(init) {
let opts = levelOpts.value,
idx
if(init) opts.activeLevels = levelsActive(item.panel.main)
if(expand.value.expandable || (!expand.value.expandable && expand.value.expanded)) {
if(!init) {
if(expand.value.maximizable) fhem.app.panelMaximized = expanded.value ? false : item.panel
expanded.value = !expanded.value
}
if(opts.expandable && !init) opts.expanded = !opts.expanded
levels.value = expanded.value ? levelsActive.value : [levelsActive.value[0]]
if(opts.expanded) {
opts.levels = opts.activeLevels
} else {
idx = levelsActive.value.indexOf(levels.value ? levels.value[0] : null)
levels.value = (idx === -1 || idx === levelsActive.value.length - 1) ? [levelsActive.value[0]] : [levelsActive.value[idx + 1]]
if(opts.expandable || init) {
opts.levels = [opts.activeLevels[0]]
} else {
idx = opts.activeLevels.indexOf(opts.levels[0])
opts.levels = [opts.activeLevels[idx + 1] >= 0 ? opts.activeLevels[idx + 1] : opts.activeLevels[0]]
}
}
}
const levels = ref([])
opts.icon = opts.activeLevels.length > 1 ? opts.expandable ? opts.expanded ? 'mdi-arrow-collapse' : 'mdi-arrow-expand' : !opts.expanded ? 'mdi-swap-vertical' : '' : ''
}
function getInfo(pos) {
let res = fhem.handleDefs(item.panel.info[pos], ['text', 'icon', 'color'],['', '', ''])
Expand All @@ -103,7 +103,7 @@
const infoRight1 = computed(() => getInfo('right1'))
const infoRight2 = computed(() => getInfo('right2'))
levelSwitch(true)
levelClick(true)
</script>

<template>
Expand Down Expand Up @@ -138,15 +138,15 @@
<v-col v-if="fhem.app.settings.loglevel > 6" class="text-right">
{{ sortby.sortby }}
</v-col>
<v-col v-if="expandIcon" cols="1" class="text-right">
<v-btn :icon="expandIcon" size="small" variant="plain" density="compact" @click="levelSwitch(false)"></v-btn>
<v-col v-if="levelOpts.icon" cols="1" class="text-right">
<v-btn :icon="levelOpts.icon" size="small" variant="plain" density="compact" @click="levelClick(false)"></v-btn>
</v-col>
</v-row>
</v-card-title>
</v-img>
</v-sheet>

<PanelMain :main="panel.main" :levels="levels" :iconmap="panel.panel.iconmap" :devices="panel.panel.devices"></PanelMain>
<PanelMain :main="panel.main" :levels="levelOpts.levels" :iconmap="panel.panel.iconmap" :devices="panel.panel.devices"></PanelMain>

<v-layout style="height:24px">
<v-system-bar color="secondary">
Expand Down
6 changes: 3 additions & 3 deletions src/components/PanelMainBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
}
function btnClick(evt) {
let click = fhem.handleDefs(props.el.click, ['cmd', 'type'], ['', 'cmd']),
longClick = fhem.handleDefs(props.el.longClick, ['cmd', 'type'], ['', 'cmd']),
longRelease = fhem.handleDefs(props.el.longRelease, ['cmd', 'type'], ['', 'cmd'])
let click = fhem.handleDefs(props.el.click, ['cmd', 'type'], ['', 'cmd'], false, null, true),
longClick = fhem.handleDefs(props.el.longClick, ['cmd', 'type'], ['', 'cmd'], false, null, true),
longRelease = fhem.handleDefs(props.el.longRelease, ['cmd', 'type'], ['', 'cmd'], false, null, true)
if(evt === 'mouseStart') {
btnState.timer = setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/PanelMainSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
const slider = computed(() => {
let res = fhem.handleDefs(props.el.slider, ['cmd', 'current', 'color', 'min', 'max', 'steps', 'reverse', 'size', 'vertical'],['', 0, '', 0, 100, 10, false, 4, false])
let res = fhem.handleDefs(props.el.slider, ['cmd', 'current', 'color', 'min', 'max', 'steps', 'reverse', 'size', 'vertical'],['', 0, '', 0, 100, 10, false, 4, false], false, null, true)
if(/%v/.test(res.current)) res.current = res.current.replace('%v', sliderVal.value)
setSliderVal(res.current)
Expand Down
16 changes: 9 additions & 7 deletions src/stores/fhem.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ export const useFhemStore = defineStore('fhem', () => {
//local Loop to update reading directly without response from FHEM
if(/^set.*/.test(cmd)) {
cmdParts = cmd.split(' ')

stat.evtBuffer.push({ reading: cmdParts.slice(1, 3).join('-'), value: cmdParts[3] })
handleEventBuffer(true)

if(cmdParts.length > 2) {
stat.evtBuffer.push({ reading: cmdParts.slice(1, 3).join('-'), value: cmdParts.slice(-1) })
handleEventBuffer(true)
}
}

log(4, 'Request send to FHEM.', { url: createURL(params), options })
Expand Down Expand Up @@ -703,7 +705,7 @@ export const useFhemStore = defineStore('fhem', () => {
}

//coreFunction Replace Values %s %n() %d() %t() &#058;
function replacer(prop, val) {
function replacer(prop, val, noLocalConv) {
let res = prop

if(typeof prop !== 'string') return prop
Expand All @@ -725,7 +727,7 @@ export const useFhemStore = defineStore('fhem', () => {
let digits = parseFloat(opts[0] || 0)
let num = parseFloat(val.slice(chkNum.index)) + ofs

res = def.input.replace(def[0], opts[2] === 'true' ? num.toFixed(digits) : i18n.n(num, { minimumFractionDigits: digits, maximumFractionDigits: digits }))
res = def.input.replace(def[0], noLocalConv ? num.toFixed(digits) : i18n.n(num, { minimumFractionDigits: digits, maximumFractionDigits: digits }))
}

if(/%d\(.*\)/.test(res)) {
Expand Down Expand Up @@ -758,7 +760,7 @@ export const useFhemStore = defineStore('fhem', () => {
}

//coreFunction to handle Definitions
function handleDefs(defs, props, defaults, isList, splitter) {
function handleDefs(defs, props, defaults, isList, splitter, noLocalConv) {
let res = isList ? [] : {},
defList,
defParts,
Expand Down Expand Up @@ -812,7 +814,7 @@ export const useFhemStore = defineStore('fhem', () => {
if(prop === 'true') prop = true
if(prop === 'false') prop = false

if(prop !== '') obj[hasProps && props[idx] ? props[idx] : [idx]] = replacer(prop, defParts[0])
if(prop !== '') obj[hasProps && props[idx] ? props[idx] : [idx]] = replacer(prop, defParts[0], noLocalConv)
}

if(isList) {
Expand Down
6 changes: 6 additions & 0 deletions www/fhemapp4/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v4.0.27-beta (16.03.2024)
## Core
- replacer %n option noLocaleNumber deprecated -> removed!
- bugfix for update readings directly
## Panel
- bugfix for hide/show Levels
# v4.0.26-beta (13.03.2024)
## Core
- bugfix for spaces at readings
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0a8dcd5

Please sign in to comment.