forked from I2P_Developers/i2p.i2p
Console: Fix disabling sidebar refresh
0 disables refresh on /configsidebar disable ajax if refresh disabled change refresh default to 15 sec
This commit is contained in:
@ -24,7 +24,7 @@ public class CSSHelper extends HelperBase {
|
|||||||
public static final String BASE_THEME_PATH = "/themes/console/";
|
public static final String BASE_THEME_PATH = "/themes/console/";
|
||||||
private static final String FORCE = "classic";
|
private static final String FORCE = "classic";
|
||||||
public static final String PROP_REFRESH = "routerconsole.summaryRefresh";
|
public static final String PROP_REFRESH = "routerconsole.summaryRefresh";
|
||||||
public static final String DEFAULT_REFRESH = "60";
|
public static final String DEFAULT_REFRESH = "15";
|
||||||
public static final int MIN_REFRESH = 3;
|
public static final int MIN_REFRESH = 3;
|
||||||
public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh";
|
public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh";
|
||||||
private static final String PROP_XFRAME = "routerconsole.disableXFrame";
|
private static final String PROP_XFRAME = "routerconsole.disableXFrame";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.router.web.helpers;
|
package net.i2p.router.web.helpers;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -28,11 +29,22 @@ public class ConfigSummaryHandler extends FormHandler {
|
|||||||
if (_action.equals(_t("Save")) && "0".equals(group)) {
|
if (_action.equals(_t("Save")) && "0".equals(group)) {
|
||||||
try {
|
try {
|
||||||
int refreshInterval = Integer.parseInt(getJettyString("refreshInterval"));
|
int refreshInterval = Integer.parseInt(getJettyString("refreshInterval"));
|
||||||
if (refreshInterval >= CSSHelper.MIN_REFRESH) {
|
if (refreshInterval < 0)
|
||||||
_context.router().saveConfig(CSSHelper.PROP_REFRESH, Integer.toString(refreshInterval));
|
refreshInterval = 0;
|
||||||
|
else if (refreshInterval > 0 && refreshInterval < CSSHelper.MIN_REFRESH)
|
||||||
|
refreshInterval = CSSHelper.MIN_REFRESH;
|
||||||
|
Map<String, String> toAdd = new HashMap<String, String>(2);
|
||||||
|
if (refreshInterval == 0) {
|
||||||
|
toAdd.put(CSSHelper.PROP_DISABLE_REFRESH, "true");
|
||||||
|
toAdd.put(CSSHelper.PROP_REFRESH, CSSHelper.DEFAULT_REFRESH);
|
||||||
|
_context.router().saveConfig(toAdd, null);
|
||||||
|
addFormNotice(_t("Refresh disabled"));
|
||||||
|
} else {
|
||||||
|
toAdd.put(CSSHelper.PROP_DISABLE_REFRESH, "false");
|
||||||
|
toAdd.put(CSSHelper.PROP_REFRESH, Integer.toString(refreshInterval));
|
||||||
|
_context.router().saveConfig(toAdd, null);
|
||||||
addFormNotice(_t("Refresh interval changed"));
|
addFormNotice(_t("Refresh interval changed"));
|
||||||
} else
|
}
|
||||||
addFormError(_t("Refresh interval must be at least {0} seconds", CSSHelper.MIN_REFRESH));
|
|
||||||
} catch (java.lang.NumberFormatException e) {
|
} catch (java.lang.NumberFormatException e) {
|
||||||
addFormError(_t("Refresh interval must be a number"));
|
addFormError(_t("Refresh interval must be a number"));
|
||||||
return;
|
return;
|
||||||
|
@ -33,7 +33,14 @@ input.default {
|
|||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
||||||
<input type="hidden" name="group" value="0">
|
<input type="hidden" name="group" value="0">
|
||||||
<input type="text" name="refreshInterval" value="<jsp:getProperty name="intl" property="refresh" />" >
|
<%
|
||||||
|
String rval;
|
||||||
|
if (intl.getDisableRefresh())
|
||||||
|
rval = "0";
|
||||||
|
else
|
||||||
|
rval = intl.getRefresh();
|
||||||
|
%>
|
||||||
|
<input type="text" name="refreshInterval" value="<%=rval%>">
|
||||||
<%=intl._t("seconds")%>
|
<%=intl._t("seconds")%>
|
||||||
</td>
|
</td>
|
||||||
<td class="optionsave">
|
<td class="optionsave">
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
<script src="/js/ajax.js?<%=net.i2p.CoreVersion.VERSION%>" type="text/javascript"></script>
|
<%
|
||||||
|
if (!intl.getDisableRefresh()) {
|
||||||
|
%><script src="/js/ajax.js?<%=net.i2p.CoreVersion.VERSION%>" type="text/javascript"></script>
|
||||||
<script nonce="<%=cspNonce%>" type="text/javascript">
|
<script nonce="<%=cspNonce%>" type="text/javascript">
|
||||||
var failMessage = "<hr><b><%=intl._t("Router is down")%><\/b>";
|
var failMessage = "<hr><b><%=intl._t("Router is down")%><\/b>";
|
||||||
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
||||||
function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); }
|
function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); }
|
||||||
initAjax();
|
initAjax();
|
||||||
</script>
|
</script><%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
Reference in New Issue
Block a user