forked from I2P_Developers/i2p.i2p
Console: Add constants for wizard page numbers
to make it easier to add/remove/reorder pages later
This commit is contained in:
@ -41,13 +41,19 @@ public class WizardHandler extends FormHandler {
|
|||||||
// note that the page is the page we are on now,
|
// note that the page is the page we are on now,
|
||||||
// which is the page after the one the settings were on.
|
// which is the page after the one the settings were on.
|
||||||
String page = getJettyString("page");
|
String page = getJettyString("page");
|
||||||
|
int ipage = 1;
|
||||||
|
if (page != null) {
|
||||||
|
try {
|
||||||
|
ipage = Integer.parseInt(page);
|
||||||
|
} catch (NumberFormatException nfe) {}
|
||||||
|
}
|
||||||
if (getJettyString("lang") != null) {
|
if (getJettyString("lang") != null) {
|
||||||
// Saved in CSSHelper, assume success
|
// Saved in CSSHelper, assume success
|
||||||
addFormNoticeNoEscape(_t("Console language saved."));
|
addFormNoticeNoEscape(_t("Console language saved."));
|
||||||
}
|
}
|
||||||
if ("3".equals(page)) {
|
if (ipage == WizardHelper.PAGE_TEST) {
|
||||||
startNDT();
|
startNDT();
|
||||||
} else if ("4".equals(page)) {
|
} else if (ipage == WizardHelper.PAGE_RESULTS) {
|
||||||
synchronized (_helper) {
|
synchronized (_helper) {
|
||||||
if (_helper.isNDTSuccessful()) {
|
if (_helper.isNDTSuccessful()) {
|
||||||
addFormNotice(_t("Bandwidth test completed successfully"));
|
addFormNotice(_t("Bandwidth test completed successfully"));
|
||||||
@ -60,7 +66,7 @@ public class WizardHandler extends FormHandler {
|
|||||||
addFormError(_t("Bandwidth test did not complete"));
|
addFormError(_t("Bandwidth test did not complete"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ("5".equals(page)) {
|
} else if (ipage == WizardHelper.PAGE_BROWSER) {
|
||||||
Map<String, String> changes = new HashMap<String, String>();
|
Map<String, String> changes = new HashMap<String, String>();
|
||||||
boolean updated = updateRates(changes);
|
boolean updated = updateRates(changes);
|
||||||
if (updated) {
|
if (updated) {
|
||||||
|
@ -21,6 +21,14 @@ public class WizardHelper extends HelperBase {
|
|||||||
public static final String PROP_COMPLETE = "routerconsole.welcomeWizardComplete";
|
public static final String PROP_COMPLETE = "routerconsole.welcomeWizardComplete";
|
||||||
// scale bw test results by this for limiter settings
|
// scale bw test results by this for limiter settings
|
||||||
public static final float BW_SCALE = 0.75f;
|
public static final float BW_SCALE = 0.75f;
|
||||||
|
// pages
|
||||||
|
public static final int PAGE_LANG = 1;
|
||||||
|
public static final int PAGE_CHECK = 2;
|
||||||
|
public static final int PAGE_TEST = 3;
|
||||||
|
public static final int PAGE_RESULTS = 4;
|
||||||
|
public static final int PAGE_BROWSER = 5;
|
||||||
|
public static final int PAGE_DONE = 6;
|
||||||
|
|
||||||
// KBps
|
// KBps
|
||||||
private static final float MIN_DOWN_BW = 32.0f;
|
private static final float MIN_DOWN_BW = 32.0f;
|
||||||
private static final float MIN_UP_BW = 12.0f;
|
private static final float MIN_UP_BW = 12.0f;
|
||||||
|
@ -4,7 +4,21 @@
|
|||||||
// The MLabHelper singleton will prevent multiple simultaneous tests, even across sessions.
|
// The MLabHelper singleton will prevent multiple simultaneous tests, even across sessions.
|
||||||
|
|
||||||
// page ID
|
// page ID
|
||||||
final int LAST_PAGE = 6;
|
// 1: Select language
|
||||||
|
// 2: Check internet connection
|
||||||
|
// 3: Bandwidth test in progress
|
||||||
|
// 4: Bandwidth test results
|
||||||
|
// 5: Browser setup
|
||||||
|
// 6: Done
|
||||||
|
final int PAGE_LANG = net.i2p.router.web.helpers.WizardHelper.PAGE_LANG;
|
||||||
|
final int PAGE_CHECK = net.i2p.router.web.helpers.WizardHelper.PAGE_CHECK;
|
||||||
|
final int PAGE_TEST = net.i2p.router.web.helpers.WizardHelper.PAGE_TEST;
|
||||||
|
final int PAGE_RESULTS = net.i2p.router.web.helpers.WizardHelper.PAGE_RESULTS;
|
||||||
|
final int PAGE_BROWSER = net.i2p.router.web.helpers.WizardHelper.PAGE_BROWSER;
|
||||||
|
final int PAGE_DONE = net.i2p.router.web.helpers.WizardHelper.PAGE_DONE;
|
||||||
|
|
||||||
|
final int FIRST_PAGE = PAGE_LANG;
|
||||||
|
final int LAST_PAGE = PAGE_DONE;
|
||||||
String pg = request.getParameter("page");
|
String pg = request.getParameter("page");
|
||||||
int ipg;
|
int ipg;
|
||||||
if (pg == null) {
|
if (pg == null) {
|
||||||
@ -14,18 +28,18 @@
|
|||||||
ipg = Integer.parseInt(pg);
|
ipg = Integer.parseInt(pg);
|
||||||
if (request.getParameter("prev") != null) {
|
if (request.getParameter("prev") != null) {
|
||||||
// previous button handling
|
// previous button handling
|
||||||
if (ipg == 5)
|
if (ipg == PAGE_BROWSER)
|
||||||
ipg = 2;
|
ipg = PAGE_CHECK;
|
||||||
else
|
else
|
||||||
ipg -= 2;
|
ipg -= 2;
|
||||||
}
|
}
|
||||||
if (ipg <= 0 || ipg > LAST_PAGE) {
|
if (ipg < FIRST_PAGE || ipg > LAST_PAGE) {
|
||||||
ipg = 1;
|
ipg = FIRST_PAGE;
|
||||||
} else if (ipg == 3 && request.getParameter("skipbw") != null) {
|
} else if (ipg == PAGE_TEST && request.getParameter("skipbw") != null) {
|
||||||
ipg++; // skip bw test
|
ipg++; // skip bw test
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
ipg = 1;
|
ipg = FIRST_PAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +78,7 @@
|
|||||||
<%=intl.title("New Install Wizard")%>
|
<%=intl.title("New Install Wizard")%>
|
||||||
<%
|
<%
|
||||||
wizhelper.setContextId(i2pcontextId);
|
wizhelper.setContextId(i2pcontextId);
|
||||||
if (ipg == 3) {
|
if (ipg == PAGE_TEST) {
|
||||||
%>
|
%>
|
||||||
<script src="/js/welcomeajax.js?<%=net.i2p.CoreVersion.VERSION%>" type="text/javascript"></script>
|
<script src="/js/welcomeajax.js?<%=net.i2p.CoreVersion.VERSION%>" type="text/javascript"></script>
|
||||||
<script nonce="<%=cspNonce%>" type="text/javascript">
|
<script nonce="<%=cspNonce%>" type="text/javascript">
|
||||||
@ -85,7 +99,7 @@
|
|||||||
/* @license-end */
|
/* @license-end */
|
||||||
</script>
|
</script>
|
||||||
<%
|
<%
|
||||||
} // ipg == 3
|
} // ipg == PAGE_TEST
|
||||||
%>
|
%>
|
||||||
</head><body>
|
</head><body>
|
||||||
<div id="wizard" class="overlay">
|
<div id="wizard" class="overlay">
|
||||||
@ -104,7 +118,7 @@
|
|||||||
<input type="hidden" name="action" value="blah" >
|
<input type="hidden" name="action" value="blah" >
|
||||||
<input type="hidden" name="page" value="<%=(ipg + 1)%>" >
|
<input type="hidden" name="page" value="<%=(ipg + 1)%>" >
|
||||||
<%
|
<%
|
||||||
if (ipg == 1) {
|
if (ipg == PAGE_LANG) {
|
||||||
// language selection
|
// language selection
|
||||||
%>
|
%>
|
||||||
<jsp:useBean class="net.i2p.router.web.helpers.ConfigUIHelper" id="uihelper" scope="request" />
|
<jsp:useBean class="net.i2p.router.web.helpers.ConfigUIHelper" id="uihelper" scope="request" />
|
||||||
@ -140,7 +154,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<%
|
<%
|
||||||
|
|
||||||
} else if (ipg == 2) {
|
} else if (ipg == PAGE_CHECK) {
|
||||||
// Overview of bandwidth test
|
// Overview of bandwidth test
|
||||||
%>
|
%>
|
||||||
<div class="clickableProgression">
|
<div class="clickableProgression">
|
||||||
@ -176,7 +190,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<%
|
<%
|
||||||
|
|
||||||
} else if (ipg == 3) {
|
} else if (ipg == PAGE_TEST) {
|
||||||
// Bandwidth test in progress (w/ AJAX)
|
// Bandwidth test in progress (w/ AJAX)
|
||||||
%>
|
%>
|
||||||
<div class="clickableProgression">
|
<div class="clickableProgression">
|
||||||
@ -209,7 +223,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<%
|
<%
|
||||||
|
|
||||||
} else if (ipg == 4) {
|
} else if (ipg == PAGE_RESULTS) {
|
||||||
// Bandwidth test results
|
// Bandwidth test results
|
||||||
// and/or manual bw entry?
|
// and/or manual bw entry?
|
||||||
%>
|
%>
|
||||||
@ -298,7 +312,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<%
|
<%
|
||||||
|
|
||||||
} else if (ipg == 5) {
|
} else if (ipg == PAGE_BROWSER) {
|
||||||
// Browser setup
|
// Browser setup
|
||||||
%>
|
%>
|
||||||
<div class="clickableProgression">
|
<div class="clickableProgression">
|
||||||
@ -379,7 +393,7 @@
|
|||||||
<div class="wizardbuttons wizard">
|
<div class="wizardbuttons wizard">
|
||||||
<table class="configtable wizard"><tr class="wizard"><td class="optionsave wizard">
|
<table class="configtable wizard"><tr class="wizard"><td class="optionsave wizard">
|
||||||
<%
|
<%
|
||||||
if (ipg != 1) {
|
if (ipg != FIRST_PAGE) {
|
||||||
%>
|
%>
|
||||||
<input type="submit" class="back wizardbutton" name="prev" value="<%=intl._t("Previous")%>" >
|
<input type="submit" class="back wizardbutton" name="prev" value="<%=intl._t("Previous")%>" >
|
||||||
<%
|
<%
|
||||||
@ -388,11 +402,11 @@
|
|||||||
%>
|
%>
|
||||||
<input type="submit" class="cancel wizardbutton" name="skip" value="<%=intl._t("Skip Setup")%>" >
|
<input type="submit" class="cancel wizardbutton" name="skip" value="<%=intl._t("Skip Setup")%>" >
|
||||||
<%
|
<%
|
||||||
if (ipg == 2) {
|
if (ipg == PAGE_CHECK) {
|
||||||
%>
|
%>
|
||||||
<input type="submit" class="cancel wizardbutton" name="skipbw" value="<%=intl._t("Skip Bandwidth Test")%>" >
|
<input type="submit" class="cancel wizardbutton" name="skipbw" value="<%=intl._t("Skip Bandwidth Test")%>" >
|
||||||
<%
|
<%
|
||||||
} else if (ipg == 3) {
|
} else if (ipg == PAGE_TEST) {
|
||||||
%>
|
%>
|
||||||
<input type="submit" class="cancel wizardbutton" name="cancelbw" value="<%=intl._t("Cancel Bandwidth Test")%>" >
|
<input type="submit" class="cancel wizardbutton" name="cancelbw" value="<%=intl._t("Cancel Bandwidth Test")%>" >
|
||||||
<%
|
<%
|
||||||
|
Reference in New Issue
Block a user