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
Manager UI improvements
Christian Bauer60f9131d5e80
diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.javaindex ea99b1a06..ec4b50458 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.java+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapActivity.java@@ -40,6 +40,7 @@ import org.openremote.model.event.bus.EventBus;import org.openremote.model.event.bus.EventRegistration;import org.openremote.model.geo.GeoJSON;import org.openremote.model.util.Pair;+import org.openremote.model.value.Values;import javax.inject.Inject;import java.util.ArrayList;@@ -194,32 +195,24 @@ public class MapActivity extends AssetBrowsingActivity<MapPlace> implements MapV}protected void showAssetInfoItems() {- List<Pair<String, String>> infoItems = dashboardAttributes.stream()- .map(attribute -> new Pair<>(- attribute.getLabel().orElse(""),- format(- attribute.getFormat().orElse(null),- attribute.getValue().map(Object::toString).orElse(null)- )+ List<MapInfoItem> infoItems = dashboardAttributes.stream()+ .filter(attribute -> attribute.getLabel().isPresent())+ .map(attribute -> new MapInfoItem(+ attribute.getLabel().get(),+ attribute.getFormat().orElse(null),+ attribute.getValue().orElse(null)))- .sorted(Comparator.comparing(pair -> pair.key))+ .sorted(Comparator.comparing(MapInfoItem::getLabel)).collect(Collectors.toList());if (asset.hasGeoFeature()) {- infoItems.add(0, new Pair<>(+ infoItems.add(0, new MapInfoItem(environment.getMessages().location(),- asset.getCoordinatesLabel()+ null,+ Values.create(asset.getCoordinatesLabel())));-}view.showInfoItems(infoItems);}- protected native static String format(String formatString, String value) /*-{- if (formatString === null)- return value;- return $wnd.sprintf(formatString, value);- }-*/;--}diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoItem.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoItem.javanew file mode 100644index 000000000..e62ff330a--- /dev/null+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoItem.java@@ -0,0 +1,49 @@+/*+ * Copyright 2017, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.manager.client.map;++import org.openremote.model.value.Value;++import java.util.Optional;++public class MapInfoItem {++ final protected String label;+ final protected String format;+ final protected Value value;++ public MapInfoItem(String label, String format, Value value) {+ this.label = label;+ this.format = format;+ this.value = value;+ }++ public String getLabel() {+ return label;+ }++ public Optional<String> getFormat() {+ return Optional.ofNullable(format);+ }++ public Optional<Value> getValue() {+ return Optional.ofNullable(value);+ }+}diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.javaindex e3f1757c4..292e36a9f 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.java+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.java@@ -23,17 +23,15 @@ import com.google.gwt.core.client.GWT;import com.google.gwt.resources.client.CssResource;import com.google.gwt.uibinder.client.UiBinder;import com.google.gwt.uibinder.client.UiField;-import com.google.gwt.user.client.ui.FlowPanel;-import com.google.gwt.user.client.ui.HTMLPanel;-import com.google.gwt.user.client.ui.Label;+import com.google.gwt.user.client.ui.*;import elemental.client.Browser;import org.openremote.manager.client.i18n.ManagerMessages;import org.openremote.manager.client.style.WidgetStyle;-import org.openremote.manager.client.widget.AbstractAppPanel;-import org.openremote.manager.client.widget.FormLabel;+import org.openremote.manager.client.widget.*;import org.openremote.manager.client.widget.PopupPanel;-import org.openremote.model.util.Pair;import org.openremote.model.util.TextUtil;+import org.openremote.model.value.Value;+import org.openremote.model.value.Values;import java.util.List;@@ -46,13 +44,13 @@ public class MapInfoPanel extends AbstractAppPanel {public interface Style extends CssResource {- String contentItemKeyLabel();+ String infoItemLabel();String popup();- String contentItemValueLabel();+ String infoItemValue();- String contentItem();+ String infoItem();String panel();@@ -78,29 +76,29 @@ public class MapInfoPanel extends AbstractAppPanel {super(GWT.create(UI.class));}- public void setItems(List<Pair<String, String>> infoItems) {+ public void setItems(List<MapInfoItem> infoItems) {contentPanel.clear();int itemLineHeightPixels = 20;int itemMarginPixels = 8;- int itemHeightPixels = itemLineHeightPixels + (itemMarginPixels*2);+ int itemHeightPixels = itemLineHeightPixels + (itemMarginPixels * 2);int totalMaxHeight = itemHeightPixels * MAX_ITEMS_BEFORE_SCROLLING;- for (Pair<String, String> infoItem : infoItems) {- FormLabel keyLabel = new FormLabel(- TextUtil.ellipsize(infoItem.key, 35)+ for (MapInfoItem infoItem : infoItems) {+ FormLabel itemLabel = new FormLabel(+ TextUtil.ellipsize(infoItem.getLabel(), 35));- keyLabel.addStyleName("flex");- keyLabel.addStyleName(style.contentItemKeyLabel());+ itemLabel.addStyleName("flex");+ itemLabel.addStyleName(style.infoItemLabel());- Label valueLabel = new Label(infoItem.value);- valueLabel.setStyleName(style.contentItemValueLabel());+ Widget itemValue = createItemValue(infoItem);+ itemValue.addStyleName(style.infoItemValue());FlowPanel itemPanel = new FlowPanel();- itemPanel.addStyleName("flex-none layout horizontal center");- itemPanel.addStyleName(style.contentItem());- itemPanel.add(keyLabel);- itemPanel.add(valueLabel);+ itemPanel.addStyleName("flex-none layout horizontal");+ itemPanel.addStyleName(style.infoItem());+ itemPanel.add(itemLabel);+ itemPanel.add(itemValue);contentPanel.add(itemPanel);}@@ -115,4 +113,35 @@ public class MapInfoPanel extends AbstractAppPanel {}, 250);}}++ protected Widget createItemValue(MapInfoItem item) {+ if (!item.getValue().isPresent())+ return new Label("-");+ Value value = item.getValue().get();++ switch (value.getType()) {+ case BOOLEAN:+ return new IconLabel(Values.getBoolean(value).get() ? "check-square" : "square-o");+ default:+ return new Label(+ item.getFormat()+ .map(format -> formatValue(format, value.toString()))+ .orElse(value.toString())+ );+ }+ }++ protected native static String formatValue(String formatString, String value) /*-{+ if (value === null)+ return '-';+ if (formatString === null)+ return value;+ try {+ return $wnd.sprintf(formatString, value);+ } catch (e) {+ console.log(e.message);+ return value;+ }+ }-*/;+}diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.ui.xmlindex 143f70d0e..425c0df75 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.ui.xml+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapInfoPanel.ui.xml@@ -18,17 +18,17 @@overflow: auto;}- .contentItem {+ .infoItem {white-space: nowrap;margin: 8px;}- .contentItemKeyLabel {+ .infoItemLabel {font-size: 14px;line-height: 16px;}- .contentItemValueLabel {+ .infoItemValue {font-size: 18px;line-height: 20px;}diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapView.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapView.javaindex 3ae5df2c2..654b0e3c1 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapView.java+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapView.java@@ -44,5 +44,5 @@ public interface MapView extends IsWidget {void flyTo(double[] coordinates);- void showInfoItems(List<Pair<String, String>> infoItems);+ void showInfoItems(List<MapInfoItem> infoItems);}diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.java b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.javaindex 6c6ded899..936c04779 100644--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.java+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.java@@ -36,7 +36,9 @@ import org.openremote.model.geo.GeoJSON;import org.openremote.model.value.ObjectValue;import javax.inject.Inject;+import java.util.Comparator;import java.util.List;+import java.util.stream.Collectors;public class MapViewImpl extends Composite implements MapView {@@ -138,7 +140,7 @@ public class MapViewImpl extends Composite implements MapView {}@Override- public void showInfoItems(List<Pair<String, String>> infoItems) {+ public void showInfoItems(List<MapInfoItem> infoItems) {if (!mapWidget.isMapReady())return;diff --git a/manager/client/src/main/java/org/openremote/manager/client/widget/IconLabel.java b/manager/client/src/main/java/org/openremote/manager/client/widget/IconLabel.javaindex 9151470cf..b09600531 100644--- a/manager/client/src/main/java/org/openremote/manager/client/widget/IconLabel.java+++ b/manager/client/src/main/java/org/openremote/manager/client/widget/IconLabel.java@@ -25,8 +25,13 @@ public class IconLabel extends InlineLabel {protected String icon;- public IconLabel() {+ public IconLabel(String icon) {setStyleName("or-IconLabel");+ setIcon(icon);+ }++ public IconLabel() {+ this(null);}public String getIcon() {@@ -34,13 +39,15 @@ public class IconLabel extends InlineLabel {}public void setIcon(String icon) {- if (this.icon != null) {+ if (this.icon != null || icon == null) {removeStyleName("fa");removeStyleName("fa-" + this.icon);}this.icon = icon;- addStyleName("fa");- addStyleName("fa-" + icon);+ if (this.icon != null) {+ addStyleName("fa");+ addStyleName("fa-" + icon);+ }}}diff --git a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.javaindex e665bc2c2..02da305d1 100644--- a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java@@ -356,7 +356,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Cons}protected void linkProtocolConfiguration(AssetAttribute protocolConfiguration) {- LOG.info("Linking all attributes that use protocol attribute: " + protocolConfiguration);+ LOG.fine("Linking all attributes that use protocol attribute: " + protocolConfiguration);AttributeRef protocolAttributeRef = protocolConfiguration.getReferenceOrThrow();Protocol protocol = getProtocol(protocolConfiguration);@@ -417,7 +417,7 @@ public class AgentService extends RouteBuilder implements ContainerService, Cons}protected void unlinkProtocolConfiguration(AssetAttribute protocolConfiguration) {- LOG.info("Unlinking all attributes that use protocol attribute: " + protocolConfiguration);+ LOG.fine("Unlinking all attributes that use protocol attribute: " + protocolConfiguration);AttributeRef protocolAttributeRef = protocolConfiguration.getReferenceOrThrow();// Get all assets that have attributes that use this protocol configuration@@ -565,7 +565,6 @@ public class AgentService extends RouteBuilder implements ContainerService, Cons}).orElseGet(() -> {// This is just a non protocol attribute so allow the processing to continue- LOG.fine("Ignoring as it is not for an attribute linked to an agent:" + assetState);return null;});}diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.javaindex 30608422f..9da9ec503 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/AbstractManagerSetup.java@@ -76,9 +76,9 @@ public abstract class AbstractManagerSetup implements Setup {new AssetAttribute("alarmEnabled", AttributeType.BOOLEAN, Values.create(false)).setMeta(new Meta(new MetaItem(LABEL, Values.create("Alarm enabled")),- new MetaItem(READ_ONLY, Values.create(true)),new MetaItem(DESCRIPTION, Values.create("Send notifications when presence is detected")),- new MetaItem(RULE_STATE, Values.create(true))+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)))),new AssetAttribute("vacationDays", AttributeType.INTEGER).setMeta(new Meta(@@ -96,7 +96,8 @@ public abstract class AbstractManagerSetup implements Setup {.setMeta(new MetaItem(LABEL, Values.create("Last executed scene")),new MetaItem(READ_ONLY, Values.create(true)),- new MetaItem(RULE_STATE, Values.create(true))+ new MetaItem(RULE_STATE, Values.create(true)),+ new MetaItem(SHOW_ON_DASHBOARD, Values.create(true))));return apartment;