Permalink
Browse files

Delegate websocket messages from manager UI to or-app web component

  • Loading branch information...
christianbauer committed Jan 12, 2018
1 parent e25653c commit 6ab7b098aa70b957a0fe8e8073fd3ae0663a3f5a
Showing with 314 additions and 553 deletions.
  1. +1 −2 client/src/main/java/org/openremote/app/client/Environment.java
  2. +4 −6 client/src/main/java/org/openremote/app/client/ManagerModule.java
  3. +10 −3 client/src/main/java/org/openremote/app/client/OpenRemoteApp.java
  4. +4 −4 client/src/main/java/org/openremote/app/client/admin/syslog/AdminSyslogActivity.java
  5. +4 −4 client/src/main/java/org/openremote/app/client/admin/tenant/AdminTenantActivity.java
  6. +1 −1 client/src/main/java/org/openremote/app/client/admin/tenant/AdminTenantsActivity.java
  7. +2 −2 client/src/main/java/org/openremote/app/client/admin/users/AdminUsersActivity.java
  8. +9 −9 client/src/main/java/org/openremote/app/client/admin/users/edit/AdminUserEditActivity.java
  9. +5 −5 ...main/java/org/openremote/app/client/admin/users/notifications/AdminUserNotificationsActivity.java
  10. +10 −0 client/src/main/java/org/openremote/app/client/app/AppControllerImpl.java
  11. +1 −1 client/src/main/java/org/openremote/app/client/apps/ConsoleAppsActivity.java
  12. +1 −1 client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java
  13. +8 −8 client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java
  14. +2 −2 client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java
  15. +3 −3 client/src/main/java/org/openremote/app/client/assets/browser/AssetBrowserPresenter.java
  16. +5 −5 client/src/main/java/org/openremote/app/client/assets/tenant/AssetsTenantActivity.java
  17. +3 −3 client/src/main/java/org/openremote/app/client/{service → event}/EventService.java
  18. +137 −0 client/src/main/java/org/openremote/app/client/event/EventServiceImpl.java
  19. +0 −25 client/src/main/java/org/openremote/app/client/event/session/SessionCloseEvent.java
  20. +0 −25 client/src/main/java/org/openremote/app/client/event/session/SessionClosedCleanEvent.java
  21. +0 −46 client/src/main/java/org/openremote/app/client/event/session/SessionClosedErrorEvent.java
  22. +0 −25 client/src/main/java/org/openremote/app/client/event/session/SessionConnectEvent.java
  23. +0 −25 client/src/main/java/org/openremote/app/client/event/session/SessionOpenedEvent.java
  24. +1 −1 client/src/main/java/org/openremote/app/client/map/MapActivity.java
  25. +11 −2 client/src/main/java/org/openremote/app/client/mvp/AppPlaceController.java
  26. +7 −7 client/src/main/java/org/openremote/app/client/rest/{RequestService.java → Requests.java}
  27. +4 −4 client/src/main/java/org/openremote/app/client/rules/AbstractRulesEditorActivity.java
  28. +1 −1 client/src/main/java/org/openremote/app/client/rules/asset/AssetRulesEditorActivity.java
  29. +1 −1 client/src/main/java/org/openremote/app/client/rules/asset/AssetRulesListActivity.java
  30. +1 −1 client/src/main/java/org/openremote/app/client/rules/global/GlobalRulesListActivity.java
  31. +1 −1 client/src/main/java/org/openremote/app/client/rules/tenant/TenantRulesEditorActivity.java
  32. +2 −2 client/src/main/java/org/openremote/app/client/rules/tenant/TenantRulesListActivity.java
  33. +0 −292 client/src/main/java/org/openremote/app/client/service/EventServiceImpl.java
  34. +57 −20 client/src/main/webapp/src/or-app/or-app.html
  35. +1 −1 client/src/main/webapp/src/or-asset-list/or-asset-list.html
  36. +3 −0 model/src/main/java/org/openremote/model/event/Event.java
  37. +7 −7 test/src/main/groovy/org/openremote/test/ClientEventService.groovy
  38. +5 −5 test/src/main/groovy/org/openremote/test/TestOpenRemoteApp.java
  39. +1 −2 test/src/test/groovy/org/openremote/test/admin/AdminTenantsActivityTest.groovy
  40. +1 −1 test/src/test/groovy/org/openremote/test/admin/AdminUsersActivityTest.groovy
@@ -21,10 +21,9 @@
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.place.shared.PlaceHistoryMapper;
import org.openremote.app.client.OpenRemoteApp;
import org.openremote.app.client.style.WidgetStyle;
import org.openremote.app.client.i18n.ManagerMessages;
import org.openremote.app.client.service.EventService;
import org.openremote.app.client.event.EventService;
import org.openremote.model.event.bus.EventBus;
/**
@@ -30,8 +30,8 @@
import org.openremote.app.client.i18n.ManagerMessages;
import org.openremote.app.client.mvp.AppActivityManager;
import org.openremote.app.client.mvp.AppPlaceController;
import org.openremote.app.client.service.EventService;
import org.openremote.app.client.service.EventServiceImpl;
import org.openremote.app.client.event.EventService;
import org.openremote.app.client.event.EventServiceImpl;
import org.openremote.app.client.style.WidgetStyle;
import org.openremote.model.event.bus.EventBus;
import org.openremote.model.security.TenantResource;
@@ -92,17 +92,15 @@ public EventService getEventService(OpenRemoteApp app,
EventSubscriptionMapper eventSubscriptionMapper,
CancelEventSubscriptionMapper cancelEventSubscriptionMapper,
UnauthorizedEventSubscriptionMapper unauthorizedEventSubscriptionMapper) {
EventService eventService = EventServiceImpl.create(
app.getSecurity(),
return new EventServiceImpl(
app,
eventBus,
sharedEventMapper,
sharedEventArrayMapper,
eventSubscriptionMapper,
cancelEventSubscriptionMapper,
unauthorizedEventSubscriptionMapper
);
eventService.connect();
return eventService;
}
@Provides
@@ -5,8 +5,10 @@
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import jsinterop.base.Any;
import org.openremote.app.client.rest.RequestService;
import org.openremote.app.client.rest.Requests;
import org.openremote.app.client.toast.Toasts;
import org.openremote.model.interop.Consumer;
import org.openremote.model.interop.Runnable;
import org.openremote.model.security.Tenant;
/**
@@ -24,8 +26,13 @@
public native Toasts getToasts();
@JsProperty
public native RequestService getRequestService();
public native Requests getRequests();
public native void set(String property, Any value);
public native void addServiceMessageConsumer(Consumer<String> message);
public native void addServiceConnectionCloseListener(Runnable listener);
public native void sendServiceMessage(String message);
public native void set(String property, Any value);
}
@@ -131,7 +131,7 @@ public void saveSettings() {
// TODO Client-side validation error handling?
adminContent.setFormBusy(true);
readFromView();
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
syslogConfigMapper,
requestParams -> {
syslogResource.updateConfig(requestParams, config);
@@ -149,7 +149,7 @@ public void saveSettings() {
@Override
public void removeAll() {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().send(
environment.getApp().getRequests().send(
syslogResource::clearEvents,
204,
() -> {
@@ -164,7 +164,7 @@ public void removeAll() {
protected void fetchEvents() {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
sharedEventArrayMapper,
requestParams -> syslogResource.getEvents(requestParams, filterLevel, filterLimit),
200,
@@ -189,7 +189,7 @@ protected void fetchEvents() {
protected void loadConfig() {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
syslogConfigMapper,
syslogResource::getConfig,
200,
@@ -128,7 +128,7 @@ public void create() {
adminContent.clearFormMessages();
clearViewFieldErrors();
readFromView();
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
tenantMapper,
requestParams -> tenantResource.create(requestParams, tenant),
204,
@@ -149,7 +149,7 @@ public void update() {
adminContent.clearFormMessages();
clearViewFieldErrors();
readFromView();
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
tenantMapper,
requestParams -> tenantResource.update(requestParams, realm, tenant),
204,
@@ -173,7 +173,7 @@ public void delete() {
adminContent.setFormBusy(true);
adminContent.clearFormMessages();
clearViewFieldErrors();
environment.getApp().getRequestService().send(
environment.getApp().getRequests().send(
requestParams -> tenantResource.delete(requestParams, this.realm),
204,
() -> {
@@ -195,7 +195,7 @@ public void cancel() {
protected void loadTenant() {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
tenantMapper,
requestParams -> tenantResource.get(requestParams, realm),
200,
@@ -65,7 +65,7 @@ public void start(AcceptsView container, EventBus eventBus, Collection<EventRegi
adminContent.setPresenter(this);
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
tenantArrayMapper,
tenantResource::getAll,
200,
@@ -84,7 +84,7 @@ public void start(AcceptsView container, EventBus eventBus, Collection<EventRegi
adminContent.setPresenter(this);
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
tenantArrayMapper,
tenantResource::getAll,
200,
@@ -96,7 +96,7 @@ public void start(AcceptsView container, EventBus eventBus, Collection<EventRegi
if (realm != null) {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
userArrayMapper,
requestParams -> userResource.getAll(requestParams, realm),
200,
@@ -197,7 +197,7 @@ public void create() {
adminContent.clearFormMessages();
clearViewFieldErrors();
readFromView();
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
userMapper,
requestParams -> userResource.create(requestParams, realm, user),
204,
@@ -238,7 +238,7 @@ protected void handlePasswordReset() {
return;
}
Credential credential = new Credential(password, false);
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
credentialMapper,
requestParams -> userResource.resetPassword(requestParams, realm, userId, credential),
204,
@@ -247,7 +247,7 @@ protected void handlePasswordReset() {
}
protected void updateUser() {
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
userMapper,
requestParams -> userResource.update(requestParams, realm, userId, user),
204,
@@ -260,7 +260,7 @@ protected void updateUser() {
}
protected void updateRoles(Runnable onComplete) {
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
roleArrayMapper,
requestParams -> userResource.updateRoles(requestParams, realm, userId, roles),
204,
@@ -270,7 +270,7 @@ protected void updateRoles(Runnable onComplete) {
@Override
public void onDeviceRegistrationDelete(DeviceNotificationToken.Id id) {
environment.getApp().getRequestService().send(
environment.getApp().getRequests().send(
requestParams -> notificationResource.deleteDeviceToken(requestParams, id.getUserId(), id.getDeviceId()),
204,
() -> {
@@ -296,7 +296,7 @@ public void delete() {
adminContent.setFormBusy(true);
adminContent.clearFormMessages();
clearViewFieldErrors();
environment.getApp().getRequestService().send(
environment.getApp().getRequests().send(
requestParams -> userResource.delete(requestParams, realm, userId),
204,
() -> {
@@ -313,7 +313,7 @@ public void delete() {
protected void loadUser() {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
userMapper,
requestParams -> userResource.get(requestParams, realm, userId),
200,
@@ -333,7 +333,7 @@ protected void loadUser() {
}
protected void loadRoles(Runnable onComplete) {
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
roleArrayMapper,
requestParams -> userResource.getRoles(requestParams, realm, userId),
200,
@@ -349,7 +349,7 @@ protected void loadRoles(Runnable onComplete) {
}
protected void loadDeviceRegistrations(Runnable onComplete) {
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
deviceNotificationTokenMapper,
requestParams -> notificationResource.getDeviceTokens(requestParams, userId),
200,
@@ -127,7 +127,7 @@ public void onSendNotification() {
notificationEditor.setOnSend(updatedNotification -> {
adminContent.setFormBusy(true);
this.alertNotification = updatedNotification;
environment.getApp().getRequestService().sendWith(
environment.getApp().getRequests().sendWith(
alertNotificationMapper,
requestParams -> notificationResource.storeNotificationForUser(requestParams, userId, this.alertNotification),
204,
@@ -151,7 +151,7 @@ public void onRefresh() {
@Override
public void onNotificationsDelete() {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().send(
environment.getApp().getRequests().send(
requestParams -> notificationResource.removeNotificationsOfUser(requestParams, userId),
204,
() -> {
@@ -166,7 +166,7 @@ public void onNotificationsDelete() {
@Override
public void onNotificationDelete(Long id) {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().send(
environment.getApp().getRequests().send(
requestParams -> notificationResource.removeNotification(requestParams, userId, id),
204,
() -> {
@@ -194,7 +194,7 @@ protected AlertNotification createDefaultNotification() {
protected void loadUser() {
adminContent.setFormBusy(true);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
userMapper,
requestParams -> userResource.get(requestParams, realm, userId),
200,
@@ -210,7 +210,7 @@ protected void loadUser() {
}
protected void loadNotifications(Runnable onComplete) {
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
alertNotificationArrayMapper,
requestParams -> notificationResource.getNotificationsOfUser(requestParams, userId),
200,
@@ -20,6 +20,7 @@
package org.openremote.app.client.app;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.inject.Provider;
@@ -28,6 +29,7 @@
import org.openremote.app.client.event.ShowInfoEvent;
import org.openremote.app.client.event.ShowSuccessEvent;
import org.openremote.app.client.event.SubscriptionFailureEvent;
import org.openremote.app.client.mvp.AppPlaceController;
import org.openremote.app.client.toast.Toast;
import javax.inject.Inject;
@@ -40,17 +42,20 @@
protected final AppView appView;
protected final Environment environment;
protected final PlaceHistoryHandler placeHistoryHandler;
protected final PlaceController placeController;
@Inject
public AppControllerImpl(Environment environment,
PlaceHistoryHandler placeHistoryHandler,
Provider<HeaderPresenter> headerPresenterProvider,
Provider<FooterPresenter> footerPresenterProvider,
AppView appView,
PlaceController placeController,
AppInitializer appInitializer) { // AppInitializer is needed so that activities are mapped to views
this.appView = appView;
this.environment = environment;
this.placeHistoryHandler = placeHistoryHandler;
this.placeController = placeController;
// Configure layout as not using activity mapper (it's static)
HeaderPresenter headerPresenter = headerPresenterProvider.get();
@@ -113,5 +118,10 @@ public void start() {
public void stop() {
LOG.info("Stopping manager");
RootPanel.get().remove(appView);
if (placeController instanceof AppPlaceController) {
AppPlaceController appPlaceController = (AppPlaceController) placeController;
appPlaceController.stop();
}
environment.getEventService().stop();
}
}
@@ -61,7 +61,7 @@ public void start(AcceptsView container, EventBus eventBus, Collection<EventRegi
container.setViewComponent(view);
view.setPresenter(this);
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
consoleAppArrayMapper,
consoleAppResource::getInstalledApps,
200,
@@ -139,7 +139,7 @@ public void start(AcceptsView container, EventBus eventBus, Collection<EventRegi
));
if (!view.isMapInitialised()) {
environment.getApp().getRequestService().sendAndReturn(
environment.getApp().getRequests().sendAndReturn(
objectValueMapper,
mapResource::getSettings,
200,
Oops, something went wrong.

0 comments on commit 6ab7b09

Please sign in to comment.