Added option to /configui to force the mobile console to be used

This commit is contained in:
str4d
2013-01-21 05:59:53 +00:00
parent 34aa3ac207
commit d5a870226c
5 changed files with 35 additions and 0 deletions

View File

@ -23,6 +23,7 @@ public class CSSHelper extends HelperBase {
public static final int MIN_REFRESH = 3;
public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh";
private static final String PROP_XFRAME = "routerconsole.disableXFrame";
public static final String PROP_FORCE_MOBILE_CONSOLE = "routerconsole.forceMobileConsole";
private static final String _consoleNonce = Long.toString(RandomSource.getInstance().nextLong());
@ -137,6 +138,9 @@ public class CSSHelper extends HelperBase {
* @since 0.8.5
*/
public boolean allowIFrame(String ua) {
boolean forceMobileConsole = _context.getBooleanProperty(PROP_FORCE_MOBILE_CONSOLE);
if (forceMobileConsole)
return false;
if (ua == null)
return true;
Boolean brv = _UACache.get(ua);

View File

@ -9,6 +9,7 @@ import java.util.Map;
public class ConfigUIHandler extends FormHandler {
private boolean _shouldSave;
private boolean _universalTheming;
private boolean _forceMobileConsole;
private String _config;
@Override
@ -26,6 +27,8 @@ public class ConfigUIHandler extends FormHandler {
public void setUniversalTheming(String baa) { _universalTheming = true; }
public void setForceMobileConsole(String baa) { _forceMobileConsole = true; }
public void setTheme(String val) {
_config = val;
}
@ -37,6 +40,7 @@ public class ConfigUIHandler extends FormHandler {
Map<String, String> changes = new HashMap();
List<String> removes = new ArrayList();
String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
boolean oldForceMobileConsole = _context.getBooleanProperty(CSSHelper.PROP_FORCE_MOBILE_CONSOLE);
if (_config.equals("default")) // obsolete
removes.add(CSSHelper.PROP_THEME_NAME);
else
@ -45,6 +49,10 @@ public class ConfigUIHandler extends FormHandler {
changes.put(CSSHelper.PROP_UNIVERSAL_THEMING, "true");
else
removes.add(CSSHelper.PROP_UNIVERSAL_THEMING);
if (_forceMobileConsole)
changes.put(CSSHelper.PROP_FORCE_MOBILE_CONSOLE, "true");
else
removes.add(CSSHelper.PROP_FORCE_MOBILE_CONSOLE);
boolean ok = _context.router().saveConfig(changes, removes);
if (ok) {
if (!oldTheme.equals(_config))
@ -52,6 +60,11 @@ public class ConfigUIHandler extends FormHandler {
" <a href=\"configui\">" +
_("Refresh the page to view.") +
"</a>");
if (oldForceMobileConsole != _forceMobileConsole)
addFormNotice(_("Mobile console option saved.") +
" <a href=\"configui\">" +
_("Refresh the page to view.") +
"</a>");
} else {
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}

View File

@ -28,6 +28,18 @@ public class ConfigUIHelper extends HelperBase {
return buf.toString();
}
public String getForceMobileConsole() {
StringBuilder buf = new StringBuilder(256);
boolean forceMobileConsole = _context.getBooleanProperty(CSSHelper.PROP_FORCE_MOBILE_CONSOLE);
buf.append("<input type=\"checkbox\" name=\"forceMobileConsole\" ");
if (forceMobileConsole)
buf.append("checked=\"checked\" ");
buf.append("value=\"1\">")
.append(_("Force the mobile console to be used"))
.append("<br>\n");
return buf.toString();
}
static final String PROP_THEME_PFX = "routerconsole.theme.";
/** @return standard and user-installed themes, sorted (untranslated) */