Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Implemented asset browser

Christian Bauer1adc03521251
diff --git a/manager/client/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.ui.xml
index 7c6b4e957..6d00474d2 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.ui.xml
+++ b/manager/client/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.ui.xml
@@ -13,16 +13,19 @@
</ui:style>
<g:HTMLPanel styleName="layout horizontal end-justified {widgetStyle.SecondaryNav} {themeStyle.SecondaryNav}">
- <g:Hyperlink ui:field="overviewLink"
+ <w:Hyperlink ui:field="overviewLink"
addStyleNames="{style.navItem} {widgetStyle.SecondaryNavItem} {themeStyle.SecondaryNavItem}"
+ icon="dashboard"
text="{managerMessages.overview}"/>
- <g:Hyperlink ui:field="tenantsLink"
+ <w:Hyperlink ui:field="tenantsLink"
addStyleNames="{style.navItem} {widgetStyle.SecondaryNavItem} {themeStyle.SecondaryNavItem}"
+ icon="group"
text="{managerMessages.manageTenants}"/>
- <g:Hyperlink ui:field="usersLink"
+ <w:Hyperlink ui:field="usersLink"
addStyleNames="{style.navItem} {widgetStyle.SecondaryNavItem} {themeStyle.SecondaryNavItem}"
+ icon="user"
text="{managerMessages.manageUsers}"/>
</g:HTMLPanel>
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/Asset.java b/manager/client/src/main/java/org/openremote/manager/client/assets/Asset.java
new file mode 100644
index 000000000..285c8a6fc
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/Asset.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016, 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.assets;
+
+public class Asset {
+
+ public enum Type {
+ COMPOSITE,
+ SENSOR
+ }
+
+ public static boolean isRoot(Asset asset) {
+ return asset.getId() == null;
+ }
+
+ public static final String ROOT_ID = null;
+ public static final String ROOT_TYPE = Type.COMPOSITE.name();
+ public static final String ROOT_LABEL = "ROOT";
+ public static final String ROOT_LOCATION = null;
+
+ public String id;
+ public String type;
+ public String displayName;
+ public String location;
+
+ public Asset() {
+ }
+
+ public Asset(String id, String type, String displayName, String location) {
+ this.id = id;
+ this.type = type;
+ this.displayName = displayName;
+ this.location = location;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsActivity.java b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsActivity.java
index 04a3151d8..46af00146 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsActivity.java
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsActivity.java
@@ -21,6 +21,7 @@ package org.openremote.manager.client.assets;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
+import org.openremote.manager.client.assets.browser.AssetBrowser;
import org.openremote.manager.client.event.bus.EventBus;
import org.openremote.manager.client.event.bus.EventRegistration;
import org.openremote.manager.client.mvp.AppActivity;
@@ -40,14 +41,17 @@ public class AssetsActivity
private static final Logger LOG = Logger.getLogger(AssetsActivity.class.getName());
final AssetsView view;
+ final AssetBrowser.Presenter assetBrowserPresenter;
final PlaceController placeController;
final EventBus eventBus;
@Inject
public AssetsActivity(AssetsView view,
+ AssetBrowser.Presenter assetBrowserPresenter,
PlaceController placeController,
EventBus eventBus) {
this.view = view;
+ this.assetBrowserPresenter = assetBrowserPresenter;
this.placeController = placeController;
this.eventBus = eventBus;
}
@@ -69,41 +73,7 @@ public class AssetsActivity
}
@Override
- public void loadAssetChildren(AssetsView.Asset parent, Consumer<List<AssetsView.Asset>> consumer) {
- if (parent.getId() == null) {
- consumer.accept(Arrays.asList(
- new AssetsView.Asset("composite:gateways", "Composite", "Gateways", null),
- new AssetsView.Asset("composite:buildings", "Composite", "Buildings", null),
- new AssetsView.Asset("composite:rooms", "Composite", "Rooms", null),
- new AssetsView.Asset("composite:thermostats", "Composite", "Thermostats", null)
- ));
- return;
- } else if (parent.getType().equals("Composite")) {
- if (parent.getId().equals("composite:gateways")) {
- consumer.accept(Arrays.asList(
- new AssetsView.Asset("1", "Composite", "Gateway A", "123.123"),
- new AssetsView.Asset("2", "Composite", "Gateway B", "123.123"),
- new AssetsView.Asset("3", "Composite", "Gateway C", "123.123"),
- new AssetsView.Asset("4", "Composite", "Gateway D", "123.123"),
- new AssetsView.Asset("5", "Composite", "Gateway E", "123.123")
- ));
- return;
- }
-
- if (parent.getId().equals("1")) {
- consumer.accept(Arrays.asList(
- new AssetsView.Asset("11", "Sensor", "Sensor 1", "123.123"),
- new AssetsView.Asset("22", "Sensor", "Sensor 2", "123.123"),
- new AssetsView.Asset("33", "Sensor", "Sensor 3", "123.123")
- ));
- return;
- }
- }
- consumer.accept(new ArrayList<>());
- }
-
- @Override
- public void onAssetSelected(AssetsView.Asset asset) {
- view.setAssetDisplayName(asset.getDisplayName());
+ public AssetBrowser getAssetBrowser() {
+ return assetBrowserPresenter.getView();
}
}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsModule.java b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsModule.java
index 7e5856f45..7fa98c242 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsModule.java
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsModule.java
@@ -21,11 +21,17 @@ package org.openremote.manager.client.assets;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Singleton;
+import org.openremote.manager.client.assets.browser.AssetBrowser;
+import org.openremote.manager.client.assets.browser.AssetBrowserImpl;
+import org.openremote.manager.client.assets.browser.AssetBrowserPresenter;
public class AssetsModule extends AbstractGinModule {
@Override
protected void configure() {
+ bind(AssetBrowser.class).to(AssetBrowserImpl.class).in(Singleton.class);
+ bind(AssetBrowser.Presenter.class).to(AssetBrowserPresenter.class).in(Singleton.class);
+
bind(AssetsView.class).to(AssetsViewImpl.class).in(Singleton.class);
bind(AssetsActivity.class);
}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsView.java b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsView.java
index 7e09951c9..bba65b10d 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsView.java
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsView.java
@@ -20,67 +20,14 @@
package org.openremote.manager.client.assets;
import com.google.gwt.user.client.ui.IsWidget;
-import org.openremote.manager.shared.Consumer;
-
-import java.util.List;
+import org.openremote.manager.client.assets.browser.AssetBrowser;
public interface AssetsView extends IsWidget {
interface Presenter {
- void loadAssetChildren(Asset parent, Consumer<List<Asset>> consumer);
- void onAssetSelected(Asset asset);
- }
-
- class Asset {
- public String id;
- public String type;
- public String displayName;
- public String location;
-
- public Asset() {
- }
-
- public Asset(String id, String type, String displayName, String location) {
- this.id = id;
- this.type = type;
- this.displayName = displayName;
- this.location = location;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- public String getLocation() {
- return location;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
+ AssetBrowser getAssetBrowser();
}
void setPresenter(Presenter presenter);
- void setAssetDisplayName(String name);
}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.java b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.java
index d8aa1668a..638309f30 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.java
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.java
@@ -19,22 +19,16 @@
*/
package org.openremote.manager.client.assets;
-import com.google.gwt.cell.client.AbstractSafeHtmlCell;
-import com.google.gwt.cell.client.Cell;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.safehtml.shared.SafeHtml;
-import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
-import com.google.gwt.text.shared.SafeHtmlRenderer;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.cellview.client.CellTree;
-import com.google.gwt.user.client.ui.*;
-import com.google.gwt.view.client.*;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.SimplePanel;
+import org.openremote.manager.client.assets.browser.AssetBrowser;
import org.openremote.manager.client.i18n.ManagerMessages;
import org.openremote.manager.client.style.FormTreeStyle;
-import org.openremote.manager.client.widget.FormTree;
-import org.openremote.manager.client.widget.PushButton;
import javax.inject.Inject;
import java.util.logging.Logger;
@@ -46,96 +40,14 @@ public class AssetsViewImpl extends Composite implements AssetsView {
interface UI extends UiBinder<HTMLPanel, AssetsViewImpl> {
}
- static class AssetCell extends AbstractSafeHtmlCell<Asset> {
-
- static final SafeHtmlRenderer<Asset> assetRenderer = new SafeHtmlRenderer<Asset>() {
- public SafeHtml render(Asset object) {
- return (object == null)
- ? SafeHtmlUtils.EMPTY_SAFE_HTML
- : SafeHtmlUtils.fromString(object.getDisplayName()
- );
- }
-
- public void render(Asset object, SafeHtmlBuilder appendable) {
- appendable.append(SafeHtmlUtils.fromString(object.getDisplayName()));
- }
- };
-
- public AssetCell() {
- super(assetRenderer);
- }
-
- @Override
- public void render(Cell.Context context, SafeHtml value, SafeHtmlBuilder sb) {
- if (value != null) {
- sb.append(value);
- }
- }
- }
-
- static class AssetTreeModel implements TreeViewModel {
-
- final Presenter presenter;
- final SingleSelectionModel<Asset> selectionModel = new SingleSelectionModel<>();
-
- public AssetTreeModel(Presenter presenter) {
- this.presenter = presenter;
- selectionModel.addSelectionChangeHandler(selectionChangeEvent -> {
- presenter.onAssetSelected(selectionModel.getSelectedObject());
- });
- }
-
- public <T> NodeInfo<?> getNodeInfo(T value) {
- return new DefaultNodeInfo<>(
- new AssetDataProvider(presenter, (Asset) value),
- new AssetCell(),
- selectionModel,
- null);
- }
-
- public boolean isLeaf(Object value) {
- if (value instanceof Asset) {
- Asset asset = (Asset) value;
- return !asset.getType().equals("Composite");
- }
- return true;
- }
- }
-
- static class AssetDataProvider extends AsyncDataProvider<Asset> {
-
- final protected Presenter presenter;
- final protected Asset parent;
-
- public AssetDataProvider(Presenter presenter, Asset parent) {
- this.presenter = presenter;
- this.parent = parent;
- }
-
- @Override
- protected void onRangeChanged(HasData<Asset> display) {
- final Range range = display.getVisibleRange();
- presenter.loadAssetChildren(parent, assetList -> {
- int start = range.getStart();
- updateRowCount(assetList.size(), true);
- updateRowData(start, assetList);
- });
- }
- }
-
-
@UiField
ManagerMessages managerMessages;
@UiField
- SimplePanel assetTreeContainer;
+ SimplePanel assetBrowserContainer;
@UiField
SimplePanel assetsContentContainer;
- @UiField
- TextBox searchInput;
- @UiField
- PushButton searchButton;
final FormTreeStyle formTreeStyle;
@@ -148,35 +60,14 @@ public class AssetsViewImpl extends Composite implements AssetsView {
UI ui = GWT.create(UI.class);
initWidget(ui.createAndBindUi(this));
- assetsContentContainer.add(new Label("TODO: Asset Editors"));
+ assetsContentContainer.add(new Label("TODO: Asset editors on the right side"));
}
@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
- FormTree tree = new FormTree(
- new AssetTreeModel(presenter),
- new Asset(null, "Composite", "ROOT", null),
- formTreeStyle,
- new CellTree.CellTreeMessages() {
- @Override
- public String showMore() {
- return managerMessages.showMoreAssets();
- }
- @Override
- public String emptyTree() {
- return managerMessages.emptyCompositeAsset();
- }
- }
- );
- assetTreeContainer.clear();
- assetTreeContainer.add(tree);
- }
-
- @Override
- public void setAssetDisplayName(String name) {
- assetsContentContainer.clear();
- assetsContentContainer.add(new Label("TODO: Selected " + name));
+ assetBrowserContainer.clear();
+ assetBrowserContainer.add(presenter.getAssetBrowser());
}
}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.ui.xml
index be75428fb..bfb619feb 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.ui.xml
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/AssetsViewImpl.ui.xml
@@ -7,56 +7,43 @@
<ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<ui:style>
- .sidebarContent {
- width: 21em;
+ .assetBrowser {
+ width: 35em;
}
- .navItem {
- margin-right: 1.2em;
- }
+ .assetsControls {
- .navItemFirst {
- margin-left: 0.2em !important;
}
- .formInputText {
- border-radius: 0.4em;
- font-size: smaller !important;
- padding: 0.4em !important;
- height: 1.08em;
+ .navItem {
+ margin: 0 1em;
}
</ui:style>
- <g:HTMLPanel styleName="flex layout vertical">
+ <g:HTMLPanel styleName="flex layout horizontal">
- <g:HTMLPanel
- styleName="layout horizontal start-justified {widgetStyle.SecondaryNav} {themeStyle.SecondaryNav}">
- <w:FormInputText ui:field="searchInput"
- addStyleNames="{style.navItemFirst} {style.formInputText} {widgetStyle.FormControl} {themeStyle.FormControl} {widgetStyle.FormInputText} {themeStyle.FormInputText}"
- autofocus="true"
- placeholder="{managerMessages.search}..."/>
+ <g:SimplePanel ui:field="assetBrowserContainer"
+ styleName="layout vertical"
+ addStyleNames="{style.assetBrowser}"/>
- <w:PushButton ui:field="searchButton"
- addStyleNames="{style.navItem} {widgetStyle.SecondaryNavItem} {themeStyle.SecondaryNavItem}"
- icon="search"/>
- <w:PushButton ui:field="filterButton"
- addStyleNames="{style.navItem} {widgetStyle.SecondaryNavItem} {themeStyle.SecondaryNavItem}"
- text="{managerMessages.filter}"
- icon="filter"/>
+ <g:HTMLPanel styleName="flex layout vertical">
+ <g:HTMLPanel
+ styleName="layout horizontal center end-justified {style.assetsControls} {widgetStyle.SecondaryNav} {themeStyle.SecondaryNav}">
- </g:HTMLPanel>
+ <w:Hyperlink addStyleNames="{style.navItem} {widgetStyle.SecondaryNavItem} {themeStyle.SecondaryNavItem}"
+ icon="copy"
+ targetHistoryToken="assets:"
+ text="Copy/Create Asset"/>
- <g:HTMLPanel styleName="flex layout horizontal">
-
- <g:SimplePanel ui:field="assetTreeContainer"
- addStyleNames="{style.sidebarContent} {widgetStyle.SidebarContent} {themeStyle.SidebarContent}"/>
+ </g:HTMLPanel>
<div class="flex {widgetStyle.MainContent} {themeStyle.MainContent}">
+ <div>TODO: Asset browser switches to an advanced UI that needs more space on the left</div>
<g:SimplePanel ui:field="assetsContentContainer"/>
</div>
-
</g:HTMLPanel>
+
</g:HTMLPanel>
</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowser.java b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowser.java
new file mode 100644
index 000000000..2607a885e
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowser.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016, 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.assets.browser;
+
+import com.google.gwt.user.client.ui.IsWidget;
+import org.openremote.manager.client.assets.Asset;
+import org.openremote.manager.shared.Consumer;
+
+import java.util.List;
+
+public interface AssetBrowser extends IsWidget {
+
+ interface Presenter {
+
+ AssetBrowser getView();
+
+ void loadAssetChildren(Asset parent, Consumer<List<Asset>> consumer);
+
+ void onAssetSelected(Asset asset);
+ }
+
+ void setPresenter(Presenter presenter);
+
+ void setSelectedAsset(String id);
+}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserImpl.java b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserImpl.java
new file mode 100644
index 000000000..a013b7578
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserImpl.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2016, 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.assets.browser;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.cellview.client.CellTree;
+import com.google.gwt.user.client.ui.*;
+import org.openremote.manager.client.assets.Asset;
+import org.openremote.manager.client.i18n.ManagerMessages;
+import org.openremote.manager.client.style.FormTreeStyle;
+import org.openremote.manager.client.widget.FormTree;
+import org.openremote.manager.client.widget.PushButton;
+
+import javax.inject.Inject;
+import java.util.logging.Logger;
+
+public class AssetBrowserImpl extends Composite implements AssetBrowser {
+
+ private static final Logger LOG = Logger.getLogger(AssetBrowserImpl.class.getName());
+
+ interface UI extends UiBinder<HTMLPanel, AssetBrowserImpl> {
+ }
+
+ @UiField
+ ManagerMessages managerMessages;
+
+ @UiField
+ SimplePanel assetTreeContainer;
+
+ @UiField
+ TextBox searchInput;
+
+ @UiField
+ PushButton filterButton;
+
+ final FormTreeStyle formTreeStyle;
+
+ Presenter presenter;
+
+ @Inject
+ public AssetBrowserImpl(FormTreeStyle formTreeStyle) {
+ this.formTreeStyle = formTreeStyle;
+
+ UI ui = GWT.create(UI.class);
+ initWidget(ui.createAndBindUi(this));
+ }
+
+ @Override
+ public void setPresenter(Presenter presenter) {
+ this.presenter = presenter;
+
+ FormTree tree = new FormTree(
+ new AssetTreeModel(presenter),
+ new Asset(Asset.ROOT_ID, Asset.ROOT_TYPE, Asset.ROOT_LABEL, Asset.ROOT_LOCATION),
+ formTreeStyle,
+ new CellTree.CellTreeMessages() {
+ @Override
+ public String showMore() {
+ return managerMessages.showMoreAssets();
+ }
+
+ @Override
+ public String emptyTree() {
+ return managerMessages.emptyCompositeAsset();
+ }
+ }
+ );
+ assetTreeContainer.clear();
+ assetTreeContainer.add(tree);
+ }
+
+ @Override
+ public void setSelectedAsset(String id) {
+ // TODO expand tree to item
+ }
+}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserImpl.ui.xml
new file mode 100644
index 000000000..bec85cfda
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserImpl.ui.xml
@@ -0,0 +1,58 @@
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui"
+ xmlns:w="urn:import:org.openremote.manager.client.widget">
+
+ <ui:with field="managerMessages" type="org.openremote.manager.client.i18n.ManagerMessages"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
+
+ <ui:style>
+ .view {
+ }
+
+ .navItem {
+ margin-right: 1.2em;
+ }
+
+ .navItemFirst {
+ margin-left: 0.2em !important;
+ }
+
+ .searchInput {
+ border-radius: 0.4em;
+ font-size: smaller !important;
+ padding: 0.4em !important;
+ width: 8em;
+ height: 0.8em;
+ }
+
+ .assetTreeContainer {
+ overflow: auto;
+ }
+ </ui:style>
+
+ <g:HTMLPanel styleName="flex layout vertical"
+ addStyleNames="{style.view} {widgetStyle.SidebarContent} {themeStyle.SidebarContent}">
+
+ <g:HTMLPanel
+ styleName="layout horizontal center {widgetStyle.SecondaryNav} {themeStyle.SecondaryNav}">
+
+ <div class="flex">
+ <w:FormInputText ui:field="searchInput"
+ addStyleNames="{style.navItemFirst} {style.searchInput} {widgetStyle.FormControl} {themeStyle.FormControl} {widgetStyle.FormInputText} {themeStyle.FormInputText}"
+ autofocus="true"
+ placeholder="{managerMessages.search}..."/>
+ </div>
+
+ <w:PushButton ui:field="filterButton"
+ addStyleNames="{style.navItem} {widgetStyle.SecondaryNavItem} {themeStyle.SecondaryNavItem}"
+ text="{managerMessages.filter}"
+ icon="filter"/>
+
+ </g:HTMLPanel>
+
+ <g:SimplePanel ui:field="assetTreeContainer" addStyleNames="{style.assetTreeContainer}"/>
+
+ </g:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserPresenter.java b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserPresenter.java
new file mode 100644
index 000000000..f85048714
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetBrowserPresenter.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2016, 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.assets.browser;
+
+import com.google.gwt.place.shared.PlaceController;
+import org.openremote.manager.client.assets.Asset;
+import org.openremote.manager.client.event.bus.EventBus;
+import org.openremote.manager.shared.Consumer;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Logger;
+
+public class AssetBrowserPresenter implements AssetBrowser.Presenter {
+
+ private static final Logger LOG = Logger.getLogger(AssetBrowserPresenter.class.getName());
+
+ final AssetBrowser view;
+ final PlaceController placeController;
+ final EventBus eventBus;
+
+ @Inject
+ public AssetBrowserPresenter(AssetBrowser view,
+ PlaceController placeController,
+ EventBus eventBus) {
+ this.view = view;
+ this.placeController = placeController;
+ this.eventBus = eventBus;
+
+ view.setPresenter(this);
+ }
+
+ @Override
+ public AssetBrowser getView() {
+ return view;
+ }
+
+ @Override
+ public void loadAssetChildren(Asset parent, Consumer<List<Asset>> consumer) {
+ if (Asset.isRoot(parent)) {
+ consumer.accept(Arrays.asList(
+ new Asset("composite:gateways", Asset.Type.COMPOSITE.name(), "Gateways", null),
+ new Asset("composite:buildings", Asset.Type.COMPOSITE.name(), "Buildings", null),
+ new Asset("composite:rooms", Asset.Type.COMPOSITE.name(), "Rooms", null),
+ new Asset("composite:thermostats", Asset.Type.COMPOSITE.name(), "Thermostats", null)
+ ));
+ return;
+ } else if (parent.getType().equals(Asset.Type.COMPOSITE.name())) {
+ if (parent.getId().equals("composite:gateways")) {
+ consumer.accept(Arrays.asList(
+ new Asset("1", Asset.Type.COMPOSITE.name(), "Gateway A", "123.123"),
+ new Asset("2", Asset.Type.COMPOSITE.name(), "Gateway B", "123.123"),
+ new Asset("3", Asset.Type.COMPOSITE.name(), "Gateway C", "123.123"),
+ new Asset("4", Asset.Type.COMPOSITE.name(), "Gateway D", "123.123"),
+ new Asset("5", Asset.Type.COMPOSITE.name(), "Gateway E", "123.123")
+ ));
+ return;
+ }
+
+ if (parent.getId().equals("1")) {
+ consumer.accept(Arrays.asList(
+ new Asset("11", Asset.Type.SENSOR.name(), "Sensor 1", "123.123"),
+ new Asset("22", Asset.Type.SENSOR.name(), "Sensor 2", "123.123"),
+ new Asset("33", Asset.Type.SENSOR.name(), "Sensor 3", "123.123")
+ ));
+ return;
+ }
+ }
+ consumer.accept(new ArrayList<>());
+ }
+
+ @Override
+ public void onAssetSelected(Asset asset) {
+ view.setSelectedAsset(asset.getId());
+ }
+}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetCell.java b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetCell.java
new file mode 100644
index 000000000..6e6ddff74
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetCell.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016, 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.assets.browser;
+
+import com.google.gwt.cell.client.AbstractSafeHtmlCell;
+import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
+import com.google.gwt.text.shared.SafeHtmlRenderer;
+import org.openremote.manager.client.assets.Asset;
+
+class AssetCell extends AbstractSafeHtmlCell<Asset> {
+
+ static final SafeHtmlRenderer<Asset> assetRenderer = new SafeHtmlRenderer<Asset>() {
+ public SafeHtml render(Asset object) {
+ return (object == null)
+ ? SafeHtmlUtils.EMPTY_SAFE_HTML
+ : SafeHtmlUtils.fromString(object.getDisplayName()
+ );
+ }
+
+ public void render(Asset object, SafeHtmlBuilder appendable) {
+ appendable.append(SafeHtmlUtils.fromString(object.getDisplayName()));
+ }
+ };
+
+ public AssetCell() {
+ super(assetRenderer);
+ }
+
+ @Override
+ public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
+ if (value != null) {
+ sb.append(value);
+ }
+ }
+}
+
+
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetDataProvider.java b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetDataProvider.java
new file mode 100644
index 000000000..8aa0ee173
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetDataProvider.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016, 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.assets.browser;
+
+import com.google.gwt.view.client.AsyncDataProvider;
+import com.google.gwt.view.client.HasData;
+import com.google.gwt.view.client.Range;
+import org.openremote.manager.client.assets.Asset;
+
+class AssetDataProvider extends AsyncDataProvider<Asset> {
+
+ final protected AssetBrowser.Presenter presenter;
+ final protected Asset parent;
+
+ public AssetDataProvider(AssetBrowser.Presenter presenter, Asset parent) {
+ this.presenter = presenter;
+ this.parent = parent;
+ }
+
+ @Override
+ protected void onRangeChanged(HasData<Asset> display) {
+ final Range range = display.getVisibleRange();
+ presenter.loadAssetChildren(parent, assetList -> {
+ int start = range.getStart();
+ updateRowCount(assetList.size(), true);
+ updateRowData(start, assetList);
+ });
+ }
+}
diff --git a/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetTreeModel.java b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetTreeModel.java
new file mode 100644
index 000000000..bc7f703e3
--- /dev/null
+++ b/manager/client/src/main/java/org/openremote/manager/client/assets/browser/AssetTreeModel.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016, 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.assets.browser;
+
+import com.google.gwt.view.client.SingleSelectionModel;
+import com.google.gwt.view.client.TreeViewModel;
+import org.openremote.manager.client.assets.Asset;
+
+class AssetTreeModel implements TreeViewModel {
+
+ final AssetBrowser.Presenter presenter;
+ final SingleSelectionModel<Asset> selectionModel = new SingleSelectionModel<>();
+
+ public AssetTreeModel(AssetBrowser.Presenter presenter) {
+ this.presenter = presenter;
+ selectionModel.addSelectionChangeHandler(selectionChangeEvent -> {
+ presenter.onAssetSelected(selectionModel.getSelectedObject());
+ });
+ }
+
+ public <T> NodeInfo<?> getNodeInfo(T value) {
+ return new DefaultNodeInfo<>(
+ new AssetDataProvider(presenter, (Asset) value),
+ new AssetCell(),
+ selectionModel,
+ null);
+ }
+
+ public boolean isLeaf(Object value) {
+ if (value instanceof Asset) {
+ Asset asset = (Asset) value;
+ return !asset.getType().equals(Asset.Type.COMPOSITE.name());
+ }
+ return true;
+ }
+}
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.java
index 95da7903e..ba967d3ad 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
@@ -22,6 +22,7 @@ package org.openremote.manager.client.map;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
+import org.openremote.manager.client.assets.browser.AssetBrowser;
import org.openremote.manager.client.event.GoToPlaceEvent;
import org.openremote.manager.client.event.bus.EventBus;
import org.openremote.manager.client.event.bus.EventRegistration;
@@ -41,6 +42,7 @@ public class MapActivity extends AppActivity<MapPlace> implements MapView.Presen
private static final Logger LOG = Logger.getLogger(MapActivity.class.getName());
+ final AssetBrowser.Presenter assetBrowserPresenter;
final MapView view;
final MapResource mapResource;
final ManagerMessages managerMessages;
@@ -49,12 +51,14 @@ public class MapActivity extends AppActivity<MapPlace> implements MapView.Presen
final JsonObjectMapper jsonObjectMapper;
@Inject
- public MapActivity(MapView view,
+ public MapActivity(AssetBrowser.Presenter assetBrowserPresenter,
+ MapView view,
MapResource mapResource,
ManagerMessages managerMessages,
RequestService requestService,
PlaceController placeController,
JsonObjectMapper jsonObjectMapper) {
+ this.assetBrowserPresenter = assetBrowserPresenter;
this.view = view;
this.mapResource = mapResource;
this.managerMessages = managerMessages;
@@ -98,4 +102,9 @@ public class MapActivity extends AppActivity<MapPlace> implements MapView.Presen
public void goTo(Place place) {
placeController.goTo(place);
}
+
+ @Override
+ public AssetBrowser getAssetBrowser() {
+ return assetBrowserPresenter.getView();
+ }
}
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.java
index 61251a647..7f9b5b268 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
@@ -22,10 +22,12 @@ package org.openremote.manager.client.map;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.IsWidget;
import elemental.json.JsonObject;
+import org.openremote.manager.client.assets.browser.AssetBrowser;
public interface MapView extends IsWidget {
interface Presenter {
+ AssetBrowser getAssetBrowser();
void goTo(Place place);
}
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.java
index f5273276e..147b0a3f1 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
@@ -26,6 +26,7 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.SimplePanel;
import elemental.json.JsonObject;
import javax.inject.Inject;
@@ -48,6 +49,9 @@ public class MapViewImpl extends Composite implements MapView {
@UiField
MapWidget mapWidget;
+ @UiField
+ SimplePanel assetBrowserContainer;
+
@Inject
public MapViewImpl() {
initWidget(ui.createAndBindUi(this));
@@ -58,6 +62,9 @@ public class MapViewImpl extends Composite implements MapView {
@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
+
+ assetBrowserContainer.clear();
+ assetBrowserContainer.add(presenter.getAssetBrowser());
}
@Override
diff --git a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml
index b38ad4e0a..23c04454b 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml
+++ b/manager/client/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml
@@ -7,24 +7,53 @@
<ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<ui:style>
- .mapContainer {
+ .view {
+ position: relative;
+ }
+
+ .assetBrowser {
+ z-index: 10;
+ width: 15em;
+ height: 40vh;
+ }
+
+ .mapWidget {
+ position: absolute;
+ top: 0;
+ left: 0;
width: 100%;
height: 100%;
}
.mapLoadingLabel {
margin: 0.4em;
+ text-align: right;
font-weight: bold;
}
+
+ .mapControls {
+ z-index: 10;
+ }
</ui:style>
- <g:HTMLPanel ui:field="mapContainer" styleName="flex layout vertical" addStyleNames="{style.mapContainer}">
+ <g:HTMLPanel ui:field="mapContainer" styleName="flex layout horizontal" addStyleNames="{style.view}">
+ <g:SimplePanel ui:field="assetBrowserContainer"
+ styleName="layout vertical"
+ addStyleNames="{style.assetBrowser}"/>
+
+ <g:HTMLPanel
+ styleName="flex layout horizontal center end-justified {style.mapControls} {widgetStyle.SecondaryNav} {themeStyle.SecondaryNav}">
+ <div>TODO: Move map navigation action items here</div>
+ </g:HTMLPanel>
+
<g:Label ui:field="mapLoadingLabel"
text="{managerMessages.mapLoading}"
addStyleNames="{style.mapLoadingLabel}"/>
+
<map:MapWidget ui:field="mapWidget"
styleName="flex layout vertical"
- addStyleNames="{style.mapContainer}"/>
+ addStyleNames="{style.mapWidget}"/>
+
</g:HTMLPanel>
</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/client/src/main/java/org/openremote/manager/client/widget/Hyperlink.java b/manager/client/src/main/java/org/openremote/manager/client/widget/Hyperlink.java
index 626c91a68..ab33a1807 100644
--- a/manager/client/src/main/java/org/openremote/manager/client/widget/Hyperlink.java
+++ b/manager/client/src/main/java/org/openremote/manager/client/widget/Hyperlink.java
@@ -1,10 +1,34 @@
package org.openremote.manager.client.widget;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Label;
+import org.openremote.manager.client.util.JsUtil;
+
public class Hyperlink extends com.google.gwt.user.client.ui.Hyperlink {
+ protected String icon;
+ protected Label iconLabel = new Label();
+
public Hyperlink() {
super();
getElement().addClassName("or-Hyperlink");
+ Element anchor = getElement().getFirstChildElement();
+ JsUtil.log(anchor);
+ // TODO Clickable icon?!
+ DOM.insertBefore(getElement(), iconLabel.getElement(), anchor);
+ }
+
+ public String getIcon() {
+ return icon;
+ }
+
+ public void setIcon(String icon) {
+ this.icon = icon;
+ iconLabel.getElement().removeClassName("or-HyperlinkIcon");
+ if (icon != null) {
+ iconLabel.getElement().addClassName("or-HyperlinkIcon fa fa-" + icon);
+ }
}
}
diff --git a/manager/client/src/main/webapp/css/style.html b/manager/client/src/main/webapp/css/style.html
index 8524a4f30..7a3d72864 100644
--- a/manager/client/src/main/webapp/css/style.html
+++ b/manager/client/src/main/webapp/css/style.html
@@ -125,7 +125,7 @@
.or-Hyperlink a,
.or-Hyperlink a:visited {
cursor: pointer;
- font-weight: bold;
+ font-weight: 600;
text-decoration: none;
display: inline-block;
padding: 0.4em;
@@ -137,6 +137,16 @@
text-decoration: underline;
}
+ .or-SecondaryNav .or-Hyperlink {
+ padding: 0;
+ border-radius: 0
+ }
+
+ .or-SecondaryNav .or-Hyperlink a:hover,
+ .or-SecondaryNav .or-Hyperlink a:focus {
+ text-decoration: none;
+ }
+
.or-Headline1 {
font-size: x-large;
font-weight: 600;
@@ -296,7 +306,8 @@
.or-FormTreeEmptyMessage {
font-size: smaller;
font-style: italic;
- margin: 0.2em 0 0.8em 2.4em;
+ text-align: center;
+ padding-bottom: 0.8em;
}
.or-FormMessages,
diff --git a/manager/client/src/main/webapp/css/theme.html b/manager/client/src/main/webapp/css/theme.html
index 46a67bbb7..4e74a97bd 100644
--- a/manager/client/src/main/webapp/css/theme.html
+++ b/manager/client/src/main/webapp/css/theme.html
@@ -55,6 +55,7 @@
}
.theme-SecondaryNavItem.active {
+ color: var(--theme-lightgreen) !important;
}
.theme-SecondaryNavItem.active a {
diff --git a/manager/server/src/main/java/org/openremote/manager/server/SampleDataService.java b/manager/server/src/main/java/org/openremote/manager/server/SampleDataService.java
index c9b214945..fdfb84b7a 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/SampleDataService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/SampleDataService.java
@@ -165,6 +165,8 @@ public class SampleDataService implements ContainerService {
masterRealm.setLoginTheme("openremote");
masterRealm.setAccountTheme("openremote");
+ masterRealm.setSsoSessionIdleTimeout(10800); // 3 hours
+
// TODO: Make SSL setup configurable
masterRealm.setSslRequired(SslRequired.NONE.toString());