Skip to content

Commit ad27a71

Browse files
ghyskaikreuzer
authored andcommitted
Add default UI bundle (openhab#178)
This add the UI in its current state of development, the intent is to test the integration in the distro early. The other apps are listed on the home page by calling the new REST endpoint introduced in openhab/openhab-core#1329 The onboarding wizard implementation is not complete so it isn't possible to select a startup package with the UI yet. The wizard steps will be discussed in a separate issue; it should however be possible to install addons as needed from the settings screen. Signed-off-by: Yannick Schaus <[email protected]>
1 parent 81b1cc5 commit ad27a71

File tree

222 files changed

+33273
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+33273
-48
lines changed

bom/openhab-ui/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
<name>openHAB UI :: BOM :: openHAB UI</name>
1515

1616
<dependencies>
17+
<dependency>
18+
<groupId>org.openhab.ui.bundles</groupId>
19+
<artifactId>org.openhab.ui</artifactId>
20+
<version>${project.version}</version>
21+
<scope>compile</scope>
22+
</dependency>
1723
<dependency>
1824
<groupId>org.openhab.ui.bundles</groupId>
1925
<artifactId>org.openhab.ui.basic</artifactId>

bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/BasicUITile.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public String getOverlay() {
4242

4343
@Override
4444
public String getImageUrl() {
45-
return "img/basicui.png";
45+
return "res/img/basicui.png";
4646
}
4747
}

bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/CometVisuTile.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ public String getOverlay() {
9595

9696
@Override
9797
public String getImageUrl() {
98-
return "img/cometvisu.png";
98+
return "res/img/cometvisu.png";
9999
}
100100
}
Binary file not shown.
Binary file not shown.

bundles/org.openhab.ui.habpanel/src/main/java/org/openhab/ui/habpanel/internal/HABPanelTile.java

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
package org.openhab.ui.habpanel.internal;
1414

1515
import org.openhab.core.ui.tiles.Tile;
16+
import org.osgi.service.component.annotations.Activate;
17+
import org.osgi.service.component.annotations.Component;
18+
import org.osgi.service.component.annotations.Deactivate;
19+
import org.osgi.service.component.annotations.Reference;
1620
import org.osgi.service.http.HttpService;
1721
import org.osgi.service.http.NamespaceException;
1822
import org.slf4j.Logger;
@@ -24,6 +28,7 @@
2428
* @author Yannick Schaus - Initial contribution
2529
*
2630
*/
31+
@Component
2732
public class HABPanelTile implements Tile {
2833

2934
@Override
@@ -52,6 +57,7 @@ public String getImageUrl() {
5257

5358
protected HttpService httpService;
5459

60+
@Activate
5561
protected void activate() {
5662
try {
5763
httpService.registerResources(HABPANEL_ALIAS, "web", null);
@@ -61,11 +67,13 @@ protected void activate() {
6167
}
6268
}
6369

70+
@Deactivate
6471
protected void deactivate() {
6572
httpService.unregister(HABPANEL_ALIAS);
6673
logger.info("Stopped HABPanel");
6774
}
6875

76+
@Reference
6977
protected void setHttpService(HttpService httpService) {
7078
this.httpService = httpService;
7179
}

bundles/org.openhab.ui.habpanel/src/main/java/org/openhab/ui/habpanel/internal/rest/HABPanelResource.java

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.openhab.ui.habpanel.internal.gallery.GalleryProviderFactory;
3232
import org.openhab.ui.habpanel.internal.gallery.GalleryWidgetProvider;
3333
import org.openhab.ui.habpanel.internal.gallery.GalleryWidgetsListItem;
34+
import org.osgi.service.component.annotations.Component;
3435
import org.slf4j.Logger;
3536
import org.slf4j.LoggerFactory;
3637

@@ -47,6 +48,7 @@
4748
* @author Yannick Schaus - Initial contribution
4849
*
4950
*/
51+
@Component
5052
@Path(HABPanelResource.PATH_HABPANEL)
5153
@Api(HABPanelResource.PATH_HABPANEL)
5254
public class HABPanelResource implements RESTResource {

bundles/org.openhab.ui.habpanel/src/main/resources/OSGI-INF/dashboardtile.xml

-25
This file was deleted.

bundles/org.openhab.ui.habpanel/src/main/resources/OSGI-INF/habpanelresource.xml

-21
This file was deleted.

bundles/org.openhab.ui/.classpath

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry excluding="**" kind="src" output="target/classes" path="web">
15+
<attributes>
16+
<attribute name="maven.pomderived" value="true"/>
17+
</attributes>
18+
</classpathentry>
19+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
20+
<attributes>
21+
<attribute name="optional" value="true"/>
22+
<attribute name="maven.pomderived" value="true"/>
23+
<attribute name="test" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
27+
<attributes>
28+
<attribute name="maven.pomderived" value="true"/>
29+
</attributes>
30+
</classpathentry>
31+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
32+
<attributes>
33+
<attribute name="maven.pomderived" value="true"/>
34+
</attributes>
35+
</classpathentry>
36+
<classpathentry kind="src" path="target/generated-sources/annotations">
37+
<attributes>
38+
<attribute name="optional" value="true"/>
39+
</attributes>
40+
</classpathentry>
41+
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
42+
<attributes>
43+
<attribute name="optional" value="true"/>
44+
<attribute name="test" value="true"/>
45+
</attributes>
46+
</classpathentry>
47+
<classpathentry kind="output" path="target/classes"/>
48+
</classpath>

bundles/org.openhab.ui/.project

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>org.openhab.ui</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>

bundles/org.openhab.ui/NOTICE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This content is produced and maintained by the openHAB project.
2+
3+
* Project home: https://www.openhab.org
4+
5+
== Declared Project Licenses
6+
7+
This program and the accompanying materials are made available under the terms
8+
of the Eclipse Public License 2.0 which is available at
9+
https://www.eclipse.org/legal/epl-2.0/.
10+
11+
== Source Code
12+
13+
https://github.com/openhab/openhab-webui

bundles/org.openhab.ui/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Default UI
2+
3+
This is openHAB's default UI.

bundles/org.openhab.ui/bnd.bnd

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Bundle-SymbolicName: ${project.artifactId}
2+
Service-Component: OSGI-INF/*.xml

bundles/org.openhab.ui/pom.xml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.openhab.ui.bundles</groupId>
6+
<artifactId>org.openhab.ui.reactor.bundles</artifactId>
7+
<version>3.0.0-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>org.openhab.ui</artifactId>
11+
<name>openHAB UI :: Bundles :: Default UI</name>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.openhab.core.bundles</groupId>
16+
<artifactId>org.openhab.core</artifactId>
17+
<version>${project.version}</version>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.openhab.core.bundles</groupId>
21+
<artifactId>org.openhab.core.io.rest</artifactId>
22+
<version>${project.version}</version>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.openhab.core.bundles</groupId>
26+
<artifactId>org.openhab.core.ui</artifactId>
27+
<version>${project.version}</version>
28+
</dependency>
29+
</dependencies>
30+
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>com.github.eirslett</groupId>
35+
<artifactId>frontend-maven-plugin</artifactId>
36+
<version>1.0</version>
37+
38+
<configuration>
39+
<nodeVersion>v8.10.0</nodeVersion>
40+
<npmVersion>5.6.0</npmVersion>
41+
<workingDirectory>web</workingDirectory>
42+
</configuration>
43+
44+
<executions>
45+
<execution>
46+
<id>Install node and npm</id>
47+
<goals>
48+
<goal>install-node-and-npm</goal>
49+
</goals>
50+
<phase>generate-resources</phase>
51+
</execution>
52+
53+
<execution>
54+
<id>npm install</id>
55+
<goals>
56+
<goal>npm</goal>
57+
</goals>
58+
<configuration>
59+
<arguments>install</arguments>
60+
</configuration>
61+
</execution>
62+
63+
<execution>
64+
<id>npm run build-prod</id>
65+
<goals>
66+
<goal>npm</goal>
67+
</goals>
68+
<configuration>
69+
<arguments>run build-prod</arguments>
70+
</configuration>
71+
</execution>
72+
</executions>
73+
</plugin>
74+
<plugin>
75+
<groupId>org.codehaus.mojo</groupId>
76+
<artifactId>build-helper-maven-plugin</artifactId>
77+
<executions>
78+
<execution>
79+
<goals>
80+
<goal>add-resource</goal>
81+
</goals>
82+
<phase>generate-resources</phase>
83+
<configuration>
84+
<resources>
85+
<resource>
86+
<directory>web/www</directory>
87+
<targetPath>app</targetPath>
88+
</resource>
89+
</resources>
90+
</configuration>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
97+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright (c) 2010-2020 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.ui.internal;
14+
15+
import java.util.Map;
16+
17+
import org.openhab.core.net.HttpServiceUtil;
18+
import org.osgi.framework.BundleContext;
19+
import org.osgi.service.component.ComponentContext;
20+
import org.osgi.service.component.annotations.Activate;
21+
import org.osgi.service.component.annotations.Component;
22+
import org.osgi.service.component.annotations.Deactivate;
23+
import org.osgi.service.component.annotations.Reference;
24+
import org.osgi.service.http.HttpContext;
25+
import org.osgi.service.http.HttpService;
26+
import org.osgi.service.http.NamespaceException;
27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
29+
30+
/**
31+
* This service register the default UI's resources in the HTTP context.
32+
*
33+
* @author Yannick Schaus - Initial contribution
34+
*/
35+
@Component(immediate = true, name = "org.openhab.ui")
36+
public class UIService {
37+
38+
private final Logger logger = LoggerFactory.getLogger(UIService.class);
39+
40+
protected HttpService httpService;
41+
42+
@Activate
43+
protected void activate(ComponentContext componentContext, Map<String, Object> properties) {
44+
BundleContext bundleContext = componentContext.getBundleContext();
45+
HttpContext httpContext = httpService.createDefaultHttpContext();
46+
try {
47+
httpService.registerResources("/", "app", httpContext);
48+
if (HttpServiceUtil.getHttpServicePort(bundleContext) > 0) {
49+
logger.info("Started UI on port {}", HttpServiceUtil.getHttpServicePort(bundleContext));
50+
} else {
51+
logger.info("Started UI");
52+
}
53+
} catch (NamespaceException e) {
54+
logger.error("Error during UI startup: {}", e.getMessage());
55+
}
56+
}
57+
58+
@Deactivate
59+
protected void deactivate(ComponentContext componentContext) {
60+
httpService.unregister("/");
61+
logger.info("Stopped UI");
62+
}
63+
64+
@Reference
65+
protected void setHttpService(HttpService httpService) {
66+
this.httpService = httpService;
67+
}
68+
69+
protected void unsetHttpService(HttpService httpService) {
70+
this.httpService = null;
71+
}
72+
}

0 commit comments

Comments
 (0)