-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1291 from cshagen/master
Colors theme: Fixes
- Loading branch information
Showing
13 changed files
with
214 additions
and
84 deletions.
There are no files selected for viewing
Binary file not shown.
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
133 changes: 133 additions & 0 deletions
133
packages/modules/web_themes/colors/source/src/components/counterList/CounterList.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,133 @@ | ||
<template> | ||
<WbSubwidget :titlecolor="device.color" :fullwidth="true"> | ||
<template #title> | ||
{{ device.name }} | ||
</template> | ||
<template #buttons> | ||
<div class="d-flex float-right justify-content-end align-items-center"> | ||
<span | ||
v-for="(temp, idx) in device.temp" | ||
:key="idx" | ||
class="p-0 m-0 align-items-center d-flex" | ||
> | ||
<span v-if="temp < 300" class="my-0 badge rounded-pill tempbadge mx-1" | ||
>{{ formatTemp(temp) }} | ||
</span> | ||
</span> | ||
<span | ||
v-if="props.device.canSwitch" | ||
:class="switchIcon" | ||
:style="switchStyle" | ||
class="fa statusbutton mr-2 ms-4" | ||
@click="statusButtonClicked" | ||
/> | ||
<span | ||
v-if="props.device.canSwitch" | ||
class="badge rounded-pill modebutton mx-2" | ||
@click="modeButtonClicked" | ||
>{{ deviceMode }}</span | ||
> | ||
</div> | ||
</template> | ||
<div class="row m-1 mt-0 p-0"> | ||
<div class="col m-0 mb-1 p-0 d-flex justify-content-between"> | ||
<InfoItem heading="Leistung:"> | ||
<FormatWatt :watt="device.power" /> | ||
</InfoItem> | ||
<InfoItem heading="Energie:"> | ||
<FormatWattH :watt-h="device.energy" /> | ||
</InfoItem> | ||
<InfoItem heading="Laufzeit:"> | ||
{{ formatTime(device.runningTime) }} | ||
</InfoItem> | ||
</div> | ||
</div> | ||
</WbSubwidget> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import { type ShDevice, shDevices } from './model' | ||
import { formatTime, formatTemp } from '@/assets/js/helpers' | ||
import WbSubwidget from '../shared/WbSubwidget.vue' | ||
import InfoItem from '../shared/InfoItem.vue' | ||
import FormatWatt from '../shared/FormatWatt.vue' | ||
import FormatWattH from '../shared/FormatWattH.vue' | ||
import { updateServer } from '@/assets/js/sendMessages' | ||
const props = defineProps<{ | ||
device: ShDevice | ||
}>() | ||
const switchIcon = computed(() => { | ||
return props.device.status == 'on' | ||
? 'fa-toggle-on' | ||
: props.device.status == 'waiting' | ||
? 'fa-spinner fa-spin' | ||
: 'fa-toggle-off' | ||
}) | ||
const switchStyle = computed(() => { | ||
let swColor = 'var(--color-switchRed)' | ||
switch (props.device.status) { | ||
case 'on': | ||
swColor = 'var(--color-switchGreen)' | ||
break | ||
case 'detection': | ||
swColor = 'var(--color-switchBlue)' | ||
break | ||
case 'timeout': | ||
swColor = 'var(--color-switchWhite)' | ||
break | ||
case 'waiting': | ||
swColor = 'var(--color-menu)' | ||
break | ||
default: | ||
swColor = 'var(--color-switchRed)' | ||
} | ||
return { color: swColor } | ||
}) | ||
function statusButtonClicked() { | ||
if (!props.device.isAutomatic) { | ||
if (props.device.status == 'on') { | ||
updateServer('shSwitchOn', 0, props.device.id) | ||
} else { | ||
updateServer('shSwitchOn', 1, props.device.id) | ||
} | ||
shDevices[props.device.id].status = 'waiting' | ||
} | ||
} | ||
function modeButtonClicked() { | ||
if (props.device.isAutomatic) { | ||
updateServer('shSetManual', 1, props.device.id) | ||
} else { | ||
updateServer('shSetManual', 0, props.device.id) | ||
} | ||
} | ||
const deviceMode = computed(() => { | ||
if (props.device.isAutomatic) { | ||
return 'Auto' | ||
} else { | ||
return 'Man' | ||
} | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.statusbutton { | ||
font-size: var(--font-large); | ||
} | ||
.modebutton { | ||
background-color: var(--color-menu); | ||
font-size: var(--font-verysmall); | ||
font-weight: normal; | ||
} | ||
.tempbadge { | ||
background-color: var(--color-battery); | ||
color: var(--color-bg); | ||
font-size: var(--font-verysmall); | ||
font-weight: normal; | ||
} | ||
</style> |
46 changes: 46 additions & 0 deletions
46
packages/modules/web_themes/colors/source/src/components/counterList/model.ts
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,46 @@ | ||
import { reactive } from 'vue' | ||
import { savePrefs } from '@/assets/js/themeConfig' | ||
export class ShDevice { | ||
id: number | ||
name = 'Gerät' | ||
power = 0 | ||
status = 'off' | ||
energy = 0 | ||
runningTime = 0 | ||
configured = false | ||
private _showInGraph = true | ||
color = 'white' | ||
canSwitch = false | ||
countAsHouse = false | ||
energyPv = 0 | ||
energyBat = 0 | ||
pvPercentage = 0 | ||
tempConfigured = 0 | ||
temp = [300.0, 300.0, 300.0] | ||
on = false | ||
isAutomatic = true | ||
icon = '' | ||
constructor(index: number) { | ||
this.id = index | ||
} | ||
get showInGraph() { | ||
return this._showInGraph | ||
} | ||
set showInGraph(val: boolean) { | ||
this._showInGraph = val | ||
savePrefs() | ||
} | ||
} | ||
|
||
export const shDevices: { [key: number]: ShDevice } = reactive({}) | ||
|
||
export function addShDevice(shIndex: number) { | ||
if (!(shIndex in shDevices)) { | ||
shDevices[shIndex] = new ShDevice(shIndex) | ||
shDevices[shIndex].color = | ||
'var(--color-sh' + Object.values(shDevices).length + ')' | ||
// console.info('Added sh device ' + shIndex) | ||
} else { | ||
console.info('Duplicate sh device message: ' + shIndex) | ||
} | ||
} |
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
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
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
2 changes: 2 additions & 0 deletions
2
packages/modules/web_themes/colors/web/assets/index-0fe73fa4.js
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
packages/modules/web_themes/colors/web/assets/index-4e3f10be.js
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...emes/colors/web/assets/index-8951a584.css → ...emes/colors/web/assets/index-ad4978cd.css
Large diffs are not rendered by default.
Oops, something went wrong.
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