mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-19 04:05:36 +00:00
bug5905: Initial implementation. QR-Code generation works, but there are still some open points, like translated texts and error handling.
This commit is contained in:
+54
-10
@@ -7,6 +7,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import com.google.gwt.place.shared.PlaceTokenizer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.sap.sailing.domain.common.BranchIOConstants;
|
||||
import com.sap.sailing.domain.common.MailInvitationType;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.DeviceMappingConstants;
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
@@ -29,10 +30,14 @@ import com.sap.sse.gwt.client.AbstractBasePlace;
|
||||
*/
|
||||
public class QRCodePlace extends AbstractBasePlace {
|
||||
private static final Logger logger = Logger.getLogger(QRCodePlace.class.getName());
|
||||
public static final String PARAM_REGATTA_NAME = "regatta_name";
|
||||
public static final String PARAM_REGATTA_SECRET = "secret";
|
||||
private static final String PARAM_REGATTA_NAME = "regatta_name";
|
||||
private static final String PARAM_REGATTA_SECRET = "secret";
|
||||
private static final String PARAM_MODE = "mode";
|
||||
public static final String PARAM_SERVER = "server";
|
||||
private static final String PARAM_SERVER = "server";
|
||||
private static final String PARAM_SERVER_URL = "server_url";
|
||||
private static final String PARAM_DEVICE_CONFIG_ID = "device_config_identifier";
|
||||
private static final String PARAM_DEVICE_CONFIG_UUID = "device_config_uuid";
|
||||
private static final String PARAM_TOKEN = "token";
|
||||
|
||||
private UUID eventId;
|
||||
private UUID competitorId;
|
||||
@@ -44,6 +49,10 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
private InvitationMode mode;
|
||||
private String rawCheckInUrl;
|
||||
private String targetServer;
|
||||
private String serverUrl;
|
||||
private String deviceConfigIdentifier;
|
||||
private String deviceConfigUuid;
|
||||
private String token;
|
||||
|
||||
public enum InvitationMode {
|
||||
COMPETITOR(MailInvitationType.SailInsight1),
|
||||
@@ -74,6 +83,12 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
if (publicRegattaName == null || regattaRegistrationLinkSecret == null || targetServer == null) {
|
||||
logger.severe("Missing parameter for regatta, secret or server");
|
||||
}
|
||||
} else if (isRaceManagerAppRequest()) {
|
||||
serverUrl = Window.Location.getParameter(PARAM_SERVER_URL);
|
||||
targetServer = serverUrl;
|
||||
deviceConfigIdentifier = Window.Location.getParameter(PARAM_DEVICE_CONFIG_ID);
|
||||
deviceConfigUuid = Window.Location.getParameter(PARAM_DEVICE_CONFIG_UUID);
|
||||
token = Window.Location.getParameter(PARAM_TOKEN);
|
||||
} else {
|
||||
rawCheckInUrl = Window.Location.getParameter(DeviceMappingConstants.URL_CHECKIN_URL);
|
||||
if (rawCheckInUrl != null) {
|
||||
@@ -176,12 +191,28 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
}
|
||||
|
||||
public String getPublicInviteBranchIOUrl(MailInvitationType mailInvitationType) {
|
||||
return mailInvitationType.getBranchIOopenRegattaURL() + "?" + QRCodePlace.PARAM_REGATTA_NAME + "="
|
||||
+ encodeUrl(publicRegattaName) + "&" + QRCodePlace.PARAM_REGATTA_SECRET + "="
|
||||
+ encodeUrl(regattaRegistrationLinkSecret) + "&" + QRCodePlace.PARAM_SERVER + "="
|
||||
return mailInvitationType.getBranchIOopenRegattaURL() + "?" + PARAM_REGATTA_NAME + "="
|
||||
+ encodeUrl(publicRegattaName) + "&" + PARAM_REGATTA_SECRET + "="
|
||||
+ encodeUrl(regattaRegistrationLinkSecret) + "&" + PARAM_SERVER + "="
|
||||
+ encodeUrl(targetServer);
|
||||
}
|
||||
|
||||
public String getRaceManagerAppUrl() {
|
||||
String url;
|
||||
if (serverUrl != null && deviceConfigIdentifier != null && deviceConfigUuid != null) {
|
||||
url = BranchIOConstants.RACEMANAGER_APP_BRANCH_QUICK_LINK
|
||||
+ "?" + PARAM_SERVER_URL + "=" + encodeUrl(serverUrl)
|
||||
+ "&" + PARAM_DEVICE_CONFIG_ID + "=" + encodeUrl(deviceConfigIdentifier)
|
||||
+ "&" + PARAM_DEVICE_CONFIG_UUID + "=" + encodeUrl(deviceConfigUuid);
|
||||
if (token != null) {
|
||||
url += "&" + PARAM_TOKEN + "=" + encodeUrl(token);
|
||||
}
|
||||
} else {
|
||||
url = null;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
public InvitationMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
@@ -227,7 +258,9 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
return "QRCodePlace [eventId=" + eventId + ", competitorId=" + competitorId + ", boatId=" + boatId + ", markId="
|
||||
+ markId + ", leaderboardName=" + leaderboardName + ", publicRegattaName=" + publicRegattaName
|
||||
+ ", regattaRegistrationLinkSecret=" + regattaRegistrationLinkSecret + ", mode=" + mode
|
||||
+ ", rawCheckInUrl=" + rawCheckInUrl + ", targetServer=" + targetServer + "]";
|
||||
+ ", rawCheckInUrl=" + rawCheckInUrl + ", targetServer=" + targetServer + ", serverUrl=" + serverUrl
|
||||
+ ", deviceConfigIdentifier=" + deviceConfigIdentifier + ", deviceConfigUuid=" + deviceConfigUuid
|
||||
+ ", token=" + token + "]";
|
||||
}
|
||||
|
||||
public static class Tokenizer implements PlaceTokenizer<QRCodePlace> {
|
||||
@@ -257,8 +290,19 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
* @return true if it is a public invite request (former PUBLIC_INVITE or PUBLIC_INVITE3 mode)
|
||||
*/
|
||||
static boolean isPublicInviteRequest() {
|
||||
return Window.Location.getParameter(QRCodePlace.PARAM_REGATTA_NAME) != null
|
||||
&& Window.Location.getParameter(QRCodePlace.PARAM_REGATTA_SECRET) != null
|
||||
&& Window.Location.getParameter(QRCodePlace.PARAM_SERVER) != null;
|
||||
return Window.Location.getParameter(PARAM_REGATTA_NAME) != null
|
||||
&& Window.Location.getParameter(PARAM_REGATTA_SECRET) != null
|
||||
&& Window.Location.getParameter(PARAM_SERVER) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if available URL parameter are indicating a public invite request.
|
||||
*
|
||||
* @return true if it is a public invite request (former PUBLIC_INVITE or PUBLIC_INVITE3 mode)
|
||||
*/
|
||||
static boolean isRaceManagerAppRequest() {
|
||||
return Window.Location.getParameter(PARAM_SERVER_URL) != null
|
||||
&& Window.Location.getParameter(PARAM_DEVICE_CONFIG_ID) != null
|
||||
&& Window.Location.getParameter(PARAM_DEVICE_CONFIG_UUID) != null;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -142,6 +142,10 @@ public class QRCodePresenter {
|
||||
// as the event is most likely displayed on a different server anyway, do not load additional data
|
||||
dataCollector = new DataCollector(view);
|
||||
dataCollector.proceedIfFinished();
|
||||
} else if (QRCodePlace.isRaceManagerAppRequest()) {
|
||||
logger.info("QR Code for race manager app to be shown");
|
||||
dataCollector = new DataCollector(view);
|
||||
dataCollector.proceedIfFinished();
|
||||
} else {
|
||||
logger.severe("QR Code cannot be created. Request type cannot be identified.");
|
||||
}
|
||||
@@ -293,6 +297,9 @@ public class QRCodePresenter {
|
||||
logger.info("About to show QR Code for public regatta invite");
|
||||
view.showPublic(place.getPublicRegattaName(),
|
||||
place.getPublicInviteBranchIOUrl(place.getMode().getMailInvitationType()));
|
||||
} else if (QRCodePlace.isRaceManagerAppRequest()) {
|
||||
logger.info("About to show QR Code for race manager app");
|
||||
view.showRaceManagerApp(place.getRaceManagerAppUrl());
|
||||
} else {
|
||||
logger.severe("Cannot identify request type.");
|
||||
}
|
||||
|
||||
+13
@@ -93,6 +93,19 @@ public class QRCodeView extends Composite {
|
||||
showQrCodeForURL(publicInviteBranchIOUrl);
|
||||
}
|
||||
|
||||
public void showRaceManagerApp(String raceManagerAppBranchIOUrl) {
|
||||
logger.info("Showing QR Code for race manager app");
|
||||
if (raceManagerAppBranchIOUrl != null) {
|
||||
// TODO: define translated text
|
||||
titleDivUi.setInnerText("Scan this QR code on an Android device to use the Race Manager app");
|
||||
showQrCodeForURL(raceManagerAppBranchIOUrl);
|
||||
} else {
|
||||
// TODO: define translated text
|
||||
titleDivUi.setInnerText("Data is incorrect or out of date. Cannot create QR-Code.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showBouyTender(QRCodeEvent event, String leaderboardName, String branchIoUrl) {
|
||||
logger.info("Showing QR Code for buoy tender");
|
||||
titleDivUi.setInnerText(StringMessages.INSTANCE.qrCodeTitleBouy(leaderboardName));
|
||||
|
||||
Reference in New Issue
Block a user