Skip to content

Commit

Permalink
Improved client startup procedure, added loader busy indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bauer committed Jan 9, 2018
1 parent 97d9ed6 commit 74b16f5
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 74 deletions.
39 changes: 25 additions & 14 deletions client/src/main/java/org/openremote/app/client/AppEntryPoint.java
Expand Up @@ -21,30 +21,41 @@


import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;


import java.util.logging.Logger;

public class AppEntryPoint implements com.google.gwt.core.client.EntryPoint { public class AppEntryPoint implements com.google.gwt.core.client.EntryPoint {


private static final Logger LOG = Logger.getLogger(AppEntryPoint.class.getName());

protected final ManagerGinjector injector = GWT.create(ManagerGinjector.class); protected final ManagerGinjector injector = GWT.create(ManagerGinjector.class);


@Override
public void onModuleLoad() {
LOG.info("App GWT module loaded");
dispatchLoadedEvent();
}

protected void startManager() { protected void startManager() {
injector.getAppController().start(); injector.getAppController().start();
} }


public native void dispatchLoadedEvent() /*-{ protected void stopManager() {
$wnd.addEventListener("StartManager", function() { injector.getAppController().stop();
this.@org.openremote.app.client.AppEntryPoint::startManager()(); }
}.bind(this));


@Override
public native void onModuleLoad() /*-{
console.log("App GWT module loaded")
// Add a one-time event listener that starts the manager
var startEventListener = function(e) {
if (!$wnd.openremote.INSTANCE.error) {
this.@org.openremote.app.client.AppEntryPoint::startManager()();
}
e.currentTarget.removeEventListener("StartManager", startEventListener);
}.bind(this);
$wnd.addEventListener("StartManager", startEventListener);
// Add a one-time event listener that stops the manager
var stopEventListener = function(e) {
this.@org.openremote.app.client.AppEntryPoint::stopManager()();
e.currentTarget.removeEventListener("AppError", stopEventListener);
}.bind(this);
$wnd.addEventListener("AppError", stopEventListener);
// Let others know jsinterop components are loaded
$wnd.dispatchEvent(new CustomEvent("AppLoaded")); $wnd.dispatchEvent(new CustomEvent("AppLoaded"));
}-*/; }-*/;



} }
Expand Up @@ -26,4 +26,6 @@ public interface AppController {
void goTo(Place place); void goTo(Place place);


void start(); void start();

void stop();
} }
Expand Up @@ -21,21 +21,25 @@


import com.google.gwt.place.shared.Place; import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceHistoryHandler; import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.google.inject.Provider; import com.google.inject.Provider;
import elemental2.dom.DomGlobal;
import org.openremote.app.client.Environment; import org.openremote.app.client.Environment;
import org.openremote.app.client.event.ShowFailureEvent; import org.openremote.app.client.event.ShowFailureEvent;
import org.openremote.app.client.event.ShowInfoEvent; import org.openremote.app.client.event.ShowInfoEvent;
import org.openremote.app.client.event.ShowSuccessEvent; import org.openremote.app.client.event.ShowSuccessEvent;
import org.openremote.app.client.event.SubscriptionFailureEvent; import org.openremote.app.client.event.SubscriptionFailureEvent;
import org.openremote.app.client.toast.Toast; import org.openremote.app.client.toast.Toast;
import org.openremote.app.client.toast.Toasts; import org.openremote.app.client.toast.Toasts;
import org.openremote.model.event.bus.EventListener;


import javax.inject.Inject; import javax.inject.Inject;
import java.util.logging.Logger;


public class AppControllerImpl implements AppController, AppView.Presenter { public class AppControllerImpl implements AppController, AppView.Presenter {


private static final Logger LOG = Logger.getLogger(AppControllerImpl.class.getName());

protected final AppView appView; protected final AppView appView;
protected final Environment environment; protected final Environment environment;
protected final PlaceHistoryHandler placeHistoryHandler; protected final PlaceHistoryHandler placeHistoryHandler;
Expand Down Expand Up @@ -103,9 +107,15 @@ public void goTo(Place place) {


@Override @Override
public void start() { public void start() {
Window.setTitle("OpenRemote Manager"); LOG.info("Starting manager");
RootPanel.get().add(appView);
appView.setPresenter(this); appView.setPresenter(this);
RootPanel.get().add(appView);
placeHistoryHandler.handleCurrentHistory(); placeHistoryHandler.handleCurrentHistory();
} }

@Override
public void stop() {
LOG.info("Stopping manager");
RootPanel.get().remove(appView);
}
} }
Expand Up @@ -61,7 +61,6 @@ interface UI extends UiBinder<FlowPanel, AppViewImpl> {
@Inject @Inject
public AppViewImpl() { public AppViewImpl() {
initWidget(ui.createAndBindUi(this)); initWidget(ui.createAndBindUi(this));

} }


@Override @Override
Expand Down
Expand Up @@ -17,7 +17,7 @@
} }


.logo { .logo {
height: 30px; margin-right: 1em;
} }


.brand { .brand {
Expand All @@ -40,17 +40,6 @@


<g:HTMLPanel styleName="{style.logoItem}"> <g:HTMLPanel styleName="{style.logoItem}">
<g:HTMLPanel styleName="layout horizontal center {style.logo}"> <g:HTMLPanel styleName="layout horizontal center {style.logo}">
<!--
<svg style="pointer-events: none; display: block; height: 100%;" viewBox="0 0 24 24"
preserveAspectRatio="xMidYMid meet">
<path fill="#C4D600"
d="M11.93,21.851c-5.551,0-10.066-4.515-10.066-10.065h2.108c0,4.388,3.57,7.958,7.958,7.958 c4.387,0,7.958-3.57,7.958-7.958c0-4.388-3.57-7.958-7.958-7.958V1.72c5.55,0,10.066,4.517,10.066,10.066 C21.996,17.336,17.48,21.851,11.93,21.851L11.93,21.851z"/>
<path fill="#4E9D2D"
d="M10.406,19.088c-1.95-0.406-3.626-1.549-4.717-3.215s-1.469-3.66-1.062-5.61 c0.407-1.951,1.55-3.626,3.217-4.718c1.667-1.092,3.659-1.469,5.61-1.062c4.027,0.84,6.62,4.799,5.779,8.825l-2.063-0.429 c0.603-2.889-1.257-5.73-4.147-6.333c-1.4-0.292-2.829-0.022-4.025,0.762C7.802,8.091,6.982,9.293,6.69,10.693 c-0.291,1.398-0.021,2.828,0.762,4.024c0.783,1.196,1.985,2.016,3.385,2.307L10.406,19.088L10.406,19.088z"/>
<path fill="#1D5632"
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="{widgetStyle.Hyperlink} {style.brand}"> <div class="{widgetStyle.Hyperlink} {style.brand}">
<g:Anchor href="https://openremote.com/">OpenRemote Inc.</g:Anchor> <g:Anchor href="https://openremote.com/">OpenRemote Inc.</g:Anchor>
</div> </div>
Expand Down
Expand Up @@ -29,8 +29,6 @@ public interface ManagerMessages extends Messages {


String logout(); String logout();


String sessionTimedOut();

String map(); String map();


String assets(); String assets();
Expand Down
Expand Up @@ -67,7 +67,6 @@ roleLabel[write-rules]=Write rulesets (NOTE: effectively super-user access!)
noteRolesAfterCreate=You can assign access roles after creating the user. noteRolesAfterCreate=You can assign access roles after creating the user.
showMoreAssets=Show more assets showMoreAssets=Show more assets
emptyAsset=No assets found. emptyAsset=No assets found.
sessionTimedOut=Your session timed out. Please close or reload this browser window.
description=Description description=Description
unsupportedAttributeType=Not implemented attribute type: {0} unsupportedAttributeType=Not implemented attribute type: {0}
unsupportedMetaItemType=Not implemented meta item type : {0} unsupportedMetaItemType=Not implemented meta item type : {0}
Expand Down
4 changes: 2 additions & 2 deletions client/src/main/webapp/index.html
Expand Up @@ -33,11 +33,11 @@
app.set("error", e); app.set("error", e);
}); });
}); });

</script> </script>

</head> </head>


<body class="layout vertical" style="visibility:hidden;"> <body class="layout vertical">


<or-app login="true"></or-app> <or-app login="true"></or-app>
<or-toast></or-toast> <or-toast></or-toast>
Expand Down
10 changes: 5 additions & 5 deletions client/src/main/webapp/src/or-app/or-app-security.html
Expand Up @@ -140,8 +140,8 @@


/** /**
* Name of the OpenRemote tenant realm this app wants to connect to * Name of the OpenRemote tenant realm this app wants to connect to
* and possibly login and authenticate with. The realm can be overridden with an * and login and authenticate with. The realm can be overridden with an
* attribute, otherwise try to get it from URL path, first segment. * attribute, otherwise it will be obtained from the URL path, first segment.
*/ */
realm: { realm: {
type: String, type: String,
Expand Down Expand Up @@ -171,14 +171,14 @@
ready() { ready() {
super.ready(); super.ready();


// If we don't have a tenant realm, get it from the URL path // If login is required, and we don't have a realm, get it from the URL path
if (!this.realm) { if (this.login && !this.realm) {
if (!window.location.pathname || window.location.pathname.length <= 1) { if (!window.location.pathname || window.location.pathname.length <= 1) {
this.set("error", "No tenant realm configured and URL doesn't have any path elements"); this.set("error", "No tenant realm configured and URL doesn't have any path elements");
return; return;
} }
let realm = window.location.pathname.split('/')[1]; let realm = window.location.pathname.split('/')[1];
console.log("No tenant realm configured, using: " + realm); console.log("No tenant realm configured, using first URL path segment: " + realm);
this.set("realm", realm); this.set("realm", realm);
} }
} }
Expand Down

0 comments on commit 74b16f5

Please sign in to comment.