Skip to content

Commit

Permalink
Add 6 months and 2 years periods for sitemap charts
Browse files Browse the repository at this point in the history
Changes in Baisc UI and in Main UI (sitemap generator)

Depends on openhab/openhab-core#3863

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo committed Nov 4, 2023
1 parent f4bbba0 commit 4160b42
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public EList<Widget> renderWidget(Widget w, StringBuilder sb, String sitemap) th
List.of("Last 8 hours", "8h"), List.of("Last 12 hours", "12h"), List.of("Last day", "D"),
List.of("Last 2 days", "2D"), List.of("Last 3 days", "3D"), List.of("Last week", "W"),
List.of("Last 2 weeks", "2W"), List.of("Last month", "M"), List.of("Last 2 months", "2M"),
List.of("Last 4 months", "4M"), List.of("Last year", "Y"));
List.of("Last 4 months", "4M"), List.of("Last 6 months", "6M"), List.of("Last year", "Y"),
List.of("Last 2 years", "2Y"));
StringBuilder rowSB = new StringBuilder();
for (List<String> period : periods) {
buildRow(chart, period.get(0), period.get(1), chart.getPeriod(), rowSB);
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.ui.basic/web-src/smarthome.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@
}

_t.period = event.target.getAttribute("value");
_t.url = _t.url.replace(/&period=(h|4h|8h|12h|D|2D|3D|W|2W|M|2M|4M|Y)/, "&period=" + _t.period);
_t.url = _t.url.replace(/&period=(h|4h|8h|12h|D|2D|3D|W|2W|M|2M|4M|6M|Y|2Y)/, "&period=" + _t.period);
_t.image.setAttribute("src", _t.url + "&t=" + Date.now());

setTimeout(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default {
{ key: 'M', value: 'Month' },
{ key: '2M', value: '2 Months' },
{ key: '4M', value: '4 Months' },
{ key: 'Y', value: 'Year' }
{ key: '6M', value: '6 Months' },
{ key: 'Y', value: 'Year' },
{ key: '2Y', value: '2 Years' }
],
inputHintDefs: [
{ key: 'text', value: 'Text' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export default {
}
})
widgetList.filter(widget => widget.component === 'Chart').forEach(widget => {
if (!(widget.config && widget.config.period && ['h', '4h', '8h', '12h', 'D', '2D', '3D', 'W', '2W', 'M', '2M', '4M', 'Y'].includes(widget.config.period))) {
if (!(widget.config && widget.config.period && ['h', '4h', '8h', '12h', 'D', '2D', '3D', 'W', '2W', 'M', '2M', '4M', '6M', 'Y', '2Y'].includes(widget.config.period))) {
let label = widget.config && widget.config.label ? widget.config.label : 'without label'
validationWarnings.push(widget.component + ' widget ' + label + ', invalid period configured: ' + widget.config.period)
}
Expand Down

0 comments on commit 4160b42

Please sign in to comment.