Console: Add constants for wizard page numbers

to make it easier to add/remove/reorder pages later
This commit is contained in:
zzz
2021-09-16 10:50:57 -04:00
parent 3917dc6d2f
commit b1c367777d
3 changed files with 48 additions and 20 deletions

View File

@@ -41,13 +41,19 @@ public class WizardHandler extends FormHandler {
// note that the page is the page we are on now,
// which is the page after the one the settings were on.
String page = getJettyString("page");
int ipage = 1;
if (page != null) {
try {
ipage = Integer.parseInt(page);
} catch (NumberFormatException nfe) {}
}
if (getJettyString("lang") != null) {
// Saved in CSSHelper, assume success
addFormNoticeNoEscape(_t("Console language saved."));
}
if ("3".equals(page)) {
if (ipage == WizardHelper.PAGE_TEST) {
startNDT();
} else if ("4".equals(page)) {
} else if (ipage == WizardHelper.PAGE_RESULTS) {
synchronized (_helper) {
if (_helper.isNDTSuccessful()) {
addFormNotice(_t("Bandwidth test completed successfully"));
@@ -60,7 +66,7 @@ public class WizardHandler extends FormHandler {
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>();
boolean updated = updateRates(changes);
if (updated) {

View File

@@ -21,6 +21,14 @@ public class WizardHelper extends HelperBase {
public static final String PROP_COMPLETE = "routerconsole.welcomeWizardComplete";
// scale bw test results by this for limiter settings
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
private static final float MIN_DOWN_BW = 32.0f;
private static final float MIN_UP_BW = 12.0f;