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

Commit

Permalink
[BasicUI] Integrate ChartThemes in BasicUI themes (#4336)
Browse files Browse the repository at this point in the history
Take a matching ChartTheme for the current BasicUI theme.

Signed-off-by: Holger Reichert <mail@h0lger.de>
  • Loading branch information
hreichert authored and kaikreuzer committed Sep 26, 2017
1 parent ccca71e commit e135552
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit e135552

Please sign in to comment.