Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dummy and Clock widget improvements #1380

Merged
merged 3 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bundles/org.openhab.ui.habpanel/doc/habpanel.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ The following built-in widgets are available:

![Dummy widget](images/habpanel_widget-dummy.png)

The so-called dummy widget (whose name is explained by historical reasons - it evolved from the first developed widget) displays the current state of an item without any interactivity, along with a label and an optional icon.
The so-called dummy widget (whose name is explained by historical reasons - it evolved from the first developed widget) displays the current state of an item without any interactivity, along with a label and an optional icon. It has a few options to customize it's appeareance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The so-called dummy widget (whose name is explained by historical reasons - it evolved from the first developed widget) displays the current state of an item without any interactivity, along with a label and an optional icon. It has a few options to customize it's appeareance.
The so-called dummy widget (whose name is explained by historical reasons - it evolved from the first developed widget) displays the current state of an item without any interactivity, along with a label and an optional icon. It has a few options to customize its appeareance.


#### Switch (switch)

Expand Down Expand Up @@ -230,7 +230,7 @@ The frame widget displays an external web page in a HTML `<iframe>`.

![Clock widget](images/habpanel_widget-clock.png)

The clock widget displays an analog or digital clock. It can also be used to display the current date.
The clock widget displays an analog or digital clock with color customization. It can also be used to display the current date.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this addition was necessary to be emphasized here tbh :)


#### Chart (chart)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ <h3 translate-keep-content translate="widget.clock.settings.header">Clock Settin
-->


<div class="form-group" ng-class="{error: _form.digital_color.$error && _form.submitted}">
<label class="control-label col-lg-2 col-md-2" translate-keep-content translate="widget.clock.digital_color">Digital Color</label>
<div class="col-lg-4 col-md-4">
<div dab-model="form.digital_color" web-colorpicker dab-width="20" dab-height="20" dab-radius="50" dab-vertical="4" dab-rotate="0"
show-grayscale="true"></div>
</div>
</div>


</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div ng-switch-default>
<div ng-switch-on="vm.widget.font_size">
<div ng-switch-when!="">
<ds-widget-clock show-secs="true" show-digital ng-style="{ 'font-size': vm.widget.font_size + 'pt' }" digital-format="vm.widget.digital_format"/>
<ds-widget-clock show-secs="true" show-digital ng-style="{ 'color': vm.widget.digital_color, 'font-size': vm.widget.font_size + 'pt' }" digital-format="vm.widget.digital_format"/>
</div>

<div ng-switch-default>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
analog_theme: widget.analog_theme,
font_size: widget.font_size,
nobackground: widget.nobackground,
digital_format: widget.digital_format
digital_format: widget.digital_format,
digital_color: widget.digital_color
};

$scope.dismiss = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ <h3 translate-keep-content translate="widget.dummy.settings.header">Dummy Settin
<input name="col" ng-disabled="form.useserverformat" ng-model="form.unit" class="form-control" />
</div>
</div>
<div class="form-group" ng-class="{error: _form.unit.$error && _form.submitted}">
<label class="control-label col-xs-3" translate-keep-content translate="widget.dummy.state">State</label>
<div class="col-lg-9 col-md-9">
<div class="checkbox">
<label>
<input type="checkbox" name="usedescription" ng-model="form.usedescription" /> <span translate-keep-content translate="widget.dummy.state.description">Use state description</span>
</label>
</div>
</div>
</div>
<div class="form-group" ng-class="{error: _form.format.$error && _form.submitted}">
<label class="control-label col-xs-3" translate-keep-content translate="widget.common.format">Format</label>
<div class="col-xs-7">
Expand Down Expand Up @@ -100,9 +110,15 @@ <h3 translate-keep-content translate="widget.dummy.settings.header">Dummy Settin
</div>
</div>

<div class="form-group" ng-class="{error: _form.value_color.$error && _form.submitted}">
<label class="control-label col-lg-2 col-md-2" translate-keep-content translate="widget.dummy.value_color">Value color</label>
<div class="col-lg-4 col-md-4">
<div dab-model="form.value_color" web-colorpicker dab-width="20" dab-height="20" dab-radius="50" dab-vertical="4" dab-rotate="0"
show-grayscale="true"></div>
</div>
</div>
</div>


<div class="modal-footer">
<a ng-click="remove()" class="btn btn-danger pull-left" tabindex="-1"><i class="glyphicon glyphicon-trash"></i>&nbsp;<span translate>Delete</span></a>
<a ng-click="dismiss()" class="btn btn-default" tabindex="-1"><i class="glyphicon glyphicon-remove"></i>&nbsp;<span translate>Cancel</span></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<span ng-if="!vm.widget.nolinebreak" ng-if="vm.widget.name">{{vm.widget.name}}</span>
<br ng-if="!vm.widget.nolinebreak && vm.widget.name" />
<widget-icon ng-if="vm.widget.icon && !vm.widget.icon_nolinebreak" size="vm.widget.icon_size" iconset="vm.widget.iconset" icon="vm.widget.icon" inline="vm.widget.icon_nolinebreak" state="vm.state"></widget-icon>
<span ng-hide="vm.widget.icon && vm.widget.icon_replacestext" ng-style="{ 'font-size': vm.widget.font_size + 'pt' }" ng-class="{ 'dummy-value-right': vm.widget.nolinebreak }" class="value">{{vm.value}}<small ng-if="vm.widget.unit">{{vm.widget.unit}}</small></span>
<span ng-hide="vm.widget.icon && vm.widget.icon_replacestext" ng-style="{ 'color': vm.widget.value_color, 'font-size': vm.widget.font_size + 'pt' }" ng-class="{ 'dummy-value-right': vm.widget.nolinebreak }" class="value">{{vm.value}}<small ng-if="vm.widget.unit">{{vm.widget.unit}}</small></span>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,21 @@
vm.value = "N/A";
return;
}
var value = item.transformedState || item.state;

if (vm.widget.usedescription) {
var options = item.stateDescription.options;
if (Array.isArray(options)) {
var option = options.find((element) => element.value === item.state);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the line that is causing problems (arrow functions are iOS Safari 10+, find is iOS Safari 8+).
The iPad 3 apparently runs on iOS 9.

Reference
https://caniuse.com/arrow-functions
https://caniuse.com/array-find
https://en.wikipedia.org/wiki/IPad_(3rd_generation)#Software

It could probably be chenged to options.find((function (element) { return element.value === item.state; }) to make it compatible with iOS 8+.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great if it can be fixed as proposed. I know this is old hardware, but it works great with HabPanel otherwise and HabPanel is a great legacy alternative to the new MainUI that does require more modern hardware to run. Your efforts are greatly appreciated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1433 reimplements the code with techniques found elsewhere (and it seems to work in iOS 6).

image

Thank you for reporting that late minute bug.

if (option) {
var value = option.label;
} else {
var value = item.state;
}
}
} else {
var value = item.transformedState || item.state;
}

if (vm.widget.format) {
if (item.type === "DateTime" || item.type === "DateTimeItem") {
value = $filter('date')(value, vm.widget.format);
Expand Down Expand Up @@ -105,7 +119,9 @@
icon : widget.icon,
icon_size : widget.icon_size,
icon_nolinebreak : widget.icon_nolinebreak,
icon_replacestext: widget.icon_replacestext
icon_replacestext: widget.icon_replacestext,
value_color : widget.value_color,
usedescription : widget.usedescription
};

$scope.dismiss = function() {
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/af.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr ""

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr "Uitleg"

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr ""

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr ""

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr ""

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr ""

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr "Format digital"

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr "Disposició"

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr "Digitální formát"

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr "Rozvržení"

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/da.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr "Digital format"

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr "Opsætning"

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr "Digitales Format"

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr "Layout"

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.ui.habpanel/web/assets/i18n/widgets/el.po
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ msgctxt "widget.clock.digital_format"
msgid "Digital Format"
msgstr "Μορφή ψηφίων"

#. Color picker header
msgctxt "widget.clock.digital_color"
msgid "Digital Color"
msgstr ""

#. Textbox header
msgctxt "widget.clock.font_size"
msgid "Digital Font Size"
Expand Down Expand Up @@ -472,6 +477,21 @@ msgctxt "widget.dummy.layout"
msgid "Layout"
msgstr "Διάταξη"

#. Color picker header
msgctxt "widget.dummy.value_color"
msgid "Value color"
msgstr ""

#. Checkboxes header
msgctxt "widget.dummy.state"
msgid "State"
msgstr ""

#. Checkbox label
msgctxt "widget.dummy.state.description"
msgid "Use state description"
msgstr ""

#. Display name of the widget (appears in the Add Widget dropdown menu in the designer)
msgctxt "widget.frame"
msgid "Frame"
Expand Down
Loading