Permalink
Browse files

Improved client startup procedure, added loader busy indicator

  • Loading branch information...
christianbauer committed Jan 9, 2018
1 parent 97d9ed6 commit 74b16f5269bc3bc9ea4a554637255e229cca7c4e
@@ -21,30 +21,41 @@
import com.google.gwt.core.client.GWT;
import java.util.logging.Logger;
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);
@Override
public void onModuleLoad() {
LOG.info("App GWT module loaded");
dispatchLoadedEvent();
}
protected void startManager() {
injector.getAppController().start();
}
public native void dispatchLoadedEvent() /*-{
$wnd.addEventListener("StartManager", function() {
this.@org.openremote.app.client.AppEntryPoint::startManager()();
}.bind(this));
protected void stopManager() {
injector.getAppController().stop();
}
@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"));
}-*/;
}
@@ -26,4 +26,6 @@
void goTo(Place place);
void start();
void stop();
}
@@ -21,21 +21,25 @@
import com.google.gwt.place.shared.Place;
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.inject.Provider;
import elemental2.dom.DomGlobal;
import org.openremote.app.client.Environment;
import org.openremote.app.client.event.ShowFailureEvent;
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.toast.Toast;
import org.openremote.app.client.toast.Toasts;
import org.openremote.model.event.bus.EventListener;
import javax.inject.Inject;
import java.util.logging.Logger;
public class AppControllerImpl implements AppController, AppView.Presenter {
private static final Logger LOG = Logger.getLogger(AppControllerImpl.class.getName());
protected final AppView appView;
protected final Environment environment;
protected final PlaceHistoryHandler placeHistoryHandler;
@@ -103,9 +107,15 @@ public void goTo(Place place) {
@Override
public void start() {
Window.setTitle("OpenRemote Manager");
RootPanel.get().add(appView);
LOG.info("Starting manager");
appView.setPresenter(this);
RootPanel.get().add(appView);
placeHistoryHandler.handleCurrentHistory();
}
@Override
public void stop() {
LOG.info("Stopping manager");
RootPanel.get().remove(appView);
}
}
@@ -61,7 +61,6 @@
@Inject
public AppViewImpl() {
initWidget(ui.createAndBindUi(this));
}
@Override
@@ -17,7 +17,7 @@
}
.logo {
height: 30px;
margin-right: 1em;
}
.brand {
@@ -40,17 +40,6 @@
<g:HTMLPanel styleName="{style.logoItem}">
<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}">
<g:Anchor href="https://openremote.com/">OpenRemote Inc.</g:Anchor>
</div>
@@ -29,8 +29,6 @@
String logout();
String sessionTimedOut();
String map();
String assets();
@@ -67,7 +67,6 @@ roleLabel[write-rules]=Write rulesets (NOTE: effectively super-user access!)
noteRolesAfterCreate=You can assign access roles after creating the user.
showMoreAssets=Show more assets
emptyAsset=No assets found.
sessionTimedOut=Your session timed out. Please close or reload this browser window.
description=Description
unsupportedAttributeType=Not implemented attribute type: {0}
unsupportedMetaItemType=Not implemented meta item type : {0}
@@ -33,11 +33,11 @@
app.set("error", e);
});
});
</script>
</head>
<body class="layout vertical" style="visibility:hidden;">
<body class="layout vertical">
<or-app login="true"></or-app>
<or-toast></or-toast>
@@ -140,8 +140,8 @@
/**
* 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
* attribute, otherwise try to get it from URL path, first segment.
* and login and authenticate with. The realm can be overridden with an
* attribute, otherwise it will be obtained from the URL path, first segment.
*/
realm: {
type: String,
@@ -171,14 +171,14 @@
ready() {
super.ready();
// If we don't have a tenant realm, get it from the URL path
if (!this.realm) {
// If login is required, and we don't have a realm, get it from the URL path
if (this.login && !this.realm) {
if (!window.location.pathname || window.location.pathname.length <= 1) {
this.set("error", "No tenant realm configured and URL doesn't have any path elements");
return;
}
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);
}
}
Oops, something went wrong.

0 comments on commit 74b16f5

Please sign in to comment.