100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Moved font styling from body to or-Viewport, renamed GET queryPublicAssets to getPublicAssets, Requests#configure accepts service URL instead of using Window.Location, fixes #72
Christian Bauer0d50434b34bf
diff --git a/client/src/main/java/org/openremote/app/client/rest/Requests.java b/client/src/main/java/org/openremote/app/client/rest/Requests.javaindex c76247e72..1a8086587 100644--- a/client/src/main/java/org/openremote/app/client/rest/Requests.java+++ b/client/src/main/java/org/openremote/app/client/rest/Requests.java@@ -71,9 +71,8 @@ public class Requests {this.constraintViolationReader = constraintViolationReader;}- public void configure(String realm) {- Location location = Browser.getWindow().getLocation();- REST.apiURL = "//" + location.getHostname() + ":" + location.getPort() + "/" + realm;+ public void configure(String apiUrl) {+ REST.apiURL = apiUrl;REST.loglevel = LOG.isLoggable(Level.FINEST) ? 1 : 0;}diff --git a/client/src/main/webapp/src/or-app/or-app.html b/client/src/main/webapp/src/or-app/or-app.htmlindex 573ab7db0..90320ef32 100644--- a/client/src/main/webapp/src/or-app/or-app.html+++ b/client/src/main/webapp/src/or-app/or-app.html@@ -31,7 +31,7 @@border: 2px solid var(--theme-lightgreen);border-top-color: var(--theme-black);border-radius: 50%;- -webkit-animation: loadingspin 1s linear infinite;+ -webkit-animation: loaderSpin 1s linear infinite;animation: loaderSpin 1s linear infinite;}@@ -81,7 +81,7 @@error="{{error}}"></or-app-security><template is="dom-if" if="[[error]]">- <div id="errorView">+ <div id="errorView" class="or-Viewport"><h1>[[defaultErrorMessage]]</h1><h5>[[error]]</h5></div>@@ -231,7 +231,7 @@/*** The listeners to notify before event service WebSocket is closed.*/- webSocketCloseListeners : {+ webSocketCloseListeners: {type: Array,value: () => {return [];@@ -349,10 +349,10 @@// Extract manager host URI based on where this component is hosted; it is assumed that the component// is being hosted in a manager instance and that is the instance you want to connect to.- var managerHost = '';- var hostURI = this.importPath;- if ( hostURI ) {- managerHost = '//' + new URL(hostURI).host;+ let managerHost = '';+ let hostURI = this.importPath;+ if (hostURI) {+ managerHost = '//' + new URL(hostURI).host;}this.managerHost = managerHost;@@ -484,7 +484,7 @@});- requests.configure(this.tenantRealm);+ requests.configure(this.managerHost + "/" + this.tenantRealm);this.set("requests", requests);}@@ -495,7 +495,7 @@return;}- let serviceUrl = ("https:" === location.protocol ? "wss" : "ws") + "://" + location.hostname + ":" + location.port + "/websocket/events";+ let serviceUrl = ("https:" === location.protocol ? "wss" : "ws") + ":" + this.managerHost + "/websocket/events";this.getSecurity().authorizeUrl(serviceUrl, (authenticatedServiceUrl) => {this.webSocket = new WebSocket(authenticatedServiceUrl);diff --git a/client/src/main/webapp/src/or-app/or-style.html b/client/src/main/webapp/src/or-app/or-style.htmlindex 3a71d3c36..c2af1be69 100644--- a/client/src/main/webapp/src/or-app/or-style.html+++ b/client/src/main/webapp/src/or-app/or-style.html@@ -12,8 +12,6 @@}* html, body {- font-family: 'Open Sans', Helvetica, Arial, Lucida, sans-serif;- font-weight: 500 !important;box-sizing: border-box;}@@ -25,11 +23,6 @@overflow: hidden;}- body {- font-size: 0.9em;- letter-spacing: 0.02em;- }-*:focus {outline: 0;}@@ -41,6 +34,14 @@margin: 0;}+ .or-Viewport,+ .or-PopupPanel {+ font-family: 'Open Sans', Helvetica, Arial, Lucida, sans-serif;+ font-weight: 500 !important;+ font-size: 0.9em;+ letter-spacing: 0.02em;+ }+.or-NavItem {margin: 0.4em 1.2em 0 1.2em;font-size: 1.1em;diff --git a/deployment/manager/consoles/customerA/index.html b/deployment/manager/consoles/customerA/index.htmlindex e1f707546..4a1edd630 100644--- a/deployment/manager/consoles/customerA/index.html+++ b/deployment/manager/consoles/customerA/index.html@@ -71,123 +71,129 @@<!-- ############## Required: One <or-app> should wrap your frontend, you can enforce login/authentication ############## --><or-app login tenant-realm="customerA">- <!-- You can use your own styles or the OpenRemote styles and theme -->- <a href="#" class="myAppHeadline">- The OpenRemote console application of the <code>customerA</code> tenant- </a>-- <!-- This is a container element that has some padding and visual separation from other containers -->- <div class="or-MainContent">-- <h3 style="color: var(--theme-red);">Note: This is under development and incomplete.</h3>-- <p>- On your OpenRemote installation, edit the HTML content in- <code>deployment/manager/consoles/customerA/</code>.- </p>- <p>- You can duplicate the <code>customerA</code> directory to create new console applications for other- tenants/realms.- </p>- <p>- View the source in your web browser and follow the examples on this page to write your own OpenRemote- application, it's easy with <a href="https://www.webcomponents.org/">Web Components</a>.- </p>- </div>+ <!-- With or-Viewport you get OpenRemote default fonts -->+ <div class="flex layout vertical or-Viewport">++ <!-- You can use your own styles or the OpenRemote styles and theme -->+ <a href="#" class="myAppHeadline">+ The OpenRemote console application of the <code>customerA</code> tenant+ </a>++ <!-- This is a container element that has some padding and visual separation from other containers -->+ <div class="or-MainContent">++ <h3 style="color: var(--theme-red);">Note: This is under development and incomplete.</h3>++ <p>+ On your OpenRemote installation, edit the HTML content in+ <code>deployment/manager/consoles/customerA/</code>.+ </p>+ <p>+ You can duplicate the <code>customerA</code> directory to create new console applications for other+ tenants/realms.+ </p>+ <p>+ View the source in your web browser and follow the examples on this page to write your own OpenRemote+ application, it's easy with <a href="https://www.webcomponents.org/">Web Components</a>.+ </p>+ </div>- <!-- Switch to horizontal layout but flex vertical first and take as much vertical space as needed -->- <div class="flex layout horizontal">+ <!-- Switch to horizontal layout but flex vertical first and take as much vertical space as needed -->+ <div class="flex layout horizontal">- <!-- Flex and take as much horizontal space as possible -->- <div class="flex layout vertical">+ <!-- Flex and take as much horizontal space as possible -->+ <div class="flex layout vertical">- <!-- Execute an asset query and show a nice scrollable list -->- <or-asset-list class="myAssetList flex or-MainContent or-FormList"- select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"- asset-type="urn:openremote:asset:residence">+ <!-- Execute an asset query and show a nice scrollable list -->+ <or-asset-list class="myAssetList flex or-MainContent or-FormList"+ select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"+ asset-type="urn:openremote:asset:residence">- <!-- Render each asset with a template -->- <template>- <div class="or-FormListItem layout horizontal center justified">- <div>Residence: {{asset.name}}</div>- <div>Parent: {{asset.parentName}}</div>- <div>Created On: {{asset.createdOn}}</div>- </div>- </template>+ <!-- Render each asset with a template -->+ <template>+ <div class="or-FormListItem layout horizontal center justified">+ <div>Residence: {{asset.name}}</div>+ <div>Parent: {{asset.parentName}}</div>+ <div>Created On: {{asset.createdOn}}</div>+ </div>+ </template>- </or-asset-list>+ </or-asset-list>- <!-- Execute an asset query and show a nice scrollable list -->- <or-asset-list class="myAssetList flex or-MainContent or-FormList"- select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"- asset-type="urn:openremote:asset:room">+ <!-- Execute an asset query and show a nice scrollable list -->+ <or-asset-list class="myAssetList flex or-MainContent or-FormList"+ select-include="ALL_EXCEPT_PATH_AND_ATTRIBUTES"+ asset-type="urn:openremote:asset:room">- <!-- Render each asset with a template -->- <template>- <div class="or-FormListItem layout horizontal center justified">- <div>Room: {{asset.name}}</div>- <div>Parent: {{asset.parentName}}</div>- <div>Created On: {{asset.createdOn}}</div>- </div>- </template>+ <!-- Render each asset with a template -->+ <template>+ <div class="or-FormListItem layout horizontal center justified">+ <div>Room: {{asset.name}}</div>+ <div>Parent: {{asset.parentName}}</div>+ <div>Created On: {{asset.createdOn}}</div>+ </div>+ </template>- </or-asset-list>+ </or-asset-list>- </div>+ </div>- <!-- Flex and take as much horizontal space as possible, show scrollbars if content doesn't fit. -->- <div class="flex or-MainContent scroll">- <!-- Execute AssetQuery and subscribe for attribute changes -->- <or-asset type="room" id="blabla">-- <!-- Bind asset attributes to elements -->- <p>- Temperature of the room is: <span data-attribute="currentTemp"></span>- </p>-- <form>- Set desired temperature:- <input data-attribute="setTemp" data-validate>- <submit data-asset-action></submit>- <!-- Defaults to 'update' as this is what restricted users can do -->- </form>-- <!-- Show hide elements based on boolean asset attribute -->- <p data-visible="humidityBool">- Humidity too high!- </p>- <p data-attached="co2Bool">- Too much CO2!- </p>- </or-asset>- </div>+ <!-- Flex and take as much horizontal space as possible, show scrollbars if content doesn't fit. -->+ <div class="flex or-MainContent scroll">+ <!-- Execute AssetQuery and subscribe for attribute changes -->+ <or-asset type="room" id="blabla">++ <!-- Bind asset attributes to elements -->+ <p>+ Temperature of the room is: <span data-attribute="currentTemp"></span>+ </p>++ <form>+ Set desired temperature:+ <input data-attribute="setTemp" data-validate>+ <submit data-asset-action></submit>+ <!-- Defaults to 'update' as this is what restricted users can do -->+ </form>++ <!-- Show hide elements based on boolean asset attribute -->+ <p data-visible="humidityBool">+ Humidity too high!+ </p>+ <p data-attached="co2Bool">+ Too much CO2!+ </p>+ </or-asset>+ </div>- </div>+ </div>- <div class="or-MainContent">- <div class="layout horizontal or-FormGroup">- <div class="or-FormField">+ <div class="or-MainContent">+ <div class="layout horizontal or-FormGroup">+ <div class="or-FormField">- <button class="or-FormControl or-FormButton or-PushButton"- onclick="openremote.INSTANCE.toasts.showToast(+ <button class="or-FormControl or-FormButton or-PushButton"+ onclick="openremote.INSTANCE.toasts.showToast(new openremote.toast.Toast(openremote.toast.Toast.Type.SUCCESS,'Welcome ' + openremote.INSTANCE.user + ', on ' + openremote.INSTANCE.tenantRealm + '. It is ' + new Date() + '.',3000))">Show a toast- </button>+ </button>- <button class="or-FormControl or-FormButton or-PushButton"- onclick="document.querySelectorAll('.myAssetList').forEach((assetList) => {assetList.executeQuery()})">Refresh asset lists- </button>+ <button class="or-FormControl or-FormButton or-PushButton"+ onclick="document.querySelectorAll('.myAssetList').forEach((assetList) => {assetList.executeQuery()})">+ Refresh asset lists+ </button>- <button class="or-FormControl or-FormButtonDanger or-PushButton"- onclick="document.querySelector('or-app').logout()">Logout- </button>+ <button class="or-FormControl or-FormButtonDanger or-PushButton"+ onclick="document.querySelector('or-app').logout()">Logout+ </button>+ </div></div></div>+</div></or-app>diff --git a/keycloak/theme/account/template.ftl b/keycloak/theme/account/template.ftlindex 28be2f5b2..a175a30c1 100644--- a/keycloak/theme/account/template.ftl+++ b/keycloak/theme/account/template.ftl@@ -32,7 +32,7 @@<or-app>- <div class="flex layout horizontal">+ <div class="flex layout horizontal or-Viewport"><div class="layout vertical or-SecondaryNav"><div class="or-SecondaryNavItem <#if active=='account'>active</#if>"><div class="fa fa-user" style="width: 1em; margin-right:0.4em;"></div><a href="${url.accountUrl}">${msg("account")}</a></div><#if features.passwordUpdateSupported><div class="or-SecondaryNavItem <#if active=='password'>active</#if>"><div class="fa fa-key" style="width: 1em; margin-right:0.4em;"></div><a href="${url.passwordUrl}">${msg("password")}</a></div></#if>diff --git a/keycloak/theme/login/template.ftl b/keycloak/theme/login/template.ftlindex ca018f991..f45b14edd 100755--- a/keycloak/theme/login/template.ftl+++ b/keycloak/theme/login/template.ftl@@ -32,7 +32,7 @@<or-app>- <div class="flex layout vertical center-center">+ <div class="flex layout vertical center-center or-Viewport"><div class="layout horizontal center-center" style="margin: 1em;"><a href="https://www.openremote.com/">diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.javaindex fa46670fc..2de833bed 100644--- a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java@@ -38,10 +38,12 @@ import org.openremote.model.value.ValueException;import org.openremote.model.value.Values;import javax.ws.rs.WebApplicationException;+import java.io.IOException;import java.util.*;import java.util.logging.Logger;import static javax.ws.rs.core.Response.Status.*;+import static org.openremote.container.Container.JSON;import static org.openremote.model.asset.AssetQuery.*;import static org.openremote.model.attribute.AttributeEvent.Source.CLIENT;import static org.openremote.model.util.TextUtil.isNullOrEmpty;@@ -500,14 +502,14 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour}}-// @Override-// public Asset[] queryPublicAssets(RequestParams requestParams, String q) {-// AssetQuery assetQuery;-// try {-// assetQuery = JSON.readValue(q, AssetQuery.class);-// } catch (IOException ex) {-// throw new WebApplicationException("Error parsing query parameter 'q' as JSON object", BAD_REQUEST);-// }-// return queryPublicAssets(requestParams, assetQuery);-// }+ @Override+ public Asset[] getPublicAssets(RequestParams requestParams, String q) {+ AssetQuery assetQuery;+ try {+ assetQuery = JSON.readValue(q, AssetQuery.class);+ } catch (IOException ex) {+ throw new WebApplicationException("Error parsing query parameter 'q' as JSON object", BAD_REQUEST);+ }+ return queryPublicAssets(requestParams, assetQuery);+ }}diff --git a/model/src/main/java/org/openremote/model/asset/AssetResource.java b/model/src/main/java/org/openremote/model/asset/AssetResource.javaindex 3ff9e24d3..3fe642441 100644--- a/model/src/main/java/org/openremote/model/asset/AssetResource.java+++ b/model/src/main/java/org/openremote/model/asset/AssetResource.java@@ -248,16 +248,15 @@ public interface AssetResource {@SuppressWarnings("unusable-by-js")Asset[] queryPublicAssets(@BeanParam RequestParams requestParams, AssetQuery query);-// TODO: Disabled for now because in jsapi this hides the post method and doesn't work-// /**-// * Retrieve public assets using an {@link AssetQuery} as a JSON serialized query parameter.-// * <p>-// * Allows un-authenticated 'public' users to query public assets for a realm.-// */-// @GET-// @Path("public/query")-// @Produces(APPLICATION_JSON)-// @SuccessStatusCode(200)-// @SuppressWarnings("unusable-by-js")-// Asset[] queryPublicAssets(@BeanParam RequestParams requestParams, @QueryParam("q") String q);+ /**+ * Retrieve public assets using an {@link AssetQuery} as a JSON serialized query parameter.+ * <p>+ * Allows un-authenticated 'public' users to query public assets for a realm.+ */+ @GET+ @Path("public/query")+ @Produces(APPLICATION_JSON)+ @SuccessStatusCode(200)+ @SuppressWarnings("unusable-by-js")+ Asset[] getPublicAssets(@BeanParam RequestParams requestParams, @QueryParam("q") String q);}