Skip to content

armgit / core

Public Imported from GitHub
0

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

Added admin pages and navigation

Christian Bauer7e865eac7cb2
diff --git a/README.md b/README.md
index 4658240ba..b697c7bb5 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
---
-* **Live Demo**: http://demo2.openremote.com (test/test)
+* **Live Demo**: http://demo2.openremote.com (sign-in with `test/test` or `admin/admin`)
* **Docker Images**: https://hub.docker.com/u/openremote/
* **Documentation/Wiki:** https://github.com/openremote/openremote/wiki
* **Community:** https://groups.google.com/forum/#!forum/openremotecommunity
diff --git a/keycloak/theme/account/account.ftl b/keycloak/theme/account/account.ftl
index 4c5aad970..5080dd1b8 100755
--- a/keycloak/theme/account/account.ftl
+++ b/keycloak/theme/account/account.ftl
@@ -3,8 +3,8 @@
<div class="layout vertical">
- <div class="or-Header1 theme-Header1">${msg("editAccountHtmlTtile")}</div>
- <div class="or-HeaderSub theme-HeaderSub"><span class="required">*</span> ${msg("requiredFields")}</div>
+ <div class="or-Headline1 theme-Headline1">${msg("editAccountHtmlTtile")}</div>
+ <div class="or-HeadlineSub theme-HeadlineSub"><span class="required">*</span> ${msg("requiredFields")}</div>
<form action="${url.accountUrl}" class="layout vertical or-Form theme-Form" method="post">
diff --git a/keycloak/theme/account/password.ftl b/keycloak/theme/account/password.ftl
index 105f6ee0d..bc727d8b7 100755
--- a/keycloak/theme/account/password.ftl
+++ b/keycloak/theme/account/password.ftl
@@ -4,8 +4,8 @@
<div class="layout vertical">
- <div class="or-Header1 theme-Header1">${msg("changePasswordHtmlTitle")}</div>
- <div class="or-HeaderSub theme-HeaderSub">${msg("allFieldsRequired")}</div>
+ <div class="or-Headline1 theme-Headline1">${msg("changePasswordHtmlTitle")}</div>
+ <div class="or-HeadlineSub theme-HeadlineSub">${msg("allFieldsRequired")}</div>
<form action="${url.passwordUrl}" class="layout vertical or-Form theme-Form" method="post">
diff --git a/keycloak/theme/account/template.ftl b/keycloak/theme/account/template.ftl
index be5de707d..388b2b8c5 100644
--- a/keycloak/theme/account/template.ftl
+++ b/keycloak/theme/account/template.ftl
@@ -40,7 +40,7 @@
</head>
<body class="layout vertical">
- <div class="flex layout horizontal center-start">
+ <div class="flex layout horizontal">
<div class="or-SidebarContent theme-SidebarContent">
<ul class="or-UnorderedList theme-UnorderedList">
<li><div class="or-Hyperlink theme-Hyperlink <#if active=='account'>active</#if>"><a href="${url.accountUrl}">${msg("account")}</a></div></li>
diff --git a/keycloak/theme/login/template.ftl b/keycloak/theme/login/template.ftl
index e62c05a70..3792e06ba 100755
--- a/keycloak/theme/login/template.ftl
+++ b/keycloak/theme/login/template.ftl
@@ -54,8 +54,8 @@
d="M11.936,16.622c-0.082,0-0.164-0.001-0.245-0.004c-1.29-0.065-2.478-0.628-3.346-1.585 c-0.868-0.958-1.31-2.195-1.246-3.487l2.104,0.105c-0.036,0.728,0.214,1.427,0.704,1.967c0.488,0.54,1.16,0.858,1.888,0.894 c0.725,0.033,1.426-0.213,1.966-0.703c0.541-0.489,0.858-1.159,0.895-1.887c0.075-1.503-1.088-2.787-2.591-2.862l0.105-2.104 c2.664,0.132,4.724,2.406,4.592,5.07c-0.064,1.291-0.628,2.478-1.585,3.345C14.28,16.183,13.137,16.622,11.936,16.622L11.936,16.622 z"/>
</svg>
<div class="layout vertical">
- <div class="or-Header1 theme-Header1" style="margin: 0;"><#nested "header"></div>
- <div class="or-HeaderSub theme-HeaderSub" style="margin-left: 0.2em;">Manager Login</div>
+ <div class="or-Headline1 theme-Headline1" style="margin: 0;"><#nested "header"></div>
+ <div class="or-HeadlineSub theme-HeadlineSub" style="margin-left: 0.2em;">Manager Login</div>
</div>
</div>
diff --git a/manager/src/main/java/org/openremote/manager/client/ManagerActivityMapper.java b/manager/src/main/java/org/openremote/manager/client/ManagerActivityMapper.java
new file mode 100644
index 000000000..ab18d3ab4
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/ManagerActivityMapper.java
@@ -0,0 +1,118 @@
+/*
+ * 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;
+
+import com.google.gwt.place.shared.Place;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import org.openremote.manager.client.admin.overview.AdminOverview;
+import org.openremote.manager.client.admin.overview.AdminOverviewActivity;
+import org.openremote.manager.client.admin.AdminPlace;
+import org.openremote.manager.client.admin.overview.AdminOverviewPlace;
+import org.openremote.manager.client.admin.realms.AdminRealmsActivity;
+import org.openremote.manager.client.admin.realms.AdminRealmsPlace;
+import org.openremote.manager.client.admin.users.AdminUsersActivity;
+import org.openremote.manager.client.admin.users.AdminUsersPlace;
+import org.openremote.manager.client.assets.AssetDetailActivity;
+import org.openremote.manager.client.assets.AssetsPlace;
+import org.openremote.manager.client.event.bus.EventBus;
+import org.openremote.manager.client.flows.FlowsActivity;
+import org.openremote.manager.client.flows.FlowsPlace;
+import org.openremote.manager.client.i18n.ManagerMessages;
+import org.openremote.manager.client.map.MapActivity;
+import org.openremote.manager.client.map.MapPlace;
+import org.openremote.manager.client.mvp.AppActivity;
+import org.openremote.manager.client.mvp.AppActivityMapper;
+import org.openremote.manager.client.mvp.RoleRequiredException;
+import org.openremote.manager.client.service.SecurityService;
+import org.openremote.manager.client.user.UserAccountActivity;
+import org.openremote.manager.client.user.UserAccountPlace;
+import org.openremote.manager.shared.event.ui.ShowFailureEvent;
+
+import java.util.logging.Logger;
+
+public class ManagerActivityMapper implements AppActivityMapper {
+
+ private static final Logger LOG = Logger.getLogger(ManagerActivityMapper.class.getName());
+
+ protected final SecurityService securityService;
+ protected final EventBus eventBus;
+ protected final ManagerMessages managerMessages;
+ protected final Provider<AssetDetailActivity> assetsActivityProvider;
+ protected final Provider<MapActivity> mapActivityProvider;
+ protected final Provider<FlowsActivity> flowsActivityProvider;
+ protected final Provider<AdminOverviewActivity> adminOverviewActivityProvider;
+ protected final Provider<AdminRealmsActivity> adminRealmsActivityProvider;
+ protected final Provider<AdminUsersActivity> adminUsersActivityProvider;
+ protected final Provider<UserAccountActivity> userProfileActivityProvider;
+
+ @Inject
+ public ManagerActivityMapper(SecurityService securityService,
+ EventBus eventBus,
+ ManagerMessages managerMessages,
+ Provider<AssetDetailActivity> assetsActivityProvider,
+ Provider<MapActivity> mapActivityProvider,
+ Provider<FlowsActivity> flowsActivityProvider,
+ Provider<AdminOverviewActivity> adminOverviewActivityProvider,
+ Provider<AdminRealmsActivity> adminRealmsActivityProvider,
+ Provider<AdminUsersActivity> adminUsersActivityProvider,
+ Provider<UserAccountActivity> userProfileActivityProvider) {
+ this.securityService = securityService;
+ this.eventBus = eventBus;
+ this.managerMessages = managerMessages;
+ this.assetsActivityProvider = assetsActivityProvider;
+ this.mapActivityProvider = mapActivityProvider;
+ this.flowsActivityProvider = flowsActivityProvider;
+ this.adminOverviewActivityProvider = adminOverviewActivityProvider;
+ this.adminRealmsActivityProvider = adminRealmsActivityProvider;
+ this.adminUsersActivityProvider = adminUsersActivityProvider;
+ this.userProfileActivityProvider = userProfileActivityProvider;
+ }
+
+ public AppActivity getActivity(Place place) {
+ try {
+ if (place instanceof AssetsPlace) {
+ return assetsActivityProvider.get().init(securityService, (AssetsPlace) place);
+ }
+ if (place instanceof MapPlace) {
+ return mapActivityProvider.get().init(securityService, (MapPlace) place);
+ }
+ if (place instanceof FlowsPlace) {
+ return flowsActivityProvider.get().init(securityService, (FlowsPlace) place);
+ }
+ if (place instanceof AdminOverviewPlace) {
+ return adminOverviewActivityProvider.get().init(securityService, (AdminOverviewPlace) place);
+ }
+ if (place instanceof AdminRealmsPlace) {
+ return adminRealmsActivityProvider.get().init(securityService, (AdminRealmsPlace) place);
+ }
+ if (place instanceof AdminUsersPlace) {
+ return adminUsersActivityProvider.get().init(securityService, (AdminUsersPlace) place);
+ }
+ if (place instanceof UserAccountPlace) {
+ return userProfileActivityProvider.get().init(securityService, (UserAccountPlace) place);
+ }
+ } catch (RoleRequiredException ex) {
+ LOG.warning("Access denied, missing required role for: " + place);
+ eventBus.dispatch(new ShowFailureEvent(managerMessages.accessDenied(), 5000));
+ }
+ return null;
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/ManagerHistoryMapper.java b/manager/src/main/java/org/openremote/manager/client/ManagerHistoryMapper.java
index 415c0afd8..3350af3a4 100644
--- a/manager/src/main/java/org/openremote/manager/client/ManagerHistoryMapper.java
+++ b/manager/src/main/java/org/openremote/manager/client/ManagerHistoryMapper.java
@@ -21,6 +21,9 @@ package org.openremote.manager.client;
import com.google.gwt.place.shared.PlaceHistoryMapper;
import com.google.gwt.place.shared.WithTokenizers;
+import org.openremote.manager.client.admin.overview.AdminOverviewPlace;
+import org.openremote.manager.client.admin.realms.AdminRealmsPlace;
+import org.openremote.manager.client.admin.users.AdminUsersPlace;
import org.openremote.manager.client.assets.AssetsPlace;
import org.openremote.manager.client.flows.FlowsPlace;
import org.openremote.manager.client.map.MapPlace;
@@ -31,6 +34,9 @@ import org.openremote.manager.client.user.UserAccountPlace;
AssetsPlace.Tokenizer.class,
MapPlace.Tokenizer.class,
FlowsPlace.Tokenizer.class,
+ AdminOverviewPlace.Tokenizer.class,
+ AdminRealmsPlace.Tokenizer.class,
+ AdminUsersPlace.Tokenizer.class,
UserAccountPlace.Tokenizer.class
}
)
diff --git a/manager/src/main/java/org/openremote/manager/client/ManagerModule.java b/manager/src/main/java/org/openremote/manager/client/ManagerModule.java
index 93b898556..aad2fdf24 100644
--- a/manager/src/main/java/org/openremote/manager/client/ManagerModule.java
+++ b/manager/src/main/java/org/openremote/manager/client/ManagerModule.java
@@ -26,6 +26,19 @@ import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.place.shared.PlaceHistoryMapper;
import com.google.inject.Provides;
import com.google.inject.Singleton;
+import org.openremote.manager.client.admin.*;
+import org.openremote.manager.client.admin.navigation.AdminNavigation;
+import org.openremote.manager.client.admin.navigation.AdminNavigationImpl;
+import org.openremote.manager.client.admin.navigation.AdminNavigationPresenter;
+import org.openremote.manager.client.admin.overview.AdminOverview;
+import org.openremote.manager.client.admin.overview.AdminOverviewActivity;
+import org.openremote.manager.client.admin.overview.AdminOverviewImpl;
+import org.openremote.manager.client.admin.realms.AdminRealms;
+import org.openremote.manager.client.admin.realms.AdminRealmsActivity;
+import org.openremote.manager.client.admin.realms.AdminRealmsImpl;
+import org.openremote.manager.client.admin.users.AdminUsers;
+import org.openremote.manager.client.admin.users.AdminUsersActivity;
+import org.openremote.manager.client.admin.users.AdminUsersImpl;
import org.openremote.manager.client.app.*;
import org.openremote.manager.client.assets.*;
import org.openremote.manager.client.event.EventMapper;
@@ -47,6 +60,7 @@ import org.openremote.manager.client.toast.PopupToastDisplay;
import org.openremote.manager.client.toast.ToastDisplay;
import org.openremote.manager.client.user.*;
import org.openremote.manager.shared.map.MapResource;
+import rx.Single;
public class ManagerModule extends AbstractGinModule {
@@ -74,6 +88,16 @@ public class ManagerModule extends AbstractGinModule {
bind(FlowsView.class).to(FlowsViewImpl.class).in(Singleton.class);
bind(FlowsActivity.class);
+ bind(AdminView.class).to(AdminViewImpl.class).in(Singleton.class);
+ bind(AdminNavigation.class).to(AdminNavigationImpl.class).in(Singleton.class);
+ bind(AdminNavigation.Presenter.class).to(AdminNavigationPresenter.class);
+ bind(AdminOverview.class).to(AdminOverviewImpl.class).in(Singleton.class);
+ bind(AdminOverviewActivity.class);
+ bind(AdminRealms.class).to(AdminRealmsImpl.class).in(Singleton.class);
+ bind(AdminRealmsActivity.class);
+ bind(AdminUsers.class).to(AdminUsersImpl.class).in(Singleton.class);
+ bind(AdminUsersActivity.class);
+
bind(UserControls.class).to(UserControlsImpl.class).in(Singleton.class);
bind(UserControls.Presenter.class).to(UserControlsPresenter.class).in(Singleton.class);
@@ -108,7 +132,7 @@ public class ManagerModule extends AbstractGinModule {
@Provides
@Singleton
- public AppActivityManager getAppActivityMapper(MainActivityMapper activityMapper, EventBus eventBus) {
+ public AppActivityManager getAppActivityMapper(ManagerActivityMapper activityMapper, EventBus eventBus) {
return new AppActivityManager("AppActivityManager", activityMapper, eventBus);
}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/AbstractAdminActivity.java b/manager/src/main/java/org/openremote/manager/client/admin/AbstractAdminActivity.java
new file mode 100644
index 000000000..929a9d901
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/AbstractAdminActivity.java
@@ -0,0 +1,69 @@
+/*
+ * 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.admin;
+
+import com.google.gwt.user.client.ui.AcceptsOneWidget;
+import org.openremote.manager.client.admin.navigation.AdminNavigation;
+import org.openremote.manager.client.event.GoToPlaceEvent;
+import org.openremote.manager.client.event.bus.EventBus;
+import org.openremote.manager.client.event.bus.EventRegistration;
+import org.openremote.manager.client.mvp.AppActivity;
+import org.openremote.manager.client.mvp.RoleRequiredException;
+import org.openremote.manager.client.service.SecurityService;
+
+import java.util.Collection;
+
+public abstract class AbstractAdminActivity<P extends AdminPlace, AC extends AdminContent>
+ extends AppActivity<P> {
+
+ final protected AdminView adminView;
+ final protected AdminNavigation.Presenter adminNavigationPresenter;
+ final protected AC adminContent;
+
+ public AbstractAdminActivity(AdminView adminView,
+ AdminNavigation.Presenter adminNavigationPresenter,
+ AC adminContent) {
+ this.adminView = adminView;
+ this.adminNavigationPresenter = adminNavigationPresenter;
+ this.adminContent = adminContent;
+
+ adminView.setContent(adminContent);
+ }
+
+ @Override
+ protected AppActivity<P> init(P place) {
+ return this;
+ }
+
+ @Override
+ public void start(AcceptsOneWidget container, EventBus eventBus, Collection<EventRegistration> registrations) {
+ container.setWidget(adminView.asWidget());
+
+ registrations.add(eventBus.register(
+ GoToPlaceEvent.class,
+ event -> {
+ if (event.getNewPlace() instanceof AdminPlace) {
+ AdminPlace adminPlace = (AdminPlace) event.getNewPlace();
+ adminNavigationPresenter.setActivePlace(adminPlace);
+ }
+ }
+ ));
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/AdminContent.java b/manager/src/main/java/org/openremote/manager/client/admin/AdminContent.java
new file mode 100644
index 000000000..9d5067fe1
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/AdminContent.java
@@ -0,0 +1,26 @@
+/*
+ * 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.admin;
+
+import com.google.gwt.user.client.ui.IsWidget;
+
+public interface AdminContent extends IsWidget {
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/AdminPlace.java b/manager/src/main/java/org/openremote/manager/client/admin/AdminPlace.java
new file mode 100644
index 000000000..51cb2dcf2
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/AdminPlace.java
@@ -0,0 +1,26 @@
+/*
+ * 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.admin;
+
+import com.google.gwt.place.shared.Place;
+
+public abstract class AdminPlace extends Place {
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/AdminView.java b/manager/src/main/java/org/openremote/manager/client/admin/AdminView.java
new file mode 100644
index 000000000..506036eff
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/AdminView.java
@@ -0,0 +1,28 @@
+/*
+ * 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.admin;
+
+import com.google.gwt.user.client.ui.IsWidget;
+
+public interface AdminView extends IsWidget {
+
+ void setContent(AdminContent adminContent);
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/AdminViewImpl.java b/manager/src/main/java/org/openremote/manager/client/admin/AdminViewImpl.java
new file mode 100644
index 000000000..f1ad2bb7c
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/AdminViewImpl.java
@@ -0,0 +1,57 @@
+/*
+ * 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.admin;
+
+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.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.SimplePanel;
+import org.openremote.manager.client.admin.navigation.AdminNavigation;
+
+import javax.inject.Inject;
+
+public class AdminViewImpl extends Composite implements AdminView {
+
+ interface UI extends UiBinder<HTMLPanel, AdminViewImpl> {
+ }
+
+ private UI ui = GWT.create(UI.class);
+
+ @UiField(provided = true)
+ final AdminNavigation adminNavigation;
+
+ @UiField
+ SimplePanel adminContentContainer;
+
+ @Inject
+ public AdminViewImpl(AdminNavigation adminNavigation) {
+ this.adminNavigation = adminNavigation;
+
+ initWidget(ui.createAndBindUi(this));
+ }
+
+ @Override
+ public void setContent(AdminContent adminContent) {
+ adminContentContainer.clear();
+ adminContentContainer.add(adminContent);
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/AdminViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/admin/AdminViewImpl.ui.xml
new file mode 100644
index 000000000..4c267a536
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/AdminViewImpl.ui.xml
@@ -0,0 +1,20 @@
+<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"
+ xmlns:an="urn:import:org.openremote.manager.client.admin.navigation">
+
+ <ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
+
+ <g:HTMLPanel styleName="flex layout horizontal">
+
+ <an:AdminNavigation ui:field="adminNavigation"/>
+
+ <div class="flex {widgetStyle.MainContent} {themeStyle.MainContent}">
+ <g:SimplePanel ui:field="adminContentContainer"/>
+ </div>
+
+ </g:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigation.java b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigation.java
new file mode 100644
index 000000000..c662e210a
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigation.java
@@ -0,0 +1,44 @@
+/*
+ * 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.admin.navigation;
+
+import com.google.gwt.user.client.ui.IsWidget;
+import org.openremote.manager.client.admin.AdminPlace;
+
+public interface AdminNavigation extends IsWidget {
+
+ interface Presenter {
+
+ AdminNavigation getView();
+
+ String getAdminOverviewPlaceToken();
+
+ String getAdminRealmsPlaceToken(String realm);
+
+ String getAdminUsersPlaceToken(String userId);
+
+ void setActivePlace(AdminPlace place);
+ }
+
+ void setPresenter(Presenter presenter);
+
+ void onPlaceChange(AdminPlace adminPlace);
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.java b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.java
new file mode 100644
index 000000000..3c4583a98
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.java
@@ -0,0 +1,88 @@
+/*
+ * 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.admin.navigation;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.LIElement;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import org.openremote.manager.client.admin.realms.AdminRealmsPlace;
+import org.openremote.manager.client.admin.users.AdminUsersPlace;
+import org.openremote.manager.client.admin.AdminPlace;
+import org.openremote.manager.client.widget.Hyperlink;
+
+import javax.inject.Inject;
+
+public class AdminNavigationImpl extends Composite implements AdminNavigation {
+
+ interface UI extends UiBinder<HTMLPanel, AdminNavigationImpl> {
+ }
+
+ private UI ui = GWT.create(UI.class);
+
+ Presenter presenter;
+
+ @UiField
+ LIElement overview;
+ @UiField
+ Hyperlink overviewLink;
+
+ @UiField
+ LIElement realmsItem;
+ @UiField
+ Hyperlink realmsLink;
+
+ @UiField
+ LIElement usersItem;
+ @UiField
+ Hyperlink usersLink;
+
+ @Inject
+ public AdminNavigationImpl() {
+ initWidget(ui.createAndBindUi(this));
+ }
+
+ @Override
+ public void setPresenter(Presenter presenter) {
+ this.presenter = presenter;
+
+ overviewLink.setTargetHistoryToken(presenter.getAdminOverviewPlaceToken());
+ realmsLink.setTargetHistoryToken(presenter.getAdminRealmsPlaceToken(""));
+ usersLink.setTargetHistoryToken(presenter.getAdminUsersPlaceToken(""));
+ }
+
+ @Override
+ public void onPlaceChange(AdminPlace adminPlace) {
+ overviewLink.removeStyleName("active");
+ realmsLink.removeStyleName("active");
+ usersLink.removeStyleName("active");
+
+ if (adminPlace instanceof AdminRealmsPlace) {
+ realmsLink.addStyleName("active");
+ } else if (adminPlace instanceof AdminUsersPlace) {
+ usersLink.addStyleName("active");
+ } else {
+ overviewLink.addStyleName("active");
+ }
+ }
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.ui.xml
new file mode 100644
index 000000000..6b232d6c9
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationImpl.ui.xml
@@ -0,0 +1,33 @@
+<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="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
+
+ <g:HTMLPanel styleName="layout vertical {widgetStyle.SidebarContent} {themeStyle.SidebarContent}">
+ <ul class="{widgetStyle.UnorderedList} {themeStyle.UnorderedList}">
+
+ <li ui:field="overview">
+ <w:Hyperlink ui:field="overviewLink"
+ addStyleNames="{themeStyle.Hyperlink}"
+ text="{constants.overview}"/>
+ </li>
+
+ <li ui:field="realmsItem">
+ <w:Hyperlink ui:field="realmsLink"
+ addStyleNames="{themeStyle.Hyperlink}"
+ text="{constants.manageRealms}"/>
+ </li>
+
+ <li ui:field="usersItem">
+ <w:Hyperlink ui:field="usersLink"
+ addStyleNames="{themeStyle.Hyperlink}"
+ text="{constants.manageUsers}"/>
+ </li>
+
+ </ul>
+ </g:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationPresenter.java b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationPresenter.java
new file mode 100644
index 000000000..1e031b335
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/navigation/AdminNavigationPresenter.java
@@ -0,0 +1,48 @@
+package org.openremote.manager.client.admin.navigation;
+
+import com.google.inject.Inject;
+import org.openremote.manager.client.ManagerHistoryMapper;
+import org.openremote.manager.client.admin.AdminPlace;
+import org.openremote.manager.client.admin.overview.AdminOverviewPlace;
+import org.openremote.manager.client.admin.realms.AdminRealmsPlace;
+import org.openremote.manager.client.admin.users.AdminUsersPlace;
+
+public class AdminNavigationPresenter implements AdminNavigation.Presenter {
+
+ final protected AdminNavigation view;
+ final protected ManagerHistoryMapper managerHistoryMapper;
+
+ @Inject
+ public AdminNavigationPresenter(AdminNavigation view,
+ ManagerHistoryMapper managerHistoryMapper) {
+ this.view = view;
+ this.managerHistoryMapper = managerHistoryMapper;
+
+ view.setPresenter(this);
+ }
+
+ @Override
+ public AdminNavigation getView() {
+ return view;
+ }
+
+ @Override
+ public String getAdminOverviewPlaceToken() {
+ return managerHistoryMapper.getToken(new AdminOverviewPlace());
+ }
+
+ @Override
+ public String getAdminRealmsPlaceToken(String realm) {
+ return managerHistoryMapper.getToken(new AdminRealmsPlace(realm));
+ }
+
+ @Override
+ public String getAdminUsersPlaceToken(String userId) {
+ return managerHistoryMapper.getToken(new AdminUsersPlace(userId));
+ }
+
+ @Override
+ public void setActivePlace(AdminPlace place) {
+ view.onPlaceChange(place);
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverview.java b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverview.java
new file mode 100644
index 000000000..e4e4db21f
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverview.java
@@ -0,0 +1,32 @@
+/*
+ * 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.admin.overview;
+
+import org.openremote.manager.client.admin.AdminContent;
+
+public interface AdminOverview extends AdminContent {
+
+ interface Presenter {
+
+ }
+
+ void setPresenter(Presenter presenter);
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewActivity.java b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewActivity.java
new file mode 100644
index 000000000..219b47809
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewActivity.java
@@ -0,0 +1,55 @@
+/*
+ * 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.admin.overview;
+
+import com.google.gwt.user.client.ui.AcceptsOneWidget;
+import org.openremote.manager.client.admin.AbstractAdminActivity;
+import org.openremote.manager.client.admin.AdminPlace;
+import org.openremote.manager.client.admin.AdminView;
+import org.openremote.manager.client.admin.navigation.AdminNavigation;
+import org.openremote.manager.client.event.bus.EventBus;
+import org.openremote.manager.client.event.bus.EventRegistration;
+
+import javax.inject.Inject;
+import java.util.Collection;
+
+public class AdminOverviewActivity
+ extends AbstractAdminActivity<AdminOverviewPlace, AdminOverview>
+ implements AdminOverview.Presenter {
+
+ @Inject
+ public AdminOverviewActivity(AdminView adminView,
+ AdminNavigation.Presenter adminNavigationPresenter,
+ AdminOverview view) {
+ super(adminView, adminNavigationPresenter, view);
+ }
+
+ @Override
+ protected String[] getRequiredRoles() {
+ return new String[]{"read:admin"};
+ }
+
+ @Override
+ public void start(AcceptsOneWidget container, EventBus eventBus, Collection<EventRegistration> registrations) {
+ super.start(container, eventBus, registrations);
+ adminContent.setPresenter(this);
+ }
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewImpl.java b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewImpl.java
new file mode 100644
index 000000000..593362cfe
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewImpl.java
@@ -0,0 +1,47 @@
+/*
+ * 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.admin.overview;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+
+import javax.inject.Inject;
+
+public class AdminOverviewImpl extends Composite implements AdminOverview {
+
+ interface UI extends UiBinder<HTMLPanel, AdminOverviewImpl> {
+ }
+
+ private UI ui = GWT.create(UI.class);
+
+ Presenter presenter;
+
+ @Inject
+ public AdminOverviewImpl() {
+ initWidget(ui.createAndBindUi(this));
+ }
+
+ @Override
+ public void setPresenter(Presenter presenter) {
+ this.presenter = presenter;
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewImpl.ui.xml
new file mode 100644
index 000000000..177343a94
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewImpl.ui.xml
@@ -0,0 +1,15 @@
+<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="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
+
+ <g:HTMLPanel styleName="flex layout vertical">
+
+ <div class="{widgetStyle.Headline1} {themeStyle.Headline1}">Admin Overview</div>
+
+ </g:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewPlace.java b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewPlace.java
new file mode 100644
index 000000000..34c2287fe
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/overview/AdminOverviewPlace.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.admin.overview;
+
+import com.google.gwt.place.shared.PlaceTokenizer;
+import com.google.gwt.place.shared.Prefix;
+import org.openremote.manager.client.admin.AdminPlace;
+
+public class AdminOverviewPlace extends AdminPlace {
+
+ @Prefix("admin")
+ public static class Tokenizer implements PlaceTokenizer<AdminOverviewPlace> {
+
+ @Override
+ public AdminOverviewPlace getPlace(String token) {
+ return new AdminOverviewPlace();
+ }
+
+ @Override
+ public String getToken(AdminOverviewPlace place) {
+ return "";
+ }
+ }
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealms.java b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealms.java
new file mode 100644
index 000000000..97b6f7f2c
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealms.java
@@ -0,0 +1,32 @@
+/*
+ * 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.admin.realms;
+
+import org.openremote.manager.client.admin.AdminContent;
+
+public interface AdminRealms extends AdminContent {
+
+ interface Presenter {
+
+ }
+
+ void setPresenter(Presenter presenter);
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsActivity.java b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsActivity.java
new file mode 100644
index 000000000..33c02449d
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsActivity.java
@@ -0,0 +1,54 @@
+/*
+ * 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.admin.realms;
+
+import com.google.gwt.user.client.ui.AcceptsOneWidget;
+import org.openremote.manager.client.admin.AbstractAdminActivity;
+import org.openremote.manager.client.admin.AdminView;
+import org.openremote.manager.client.admin.navigation.AdminNavigation;
+import org.openremote.manager.client.event.bus.EventBus;
+import org.openremote.manager.client.event.bus.EventRegistration;
+
+import javax.inject.Inject;
+import java.util.Collection;
+
+public class AdminRealmsActivity
+ extends AbstractAdminActivity<AdminRealmsPlace, AdminRealms>
+ implements AdminRealms.Presenter {
+
+ @Inject
+ public AdminRealmsActivity(AdminView adminView,
+ AdminNavigation.Presenter adminNavigationPresenter,
+ AdminRealms view) {
+ super(adminView, adminNavigationPresenter, view);
+ }
+
+ @Override
+ protected String[] getRequiredRoles() {
+ return new String[]{"read:admin"};
+ }
+
+ @Override
+ public void start(AcceptsOneWidget container, EventBus eventBus, Collection<EventRegistration> registrations) {
+ super.start(container, eventBus, registrations);
+ adminContent.setPresenter(this);
+ }
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsImpl.java b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsImpl.java
new file mode 100644
index 000000000..2f5cf4821
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsImpl.java
@@ -0,0 +1,47 @@
+/*
+ * 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.admin.realms;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+
+import javax.inject.Inject;
+
+public class AdminRealmsImpl extends Composite implements AdminRealms {
+
+ interface UI extends UiBinder<HTMLPanel, AdminRealmsImpl> {
+ }
+
+ private UI ui = GWT.create(UI.class);
+
+ Presenter presenter;
+
+ @Inject
+ public AdminRealmsImpl() {
+ initWidget(ui.createAndBindUi(this));
+ }
+
+ @Override
+ public void setPresenter(Presenter presenter) {
+ this.presenter = presenter;
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsImpl.ui.xml
new file mode 100644
index 000000000..698dc3b64
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsImpl.ui.xml
@@ -0,0 +1,15 @@
+<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="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
+
+ <g:HTMLPanel styleName="flex layout vertical">
+
+ <div class="{widgetStyle.Headline1} {themeStyle.Headline1}">Manage Tenants</div>
+
+ </g:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsPlace.java b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsPlace.java
new file mode 100644
index 000000000..59f0c188a
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/realms/AdminRealmsPlace.java
@@ -0,0 +1,33 @@
+package org.openremote.manager.client.admin.realms;
+
+import com.google.gwt.place.shared.PlaceTokenizer;
+import com.google.gwt.place.shared.Prefix;
+import org.openremote.manager.client.admin.AdminPlace;
+
+public class AdminRealmsPlace extends AdminPlace {
+
+ final String realm;
+
+ public AdminRealmsPlace(String realm) {
+ this.realm = realm;
+ }
+
+ public String getRealm() {
+ return realm;
+ }
+
+ @Prefix("realm")
+ public static class Tokenizer implements PlaceTokenizer<AdminRealmsPlace> {
+
+ @Override
+ public AdminRealmsPlace getPlace(String token) {
+ return new AdminRealmsPlace(token);
+ }
+
+ @Override
+ public String getToken(AdminRealmsPlace place) {
+ return place.getRealm() != null ? place.getRealm() : "";
+ }
+ }
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsers.java b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsers.java
new file mode 100644
index 000000000..5e61af38a
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsers.java
@@ -0,0 +1,32 @@
+/*
+ * 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.admin.users;
+
+import org.openremote.manager.client.admin.AdminContent;
+
+public interface AdminUsers extends AdminContent {
+
+ interface Presenter {
+
+ }
+
+ void setPresenter(Presenter presenter);
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersActivity.java b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersActivity.java
new file mode 100644
index 000000000..9b666c77b
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersActivity.java
@@ -0,0 +1,54 @@
+/*
+ * 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.admin.users;
+
+import com.google.gwt.user.client.ui.AcceptsOneWidget;
+import org.openremote.manager.client.admin.AbstractAdminActivity;
+import org.openremote.manager.client.admin.AdminView;
+import org.openremote.manager.client.admin.navigation.AdminNavigation;
+import org.openremote.manager.client.event.bus.EventBus;
+import org.openremote.manager.client.event.bus.EventRegistration;
+
+import javax.inject.Inject;
+import java.util.Collection;
+
+public class AdminUsersActivity
+ extends AbstractAdminActivity<AdminUsersPlace, AdminUsers>
+ implements AdminUsers.Presenter {
+
+ @Inject
+ public AdminUsersActivity(AdminView adminView,
+ AdminNavigation.Presenter adminNavigationPresenter,
+ AdminUsers view) {
+ super(adminView, adminNavigationPresenter, view);
+ }
+
+ @Override
+ protected String[] getRequiredRoles() {
+ return new String[]{"read:admin"};
+ }
+
+ @Override
+ public void start(AcceptsOneWidget container, EventBus eventBus, Collection<EventRegistration> registrations) {
+ super.start(container, eventBus, registrations);
+ adminContent.setPresenter(this);
+ }
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersImpl.java b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersImpl.java
new file mode 100644
index 000000000..94746bfb6
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersImpl.java
@@ -0,0 +1,47 @@
+/*
+ * 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.admin.users;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+
+import javax.inject.Inject;
+
+public class AdminUsersImpl extends Composite implements AdminUsers {
+
+ interface UI extends UiBinder<HTMLPanel, AdminUsersImpl> {
+ }
+
+ private UI ui = GWT.create(UI.class);
+
+ Presenter presenter;
+
+ @Inject
+ public AdminUsersImpl() {
+ initWidget(ui.createAndBindUi(this));
+ }
+
+ @Override
+ public void setPresenter(Presenter presenter) {
+ this.presenter = presenter;
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersImpl.ui.xml
new file mode 100644
index 000000000..797230ef6
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersImpl.ui.xml
@@ -0,0 +1,15 @@
+<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="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
+
+ <g:HTMLPanel styleName="flex layout vertical">
+
+ <div class="{widgetStyle.Headline1} {themeStyle.Headline1}">Manage Users</div>
+
+ </g:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersPlace.java b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersPlace.java
new file mode 100644
index 000000000..bf1b8fcac
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/admin/users/AdminUsersPlace.java
@@ -0,0 +1,33 @@
+package org.openremote.manager.client.admin.users;
+
+import com.google.gwt.place.shared.PlaceTokenizer;
+import com.google.gwt.place.shared.Prefix;
+import org.openremote.manager.client.admin.AdminPlace;
+
+public class AdminUsersPlace extends AdminPlace {
+
+ final String userId;
+
+ public AdminUsersPlace(String userId) {
+ this.userId = userId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ @Prefix("user")
+ public static class Tokenizer implements PlaceTokenizer<AdminUsersPlace> {
+
+ @Override
+ public AdminUsersPlace getPlace(String token) {
+ return new AdminUsersPlace(token);
+ }
+
+ @Override
+ public String getToken(AdminUsersPlace place) {
+ return place.getUserId() != null ? place.getUserId() : "";
+ }
+ }
+
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/app/AppViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/app/AppViewImpl.ui.xml
index 6cc5e0283..477308e52 100644
--- a/manager/src/main/java/org/openremote/manager/client/app/AppViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/app/AppViewImpl.ui.xml
@@ -15,7 +15,7 @@
</ui:style>
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<g:FlowPanel styleName="layout vertical" addStyleNames="{style.viewport}">
<g:SimplePanel ui:field="header" styleName="layout horizontal"/>
diff --git a/manager/src/main/java/org/openremote/manager/client/app/FooterViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/app/FooterViewImpl.ui.xml
index 77bbdf7ae..d9e265d6b 100644
--- a/manager/src/main/java/org/openremote/manager/client/app/FooterViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/app/FooterViewImpl.ui.xml
@@ -9,7 +9,7 @@
</ui:style>
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<g:HTMLPanel styleName="flex layout horizontal" addStyleNames="{style.footer} {themeStyle.Footer}">
Footer
diff --git a/manager/src/main/java/org/openremote/manager/client/app/HeaderPresenter.java b/manager/src/main/java/org/openremote/manager/client/app/HeaderPresenter.java
index 561d13e8b..9ec3a194e 100644
--- a/manager/src/main/java/org/openremote/manager/client/app/HeaderPresenter.java
+++ b/manager/src/main/java/org/openremote/manager/client/app/HeaderPresenter.java
@@ -27,6 +27,9 @@ import org.openremote.manager.client.event.UserChangeEvent;
import org.openremote.manager.client.event.bus.EventBus;
import org.openremote.manager.client.service.SecurityService;
import org.openremote.manager.client.user.UserControls;
+import org.openremote.manager.client.util.JsUtil;
+
+import static org.openremote.manager.shared.Constants.MANAGER_CLIENT_ID;
public class HeaderPresenter implements HeaderView.Presenter {
@@ -58,6 +61,8 @@ public class HeaderPresenter implements HeaderView.Presenter {
UserChangeEvent.class,
event -> view.setUsername(event.getUsername())
);
+
+ JsUtil.log(securityService.getParsedToken());
}
@Override
@@ -74,4 +79,9 @@ public class HeaderPresenter implements HeaderView.Presenter {
public UserControls getUserControls() {
return userControlsPresenter.getView();
}
+
+ @Override
+ public boolean isUserInRole(String role) {
+ return securityService.hasResourceRoleOrIsAdmin(role, MANAGER_CLIENT_ID);
+ }
}
diff --git a/manager/src/main/java/org/openremote/manager/client/app/HeaderView.java b/manager/src/main/java/org/openremote/manager/client/app/HeaderView.java
index 4465ff5b1..ad837f045 100644
--- a/manager/src/main/java/org/openremote/manager/client/app/HeaderView.java
+++ b/manager/src/main/java/org/openremote/manager/client/app/HeaderView.java
@@ -31,6 +31,8 @@ public interface HeaderView extends IsWidget {
void goTo(Place place);
UserControls getUserControls();
+
+ boolean isUserInRole(String role);
}
void setPresenter(Presenter presenter);
diff --git a/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.java b/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.java
index 551d43e6e..468c5a2b8 100644
--- a/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.java
+++ b/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.java
@@ -29,7 +29,9 @@ import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.inject.Inject;
-import org.openremote.manager.client.ThemeStyle;
+import org.openremote.manager.client.style.ThemeStyle;
+import org.openremote.manager.client.admin.AdminPlace;
+import org.openremote.manager.client.admin.overview.AdminOverviewPlace;
import org.openremote.manager.client.assets.AssetsPlace;
import org.openremote.manager.client.flows.FlowsPlace;
import org.openremote.manager.client.map.MapPlace;
@@ -71,9 +73,15 @@ public class HeaderViewImpl extends Composite implements HeaderView {
@UiField
PushButton assetsButton;
+ @UiField
+ PushButton rulesButton;
+
@UiField
PushButton flowsButton;
+ @UiField
+ PushButton adminButton;
+
@UiField
PushButton userButton;
@@ -85,6 +93,12 @@ public class HeaderViewImpl extends Composite implements HeaderView {
@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
+
+ mapButton.setEnabled(presenter.isUserInRole("read:map"));
+ assetsButton.setEnabled(presenter.isUserInRole("read:assets"));
+ rulesButton.setEnabled(presenter.isUserInRole("read:rules"));
+ flowsButton.setEnabled(presenter.isUserInRole("read:flows"));
+ adminButton.setEnabled(presenter.isUserInRole("read:admin"));
}
@Override
@@ -92,6 +106,7 @@ public class HeaderViewImpl extends Composite implements HeaderView {
mapButton.removeStyleName(themeStyle.NavItemActive());
assetsButton.removeStyleName(themeStyle.NavItemActive());
flowsButton.removeStyleName(themeStyle.NavItemActive());
+ adminButton.removeStyleName(themeStyle.NavItemActive());
userButton.removeStyleName(themeStyle.NavItemActive());
if (place instanceof MapPlace) {
@@ -103,6 +118,9 @@ public class HeaderViewImpl extends Composite implements HeaderView {
if (place instanceof FlowsPlace) {
flowsButton.addStyleName(themeStyle.NavItemActive());
}
+ if (place instanceof AdminPlace) {
+ adminButton.addStyleName(themeStyle.NavItemActive());
+ }
if (place instanceof UserAccountPlace) {
userButton.addStyleName(themeStyle.NavItemActive());
}
@@ -115,22 +133,27 @@ public class HeaderViewImpl extends Composite implements HeaderView {
}
@UiHandler("mapButton")
- void itemMapClicked(ClickEvent e) {
+ void mapClicked(ClickEvent e) {
presenter.goTo(new MapPlace());
}
@UiHandler("assetsButton")
- void itemAssetsClicked(ClickEvent e) {
+ void assetsClicked(ClickEvent e) {
presenter.goTo(new AssetsPlace());
}
+ @UiHandler("adminButton")
+ void adminClicked(ClickEvent e) {
+ presenter.goTo(new AdminOverviewPlace());
+ }
+
@UiHandler("flowsButton")
- void itemFlowsClicked(ClickEvent e) {
+ void flowsClicked(ClickEvent e) {
presenter.goTo(new FlowsPlace());
}
@UiHandler("userButton")
- public void onToggleNotificationPanel(final ClickEvent event) {
+ public void userClicked(final ClickEvent event) {
presenter.getUserControls().toggleRelativeTo(userButton);
}
}
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.ui.xml
index b73bb3b2d..1c91ce111 100644
--- a/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/app/HeaderViewImpl.ui.xml
@@ -27,14 +27,14 @@
</ui:style>
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
- <g:HTMLPanel styleName="flex layout horizontal center" addStyleNames="{style.header} {themeStyle.Header}">
+ <g:HTMLPanel styleName="flex layout horizontal center {style.header} {widgetStyle.Header} {themeStyle.Header}">
<g:HTMLPanel ui:field="quickAccess"
- styleName="or-PushButton"
- addStyleNames="{style.navItem} {style.navItemFirst} {themeStyle.NavItem}">
- <g:HTMLPanel addStyleNames="{style.logoButton}" styleName="layout horizontal center">
+ styleName="{style.navItem} {style.navItemFirst} {widgetStyle.NavItem} {themeStyle.NavItem}">
+ <g:HTMLPanel styleName="layout horizontal center {style.logoButton}">
<svg style="pointer-events: none; display: block; height: 100%; margin-right: 8px;" viewBox="0 0 24 24"
preserveAspectRatio="xMidYMid meet">
<path fill="#C4D600"
@@ -49,25 +49,35 @@
</g:HTMLPanel>
<w:PushButton ui:field="mapButton"
- addStyleNames="{style.navItem} {themeStyle.NavItem}"
+ addStyleNames="{style.navItem} {widgetStyle.NavItem} {themeStyle.NavItem}"
icon="map"
- text="{constants.locate}"/>
+ text="{constants.map}"/>
<w:PushButton ui:field="assetsButton"
- addStyleNames="{style.navItem} {themeStyle.NavItem}"
- icon="table"
- text="{constants.manage}"/>
+ addStyleNames="{style.navItem} {widgetStyle.NavItem} {themeStyle.NavItem}"
+ icon="cubes"
+ text="{constants.assets}"/>
+
+ <w:PushButton ui:field="rulesButton"
+ addStyleNames="{style.navItem} {widgetStyle.NavItem} {themeStyle.NavItem}"
+ icon="chain"
+ text="{constants.rules}"/>
<w:PushButton ui:field="flowsButton"
- addStyleNames="{style.navItem} {themeStyle.NavItem}"
+ addStyleNames="{style.navItem} {widgetStyle.NavItem} {themeStyle.NavItem}"
icon="connectdevelop"
- text="{constants.connect}"/>
+ text="{constants.flows}"/>
<g:HTMLPanel styleName="flex"/>
+ <w:PushButton ui:field="adminButton"
+ addStyleNames="{style.navItem} {widgetStyle.NavItem} {themeStyle.NavItem}"
+ icon="gears"
+ text="{constants.admin}"/>
+
<w:PushButton ui:field="userButton"
icon="user"
- addStyleNames="{style.navItem} {style.navItemLast} {themeStyle.NavItem}"/>
+ addStyleNames="{style.navItem} {style.navItemLast} {widgetStyle.NavItem} {themeStyle.NavItem}"/>
</g:HTMLPanel>
diff --git a/manager/src/main/java/org/openremote/manager/client/app/MainActivityMapper.java b/manager/src/main/java/org/openremote/manager/client/app/MainActivityMapper.java
deleted file mode 100644
index 2a1f9b656..000000000
--- a/manager/src/main/java/org/openremote/manager/client/app/MainActivityMapper.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.app;
-
-import com.google.gwt.place.shared.Place;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import org.openremote.manager.client.assets.AssetDetailActivity;
-import org.openremote.manager.client.assets.AssetsPlace;
-import org.openremote.manager.client.flows.FlowsActivity;
-import org.openremote.manager.client.flows.FlowsPlace;
-import org.openremote.manager.client.map.MapActivity;
-import org.openremote.manager.client.map.MapPlace;
-import org.openremote.manager.client.mvp.AppActivity;
-import org.openremote.manager.client.mvp.AppActivityMapper;
-import org.openremote.manager.client.user.UserAccountActivity;
-import org.openremote.manager.client.user.UserAccountPlace;
-
-import java.util.logging.Logger;
-
-public class MainActivityMapper implements AppActivityMapper {
-
- private static final Logger LOG = Logger.getLogger(MainActivityMapper.class.getName());
-
- protected final Provider<AssetDetailActivity> assetsActivityProvider;
- protected final Provider<MapActivity> mapActivityProvider;
- protected final Provider<FlowsActivity> flowsActivityProvider;
- protected final Provider<UserAccountActivity> userProfileActivityProvider;
-
- @Inject
- public MainActivityMapper(Provider<AssetDetailActivity> assetsActivityProvider,
- Provider<MapActivity> mapActivityProvider,
- Provider<FlowsActivity> flowsActivityProvider,
- Provider<UserAccountActivity> userProfileActivityProvider) {
- this.assetsActivityProvider = assetsActivityProvider;
- this.mapActivityProvider = mapActivityProvider;
- this.flowsActivityProvider = flowsActivityProvider;
- this.userProfileActivityProvider = userProfileActivityProvider;
- }
-
- public AppActivity getActivity(Place place) {
- if (place instanceof AssetsPlace) {
- return assetsActivityProvider.get().init((AssetsPlace) place);
- }
- if (place instanceof MapPlace) {
- return mapActivityProvider.get().init((MapPlace) place);
- }
- if (place instanceof FlowsPlace) {
- return flowsActivityProvider.get().init((FlowsPlace) place);
- }
- if (place instanceof UserAccountPlace) {
- return userProfileActivityProvider.get().init((UserAccountPlace)place);
- }
- return null;
- }
-}
diff --git a/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailActivity.java b/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailActivity.java
index 67660e89a..acf116a2c 100644
--- a/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailActivity.java
+++ b/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailActivity.java
@@ -55,10 +55,15 @@ public class AssetDetailActivity
}
@Override
- public AppActivity<AssetsPlace> init(AssetsPlace place) {
+ protected AppActivity<AssetsPlace> init(AssetsPlace place) {
return this;
}
+ @Override
+ protected String[] getRequiredRoles() {
+ return new String[]{"read:assets"};
+ }
+
@Override
public void start(AcceptsOneWidget container, EventBus eventBus, Collection<EventRegistration> registrations) {
view.setPresenter(this);
diff --git a/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailViewImpl.ui.xml
index 658606a0c..4f32cd3d8 100644
--- a/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/assets/AssetDetailViewImpl.ui.xml
@@ -3,25 +3,26 @@
xmlns:w="urn:import:org.openremote.manager.client.widget">
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
- <g:HTMLPanel styleName="flex layout vertical or-MainContent">
+ <g:HTMLPanel styleName="flex layout vertical {widgetStyle.MainContent} {themeStyle.MainContent}">
<div style="padding: 1em;">
<w:PushButton ui:field="showInfo"
- addStyleNames="{themeStyle.PushButton}"
+ addStyleNames="{widgetStyle.PushButton} {themeStyle.PushButton}"
text="Show INFO message"/>
<w:PushButton ui:field="showTempFailure"
- addStyleNames="{themeStyle.PushButton}"
+ addStyleNames="{widgetStyle.PushButton} {themeStyle.PushButton}"
text="Show temporary ERROR message"/>
<w:PushButton ui:field="showDurableFailure"
- addStyleNames="{themeStyle.PushButton}"
+ addStyleNames="{widgetStyle.PushButton} {themeStyle.PushButton}"
text="Show durable ERROR message"/>
</div>
<div style="padding: 1em;">
<w:PushButton ui:field="sendMessageButton"
- addStyleNames="{themeStyle.PushButton}"
+ addStyleNames="{widgetStyle.PushButton} {themeStyle.PushButton}"
text="Send message to server"/>
<g:Label ui:field="messageLabel" text="Waiting for response..."/>
</div>
diff --git a/manager/src/main/java/org/openremote/manager/client/assets/AssetListActivity.java b/manager/src/main/java/org/openremote/manager/client/assets/AssetListActivity.java
index 93842338c..8102436af 100644
--- a/manager/src/main/java/org/openremote/manager/client/assets/AssetListActivity.java
+++ b/manager/src/main/java/org/openremote/manager/client/assets/AssetListActivity.java
@@ -47,7 +47,7 @@ public class AssetListActivity
}
@Override
- public AppActivity<AssetsPlace> init(AssetsPlace place) {
+ protected AppActivity<AssetsPlace> init(AssetsPlace place) {
return this;
}
diff --git a/manager/src/main/java/org/openremote/manager/client/assets/AssetListViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/assets/AssetListViewImpl.ui.xml
index de9d3f33e..12a5e945b 100644
--- a/manager/src/main/java/org/openremote/manager/client/assets/AssetListViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/assets/AssetListViewImpl.ui.xml
@@ -2,7 +2,7 @@
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<g:ScrollPanel>
<g:VerticalPanel>
diff --git a/manager/src/main/java/org/openremote/manager/client/flows/FlowsActivity.java b/manager/src/main/java/org/openremote/manager/client/flows/FlowsActivity.java
index 1172d7b54..cb06a5c45 100644
--- a/manager/src/main/java/org/openremote/manager/client/flows/FlowsActivity.java
+++ b/manager/src/main/java/org/openremote/manager/client/flows/FlowsActivity.java
@@ -49,7 +49,7 @@ public class FlowsActivity
}
@Override
- public AppActivity<FlowsPlace> init(FlowsPlace place) {
+ protected AppActivity<FlowsPlace> init(FlowsPlace place) {
return this;
}
diff --git a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.java b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.java
index e118db214..263c64cc4 100644
--- a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.java
+++ b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.java
@@ -31,13 +31,23 @@ public interface ManagerConstants extends Constants {
String inventory();
- String locate();
+ String map();
- String manage();
+ String assets();
- String connect();
+ String rules();
+
+ String flows();
+
+ String admin();
String mapLoading();
String editAccount();
+
+ String manageRealms();
+
+ String manageUsers();
+
+ String overview();
}
diff --git a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.properties b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.properties
index b75e85506..4fe3aa8ab 100644
--- a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.properties
+++ b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerConstants.properties
@@ -1,8 +1,13 @@
appTitle = OpenRemote Manager
-locate = Locate
-manage = Manage
-connect = Connect
+map = Map
+assets = Assets
+rules = Rules
+flows = Apps
+admin = System
logout = Logout
inventory = Inventory
mapLoading = Loading map, please wait...
-editAccount = Edit my account
\ No newline at end of file
+editAccount = Edit my account
+manageRealms = Manage tenants
+manageUsers = Manage users
+overview = Overview
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java
index 2a3e95620..bf7326e69 100644
--- a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java
+++ b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.java
@@ -25,5 +25,7 @@ import com.google.gwt.i18n.client.Messages;
@LocalizableResource.DefaultLocale("en")
public interface ManagerMessages extends Messages {
+ String accessDenied();
+
String failureLoadingMapSettings(String error);
}
diff --git a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.properties b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.properties
index a8ee4b3a9..bd8290f48 100644
--- a/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.properties
+++ b/manager/src/main/java/org/openremote/manager/client/i18n/ManagerMessages.properties
@@ -1 +1,2 @@
+accessDenied=You do not have permission to access this feature.
failureLoadingMapSettings=Error loading map settings from server. {0}
diff --git a/manager/src/main/java/org/openremote/manager/client/map/MapActivity.java b/manager/src/main/java/org/openremote/manager/client/map/MapActivity.java
index 8306d89ae..5a69db4f3 100644
--- a/manager/src/main/java/org/openremote/manager/client/map/MapActivity.java
+++ b/manager/src/main/java/org/openremote/manager/client/map/MapActivity.java
@@ -57,10 +57,15 @@ public class MapActivity extends AppActivity<MapPlace> implements MapView.Presen
}
@Override
- public AppActivity<MapPlace> init(MapPlace place) {
+ protected AppActivity<MapPlace> init(MapPlace place) {
return this;
}
+ @Override
+ protected String[] getRequiredRoles() {
+ return new String[]{"read:map"};
+ }
+
@Override
public void start(AcceptsOneWidget container, EventBus eventBus, Collection<EventRegistration> registrations) {
view.setPresenter(this);
diff --git a/manager/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml
index 99bf9e86b..7a64af674 100644
--- a/manager/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/map/MapViewImpl.ui.xml
@@ -3,7 +3,7 @@
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<ui:style>
.mapContainer {
diff --git a/manager/src/main/java/org/openremote/manager/client/mvp/AppActivity.java b/manager/src/main/java/org/openremote/manager/client/mvp/AppActivity.java
index 0e09a8691..441753cc0 100644
--- a/manager/src/main/java/org/openremote/manager/client/mvp/AppActivity.java
+++ b/manager/src/main/java/org/openremote/manager/client/mvp/AppActivity.java
@@ -23,6 +23,8 @@ import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import org.openremote.manager.client.event.bus.EventBus;
import org.openremote.manager.client.event.bus.EventRegistration;
+import org.openremote.manager.client.service.SecurityService;
+import org.openremote.manager.shared.Constants;
import java.util.Collection;
@@ -41,10 +43,26 @@ public abstract class AppActivity<T extends Place> {
public void onStop() {
}
- public abstract AppActivity<T> init(T place);
+ public AppActivity<T> init(SecurityService securityService, T place) throws RoleRequiredException {
+ for (String requiredRole : getRequiredRoles()) {
+ if (!securityService.hasResourceRoleOrIsAdmin(requiredRole, Constants.MANAGER_CLIENT_ID)) {
+ throw new RoleRequiredException();
+ }
+ }
+ return init(place);
+ };
+
+ protected abstract AppActivity<T> init(T place);
/**
* Any registrations added to the supplied collection will be unregistered automatically when the activity stops.
*/
abstract public void start(AcceptsOneWidget container, EventBus eventBus, Collection<EventRegistration> registrations);
+
+ /**
+ * Checked when the activity is initialized, return empty array to allow all access.
+ */
+ protected String[] getRequiredRoles() {
+ return new String[0];
+ }
}
diff --git a/manager/src/main/java/org/openremote/manager/client/mvp/AppActivityManager.java b/manager/src/main/java/org/openremote/manager/client/mvp/AppActivityManager.java
index cb5285aa5..78070d89c 100644
--- a/manager/src/main/java/org/openremote/manager/client/mvp/AppActivityManager.java
+++ b/manager/src/main/java/org/openremote/manager/client/mvp/AppActivityManager.java
@@ -62,7 +62,7 @@ public class AppActivityManager {
protected static final AppActivity NULL_ACTIVITY = new AppActivity() {
@Override
- public AppActivity init(Place place) {
+ protected AppActivity init(Place place) {
return this;
}
diff --git a/manager/src/main/java/org/openremote/manager/client/mvp/RoleRequiredException.java b/manager/src/main/java/org/openremote/manager/client/mvp/RoleRequiredException.java
new file mode 100644
index 000000000..67dc1c95b
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/mvp/RoleRequiredException.java
@@ -0,0 +1,23 @@
+package org.openremote.manager.client.mvp;
+
+public class RoleRequiredException extends Exception {
+
+ public RoleRequiredException() {
+ }
+
+ public RoleRequiredException(String message) {
+ super(message);
+ }
+
+ public RoleRequiredException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public RoleRequiredException(Throwable cause) {
+ super(cause);
+ }
+
+ public RoleRequiredException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/service/SecurityService.java b/manager/src/main/java/org/openremote/manager/client/service/SecurityService.java
index 81cee6baf..12a7c938f 100644
--- a/manager/src/main/java/org/openremote/manager/client/service/SecurityService.java
+++ b/manager/src/main/java/org/openremote/manager/client/service/SecurityService.java
@@ -19,7 +19,6 @@
*/
package org.openremote.manager.client.service;
-import elemental.json.JsonObject;
import org.openremote.manager.client.interop.keycloak.AuthToken;
import org.openremote.manager.client.interop.keycloak.LoginOptions;
import org.openremote.manager.client.interop.keycloak.LogoutOptions;
@@ -28,7 +27,7 @@ import org.openremote.manager.shared.Runnable;
public interface SecurityService {
- public static final int MIN_VALIDITY_SECONDS = 10;
+ int MIN_VALIDITY_SECONDS = 10;
void login();
@@ -46,6 +45,8 @@ public interface SecurityService {
boolean hasResourceRole(String role, String resource);
+ boolean hasResourceRoleOrIsAdmin(String role, String resource);
+
boolean isTokenExpired();
boolean isTokenExpired(int minValiditySeconds);
diff --git a/manager/src/main/java/org/openremote/manager/client/service/SecurityServiceImpl.java b/manager/src/main/java/org/openremote/manager/client/service/SecurityServiceImpl.java
index 74db49d13..d4ba4d68b 100644
--- a/manager/src/main/java/org/openremote/manager/client/service/SecurityServiceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/client/service/SecurityServiceImpl.java
@@ -87,6 +87,11 @@ public class SecurityServiceImpl implements SecurityService {
return keycloak.hasResourceRole(role, resource);
}
+ @Override
+ public boolean hasResourceRoleOrIsAdmin(String role, String resource) {
+ return keycloak.hasResourceRole(role, resource) || keycloak.hasRealmRole("admin");
+ }
+
@Override
public boolean isTokenExpired() {
return keycloak.isTokenExpired();
diff --git a/manager/src/main/java/org/openremote/manager/client/ThemeStyle.java b/manager/src/main/java/org/openremote/manager/client/style/AbstractStyle.java
similarity index 56%
rename from manager/src/main/java/org/openremote/manager/client/ThemeStyle.java
rename to manager/src/main/java/org/openremote/manager/client/style/AbstractStyle.java
index 07b16129b..5803fa475 100644
--- a/manager/src/main/java/org/openremote/manager/client/ThemeStyle.java
+++ b/manager/src/main/java/org/openremote/manager/client/style/AbstractStyle.java
@@ -17,69 +17,81 @@
* 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;
+package org.openremote.manager.client.style;
-public class ThemeStyle {
-
- public static final String PREFIX = "theme-";
+public abstract class AbstractStyle {
+
+ abstract String getPrefix();
public String Header() {
- return PREFIX + "Header";
+ return getPrefix() + "Header";
}
public String Footer() {
- return PREFIX + "Footer";
+ return getPrefix() + "Footer";
}
public String NavItem() {
- return PREFIX + "NavItem";
+ return getPrefix() + "NavItem";
}
public String NavItemActive() {
- return PREFIX + "NavItemActive";
+ return getPrefix() + "NavItemActive";
+ }
+
+ public String SidebarContent() {
+ return getPrefix() + "SidebarContent";
+ }
+
+ public String MainContent() {
+ return getPrefix() + "MainContent";
}
public String PushButton() {
- return PREFIX + "PushButton";
+ return getPrefix() + "PushButton";
}
public String Hyperlink() {
- return PREFIX + "Hyperlink";
+ return getPrefix() + "Hyperlink";
}
public String UnorderedList() {
- return PREFIX + "UnorderedList";
+ return getPrefix() + "UnorderedList";
}
public String Toast() {
- return PREFIX + "Toast";
+ return getPrefix() + "Toast";
}
public String ToastInfo() {
- return PREFIX + "ToastInfo";
+ return getPrefix() + "ToastInfo";
}
public String ToastFailure() {
- return PREFIX + "ToastFailure";
+ return getPrefix() + "ToastFailure";
+ }
+
+ public String MessagesIcon() {
+ return getPrefix() + "MessagesIcon";
}
public String PopupPanel() {
- return PREFIX + "PopupPanel";
+ return getPrefix() + "PopupPanel";
}
public String PopupPanelHeader() {
- return PREFIX + "PopupPanelHeader";
+ return getPrefix() + "PopupPanelHeader";
}
public String PopupPanelContent() {
- return PREFIX + "PopupPanelContent";
+ return getPrefix() + "PopupPanelContent";
}
public String PopupPanelFooter() {
- return PREFIX + "PopupPanelFooter";
+ return getPrefix() + "PopupPanelFooter";
}
- public String Header1() {
- return PREFIX + "Header1";
+ public String Headline1() {
+ return getPrefix() + "Headline1";
}
-}
\ No newline at end of file
+}
diff --git a/manager/src/main/java/org/openremote/manager/client/style/ThemeStyle.java b/manager/src/main/java/org/openremote/manager/client/style/ThemeStyle.java
new file mode 100644
index 000000000..11cfd50b1
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/style/ThemeStyle.java
@@ -0,0 +1,29 @@
+/*
+ * 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.style;
+
+public class ThemeStyle extends AbstractStyle {
+
+ @Override
+ String getPrefix() {
+ return "theme-";
+ }
+
+}
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/style/WidgetStyle.java b/manager/src/main/java/org/openremote/manager/client/style/WidgetStyle.java
new file mode 100644
index 000000000..df77b2119
--- /dev/null
+++ b/manager/src/main/java/org/openremote/manager/client/style/WidgetStyle.java
@@ -0,0 +1,28 @@
+/*
+ * 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.style;
+
+public class WidgetStyle extends AbstractStyle {
+
+ @Override
+ String getPrefix() {
+ return "or-";
+ }
+}
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/client/toast/PopupToastDisplay.java b/manager/src/main/java/org/openremote/manager/client/toast/PopupToastDisplay.java
index e011287ec..ec07cf85c 100644
--- a/manager/src/main/java/org/openremote/manager/client/toast/PopupToastDisplay.java
+++ b/manager/src/main/java/org/openremote/manager/client/toast/PopupToastDisplay.java
@@ -23,8 +23,8 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import org.openremote.manager.client.ThemeStyle;
+import org.openremote.manager.client.style.ThemeStyle;
+import org.openremote.manager.client.style.WidgetStyle;
import org.openremote.manager.client.util.Point;
import org.openremote.manager.client.util.Rectangle;
@@ -38,11 +38,13 @@ public class PopupToastDisplay implements ToastDisplay {
public static final int MARGIN_BOTTOM_PIXEL = 10;
public static final int MARGIN_RIGHT_PIXEL = 25;
+ final protected WidgetStyle widgetStyle;
final protected ThemeStyle themeStyle;
final protected Map<Toast, ToastPopupPanel> toastPanels = new HashMap<>();
@Inject
- public PopupToastDisplay(ThemeStyle themeStyle) {
+ public PopupToastDisplay(WidgetStyle widgetStyle, ThemeStyle themeStyle) {
+ this.widgetStyle = widgetStyle;
this.themeStyle = themeStyle;
}
@@ -88,12 +90,20 @@ public class PopupToastDisplay implements ToastDisplay {
boolean isInfo = toast.getType() == Toast.Type.INFO;
content.setStyleName("layout horizontal center");
- content.addStyleName("or-Toast");
+ content.addStyleName(widgetStyle.Toast());
content.addStyleName(themeStyle.Toast());
- content.addStyleName(isInfo ? themeStyle.ToastInfo() : themeStyle.ToastFailure());
+ if (isInfo) {
+ content.addStyleName(widgetStyle.ToastInfo());
+ content.addStyleName(themeStyle.ToastInfo());
+ } else {
+ content.addStyleName(widgetStyle.ToastFailure());
+ content.addStyleName(themeStyle.ToastFailure());
+ }
Label icon = new Label();
- icon.setStyleName("or-MessagesIcon theme-MessagesIcon fa fa-" + (isInfo ? "check" : "warning"));
+ icon.setStyleName("fa fa-" + (isInfo ? "check" : "warning"));
+ icon.addStyleName(widgetStyle.MessagesIcon());
+ icon.addStyleName(themeStyle.MessagesIcon());
content.add(icon);
Label text = new Label(toast.getText());
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserAccountActivity.java b/manager/src/main/java/org/openremote/manager/client/user/UserAccountActivity.java
index 7ab910acb..6418b66a3 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserAccountActivity.java
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserAccountActivity.java
@@ -52,7 +52,7 @@ public class UserAccountActivity extends AppActivity<UserAccountPlace> implement
}
@Override
- public AppActivity<UserAccountPlace> init(UserAccountPlace place) {
+ protected AppActivity<UserAccountPlace> init(UserAccountPlace place) {
return this;
}
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml
index 645c6730b..2e3e7e61c 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserAccountViewImpl.ui.xml
@@ -3,7 +3,7 @@
xmlns:w="urn:import:org.openremote.manager.client.widget">
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<g:HTMLPanel styleName="flex layout vertical">
<iframe ui:field="frame"
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserControls.java b/manager/src/main/java/org/openremote/manager/client/user/UserControls.java
index 9fdd83d80..be03783b6 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserControls.java
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserControls.java
@@ -31,7 +31,10 @@ public interface UserControls {
void setPresenter(Presenter presenter);
- void setUserDetails(String username, String fullName, String userProfilePlaceToken);
+ void setUserDetails(String username,
+ String fullName,
+ String userProfilePlaceToken,
+ boolean hasManageAccountRole);
void toggleRelativeTo(UIObject target);
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.java b/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.java
index 3e5ea40af..f69646c45 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.java
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.java
@@ -20,6 +20,8 @@
package org.openremote.manager.client.user;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.LIElement;
+import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
@@ -42,6 +44,9 @@ public class UserControlsImpl extends AbstractAppPanel implements UserControls {
@UiField
Label userLabel;
+ @UiField
+ LIElement editProfileItem;
+
@UiField
Hyperlink editProfileLink;
@@ -59,8 +64,15 @@ public class UserControlsImpl extends AbstractAppPanel implements UserControls {
}
@Override
- public void setUserDetails(String username, String fullName, String userProfilePlaceToken) {
+ public void setUserDetails(String username,
+ String fullName,
+ String userProfilePlaceToken,
+ boolean hasManageAccountRole) {
userLabel.setText(fullName != null && fullName.length() > 0 ? fullName : username);
+
+ editProfileItem.getStyle().setDisplay(
+ hasManageAccountRole ? Style.Display.LIST_ITEM : Style.Display.NONE
+ );
editProfileLink.setTargetHistoryToken(userProfilePlaceToken);
}
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml b/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml
index 0f2f88d3b..3d1d266ee 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserControlsImpl.ui.xml
@@ -3,21 +3,19 @@
xmlns:w="urn:import:org.openremote.manager.client.widget">
<ui:with field="constants" type="org.openremote.manager.client.i18n.ManagerConstants"/>
- <ui:with field="themeStyle" type="org.openremote.manager.client.ThemeStyle"/>
+ <ui:with field="widgetStyle" type="org.openremote.manager.client.style.WidgetStyle"/>
+ <ui:with field="themeStyle" type="org.openremote.manager.client.style.ThemeStyle"/>
<ui:style>
.popup {
z-index: 10;
}
- .popup, .panel {
+ .panel {
width: 15em;
height: 10em;
}
- .panel {
- }
-
.header {
font-weight: 700;
padding: 0.4em;
@@ -40,29 +38,31 @@
}
</ui:style>
- <g:PopupPanel glassEnabled="false" addStyleNames="{style.popup} {themeStyle.PopupPanel}">
- <g:HTMLPanel styleName="flex layout vertical" addStyleNames="{style.panel}">
- <g:HTMLPanel styleName="layout horizontal" addStyleNames="{style.header} {themeStyle.PopupPanelHeader}">
+ <g:PopupPanel glassEnabled="false" addStyleNames="{style.popup} {widgetStyle.PopupPanel} {themeStyle.PopupPanel}">
+ <g:HTMLPanel styleName="flex layout vertical {style.panel}">
+ <g:HTMLPanel styleName="layout horizontal {style.header} {widgetStyle.PopupPanelHeader} {themeStyle.PopupPanelHeader}">
<g:Label ui:field="userLabel"/>
</g:HTMLPanel>
<g:HTMLPanel styleName="flex layout vertical"
- addStyleNames="{style.content} {themeStyle.PopupPanelContent}">
+ addStyleNames="{style.content} {widgetStyle.PopupPanelContent} {themeStyle.PopupPanelContent}">
+
+ <ul class="{widgetStyle.UnorderedList} {themeStyle.UnorderedList}">
- <ul class="or-UnorderedList {themeStyle.UnorderedList}">
- <li>
+ <li ui:field="editProfileItem">
<w:Hyperlink ui:field="editProfileLink"
- addStyleNames="{themeStyle.Hyperlink}"
+ addStyleNames="{widgetStyle.Hyperlink} {themeStyle.Hyperlink}"
text="{constants.editAccount}"/>
</li>
+
</ul>
</g:HTMLPanel>
<g:HTMLPanel styleName="layout horizontal center-center"
- addStyleNames="{style.footer} {themeStyle.PopupPanelFooter}">
+ addStyleNames="{style.footer} {widgetStyle.PopupPanelFooter} {themeStyle.PopupPanelFooter}">
<w:PushButton ui:field="logoutButton"
icon="sign-out"
text="{constants.logout}"
- addStyleNames="{themeStyle.PushButton}"/>
+ addStyleNames="{widgetStyle.PushButton} {themeStyle.PushButton}"/>
</g:HTMLPanel>
</g:HTMLPanel>
</g:PopupPanel>
diff --git a/manager/src/main/java/org/openremote/manager/client/user/UserControlsPresenter.java b/manager/src/main/java/org/openremote/manager/client/user/UserControlsPresenter.java
index 6a417c297..083c020fb 100644
--- a/manager/src/main/java/org/openremote/manager/client/user/UserControlsPresenter.java
+++ b/manager/src/main/java/org/openremote/manager/client/user/UserControlsPresenter.java
@@ -25,9 +25,14 @@ import org.openremote.manager.client.ManagerHistoryMapper;
import org.openremote.manager.client.event.UserChangeEvent;
import org.openremote.manager.client.event.bus.EventBus;
import org.openremote.manager.client.service.SecurityService;
+import org.openremote.manager.client.util.JsUtil;
+
+import java.util.logging.Logger;
public class UserControlsPresenter implements UserControls.Presenter {
+ private static final Logger LOG = Logger.getLogger(UserControlsPresenter.class.getName());
+
final protected UserControls view;
final protected SecurityService securityService;
final protected PlaceController placeController;
@@ -65,7 +70,8 @@ public class UserControlsPresenter implements UserControls.Presenter {
view.setUserDetails(
securityService.getParsedToken().getPreferredUsername(),
securityService.getParsedToken().getName(),
- managerHistoryMapper.getToken(new UserAccountPlace())
+ managerHistoryMapper.getToken(new UserAccountPlace()),
+ securityService.hasResourceRole("manage-account", "account")
);
}
diff --git a/manager/src/main/java/org/openremote/manager/server/SampleDataService.java b/manager/src/main/java/org/openremote/manager/server/SampleDataService.java
index 14642e4a7..d313c82b4 100644
--- a/manager/src/main/java/org/openremote/manager/server/SampleDataService.java
+++ b/manager/src/main/java/org/openremote/manager/server/SampleDataService.java
@@ -40,8 +40,8 @@ import java.util.List;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.openremote.container.web.WebClient.getTarget;
-import static org.openremote.manager.server.Constants.MANAGER_CLIENT_ID;
-import static org.openremote.manager.server.Constants.MASTER_REALM;
+import static org.openremote.manager.shared.Constants.MANAGER_CLIENT_ID;
+import static org.openremote.manager.shared.Constants.MASTER_REALM;
import static rx.Observable.fromCallable;
public class SampleDataService implements ContainerService {
diff --git a/manager/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java b/manager/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java
index c6d3ab6f8..60015f18a 100644
--- a/manager/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java
+++ b/manager/src/main/java/org/openremote/manager/server/security/ManagerIdentityService.java
@@ -21,7 +21,7 @@ package org.openremote.manager.server.security;
import org.openremote.container.Container;
import org.openremote.container.security.IdentityService;
-import org.openremote.manager.server.Constants;
+import org.openremote.manager.shared.Constants;
public class ManagerIdentityService extends IdentityService {
diff --git a/manager/src/main/java/org/openremote/manager/server/web/ManagerWebService.java b/manager/src/main/java/org/openremote/manager/server/web/ManagerWebService.java
index aedbbf938..d605bcb34 100644
--- a/manager/src/main/java/org/openremote/manager/server/web/ManagerWebService.java
+++ b/manager/src/main/java/org/openremote/manager/server/web/ManagerWebService.java
@@ -24,7 +24,7 @@ import org.openremote.container.web.WebService;
import java.nio.file.Paths;
-import static org.openremote.manager.server.Constants.MASTER_REALM;
+import static org.openremote.manager.shared.Constants.MASTER_REALM;
public class ManagerWebService extends WebService {
diff --git a/manager/src/main/java/org/openremote/manager/server/Constants.java b/manager/src/main/java/org/openremote/manager/shared/Constants.java
similarity index 95%
rename from manager/src/main/java/org/openremote/manager/server/Constants.java
rename to manager/src/main/java/org/openremote/manager/shared/Constants.java
index b94cde370..070cac941 100644
--- a/manager/src/main/java/org/openremote/manager/server/Constants.java
+++ b/manager/src/main/java/org/openremote/manager/shared/Constants.java
@@ -17,7 +17,7 @@
* 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.server;
+package org.openremote.manager.shared;
public interface Constants {
diff --git a/manager/src/main/webapp/css/style.html b/manager/src/main/webapp/css/style.html
index 0af486780..819cc01d2 100644
--- a/manager/src/main/webapp/css/style.html
+++ b/manager/src/main/webapp/css/style.html
@@ -92,13 +92,13 @@
text-decoration: underline;
}
- .or-Header1 {
+ .or-Headline1 {
font-size: x-large;
font-weight: 600;
margin: 0 0 0.4em 0;
}
- .or-HeaderSub {
+ .or-HeadlineSub {
font-size: smaller;
font-weight: 600;
margin: 0 0 0.4em 0;
diff --git a/manager/src/main/webapp/css/theme.html b/manager/src/main/webapp/css/theme.html
index 9b2fd232e..6af9ad29f 100644
--- a/manager/src/main/webapp/css/theme.html
+++ b/manager/src/main/webapp/css/theme.html
@@ -65,11 +65,11 @@
color: var(--theme-darkgrey);
}
- .theme-Header1 {
+ .theme-Headline1 {
color: var(--theme-darkgrey);
}
- .theme-HeaderSub {
+ .theme-HeadlineSub {
color: var(--theme-mediumgrey);
}
diff --git a/manager/src/test/groovy/org/openremote/test/assets/AssetDetailActivityTest.groovy b/manager/src/test/groovy/org/openremote/test/assets/AssetDetailActivityTest.groovy
index 8d61274b8..4817ab0a0 100644
--- a/manager/src/test/groovy/org/openremote/test/assets/AssetDetailActivityTest.groovy
+++ b/manager/src/test/groovy/org/openremote/test/assets/AssetDetailActivityTest.groovy
@@ -11,8 +11,8 @@ import org.openremote.test.ContainerTrait
import spock.lang.Specification
import spock.util.concurrent.BlockingVariables
-import static org.openremote.manager.server.Constants.MANAGER_CLIENT_ID
-import static org.openremote.manager.server.Constants.MASTER_REALM
+import static org.openremote.manager.shared.Constants.MANAGER_CLIENT_ID
+import static org.openremote.manager.shared.Constants.MASTER_REALM
class AssetDetailActivityTest extends Specification implements ContainerTrait {
diff --git a/manager/src/test/groovy/org/openremote/test/assets/AssetsResourceTest.groovy b/manager/src/test/groovy/org/openremote/test/assets/AssetsResourceTest.groovy
index 79fa2e0ab..567f68a86 100644
--- a/manager/src/test/groovy/org/openremote/test/assets/AssetsResourceTest.groovy
+++ b/manager/src/test/groovy/org/openremote/test/assets/AssetsResourceTest.groovy
@@ -17,8 +17,8 @@ import spock.lang.Specification
import javax.ws.rs.NotFoundException
-import static org.openremote.manager.server.Constants.MANAGER_CLIENT_ID
-import static org.openremote.manager.server.Constants.MASTER_REALM
+import static org.openremote.manager.shared.Constants.MANAGER_CLIENT_ID
+import static org.openremote.manager.shared.Constants.MASTER_REALM
class AssetsResourceTest extends Specification implements ContainerTrait {
diff --git a/manager/src/test/groovy/org/openremote/test/event/EventEchoTest.groovy b/manager/src/test/groovy/org/openremote/test/event/EventEchoTest.groovy
index a13b84b17..aaee63f7b 100644
--- a/manager/src/test/groovy/org/openremote/test/event/EventEchoTest.groovy
+++ b/manager/src/test/groovy/org/openremote/test/event/EventEchoTest.groovy
@@ -6,8 +6,8 @@ import org.openremote.test.ContainerTrait
import org.openremote.test.WebsocketClientTrait
import spock.lang.Specification
-import static org.openremote.manager.server.Constants.MANAGER_CLIENT_ID
-import static org.openremote.manager.server.Constants.MASTER_REALM
+import static org.openremote.manager.shared.Constants.MANAGER_CLIENT_ID
+import static org.openremote.manager.shared.Constants.MASTER_REALM
class EventEchoTest extends Specification implements ContainerTrait, WebsocketClientTrait {
diff --git a/manager/src/test/groovy/org/openremote/test/map/MapActivityTest.groovy b/manager/src/test/groovy/org/openremote/test/map/MapActivityTest.groovy
index 496d67fc0..d33166a1c 100644
--- a/manager/src/test/groovy/org/openremote/test/map/MapActivityTest.groovy
+++ b/manager/src/test/groovy/org/openremote/test/map/MapActivityTest.groovy
@@ -13,8 +13,8 @@ import org.openremote.manager.shared.map.MapResource
import org.openremote.test.ContainerTrait
import spock.lang.Specification
-import static org.openremote.manager.server.Constants.MANAGER_CLIENT_ID
-import static org.openremote.manager.server.Constants.MASTER_REALM
+import static org.openremote.manager.shared.Constants.MANAGER_CLIENT_ID
+import static org.openremote.manager.shared.Constants.MASTER_REALM
class MapActivityTest extends Specification implements ContainerTrait {
diff --git a/manager/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy b/manager/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
index 9d31fd92e..bc438f448 100644
--- a/manager/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
+++ b/manager/src/test/groovy/org/openremote/test/map/MapResourceTest.groovy
@@ -5,8 +5,8 @@ import org.openremote.manager.shared.map.MapResource
import org.openremote.test.ContainerTrait
import spock.lang.Specification
-import static org.openremote.manager.server.Constants.MANAGER_CLIENT_ID
-import static org.openremote.manager.server.Constants.MASTER_REALM
+import static org.openremote.manager.shared.Constants.MANAGER_CLIENT_ID
+import static org.openremote.manager.shared.Constants.MASTER_REALM
class MapResourceTest extends Specification implements ContainerTrait {