Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

[BasicUI] Integrate ChartThemes in BasicUI themes #4336

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,7 +21,10 @@
public class WebAppConfig {
private final static String DEFAULT_SITEMAP = "default";
private final static String DEFAULT_ICON_TYPE = "png";
private final static String DEFAULT_THEME = "default";

public final static String THEME_NAME_DEFAULT = "default";
public final static String THEME_NAME_DARK = "dark";
private final static String DEFAULT_THEME = THEME_NAME_DEFAULT;

private String defaultSitemap = DEFAULT_SITEMAP;
private String iconType = DEFAULT_ICON_TYPE;
Expand Down
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.smarthome.core.items.ItemNotFoundException;
import org.eclipse.smarthome.model.sitemap.Chart;
import org.eclipse.smarthome.model.sitemap.Widget;
import org.eclipse.smarthome.ui.basic.internal.WebAppConfig;
import org.eclipse.smarthome.ui.basic.render.RenderException;
import org.eclipse.smarthome.ui.basic.render.WidgetRenderer;
import org.slf4j.Logger;
Expand Down Expand Up @@ -55,13 +56,28 @@ public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderExcep
if (chart.getService() != null) {
chartUrl += "&service=" + chart.getService();
}
// if legend parameter is given, add correspondending GET parameter
if (chart.getLegend() != null) {
if (chart.getLegend()) {
chartUrl += "&legend=true";
} else {
chartUrl += "&legend=false";
}
}
// add theme GET parameter
String chartTheme = null;
switch (config.getTheme()) {
case WebAppConfig.THEME_NAME_DEFAULT:
chartTheme = "bright";
break;
case WebAppConfig.THEME_NAME_DARK:
chartTheme = "dark";
break;
}
if (chartTheme != null) {
chartUrl += "&theme=" + chartTheme;
}
// add timestamp to circumvent browser cache
String url = chartUrl + "&t=" + (new Date()).getTime();

String snippet = getSnippet("chart");
Expand Down