Save graph settings when changed

This commit is contained in:
zzz
2010-01-18 17:39:12 +00:00
parent 35a0dafb83
commit 2db5914ba0
4 changed files with 55 additions and 8 deletions

View File

@ -15,13 +15,29 @@ public class GraphHelper extends HelperBase {
private int _width; private int _width;
private int _height; private int _height;
private int _refreshDelaySeconds; private int _refreshDelaySeconds;
private static final String PROP_X = "routerconsole.graphX";
private static final String PROP_Y = "routerconsole.graphY";
private static final String PROP_REFRESH = "routerconsole.graphRefresh";
private static final String PROP_PERIODS = "routerconsole.graphPeriods";
private static final String PROP_EVENTS = "routerconsole.graphEvents";
private static final int DEFAULT_X = 250;
private static final int DEFAULT_Y = 100;
private static final int DEFAULT_REFRESH = 60;
private static final int DEFAULT_PERIODS = 60;
public GraphHelper() { public GraphHelper() {
_periodCount = 60; // SummaryListener.PERIODS; }
_showEvents = false;
_width = 250; /** set the defaults after we have a context */
_height = 100; @Override
_refreshDelaySeconds = 60; public void setContextId(String contextId) {
super.setContextId(contextId);
_width = _context.getProperty(PROP_X, DEFAULT_X);
_height = _context.getProperty(PROP_Y, DEFAULT_Y);
_periodCount = _context.getProperty(PROP_PERIODS, DEFAULT_PERIODS);
_refreshDelaySeconds = _context.getProperty(PROP_REFRESH, DEFAULT_REFRESH);
_showEvents = Boolean.valueOf(_context.getProperty(PROP_EVENTS)).booleanValue();
} }
public void setPeriodCount(String str) { public void setPeriodCount(String str) {
@ -102,7 +118,9 @@ public class GraphHelper extends HelperBase {
} }
return ""; return "";
} }
public String getForm() { public String getForm() {
saveSettings();
try { try {
_out.write("<br><h3>" + _("Configure Graph Display") + " [<a href=\"configstats.jsp\">" + _("Select Stats") + "</a>]</h3>"); _out.write("<br><h3>" + _("Configure Graph Display") + " [<a href=\"configstats.jsp\">" + _("Select Stats") + "</a>]</h3>");
_out.write("<form action=\"graphs.jsp\" method=\"GET\">"); _out.write("<form action=\"graphs.jsp\" method=\"GET\">");
@ -120,6 +138,25 @@ public class GraphHelper extends HelperBase {
return ""; return "";
} }
/**
* Silently save settings if changed, no indication of success or failure
* @since 0.7.10
*/
private void saveSettings() {
if (_width != _context.getProperty(PROP_X, DEFAULT_X) ||
_height != _context.getProperty(PROP_Y, DEFAULT_Y) ||
_periodCount != _context.getProperty(PROP_PERIODS, DEFAULT_PERIODS) ||
_refreshDelaySeconds != _context.getProperty(PROP_REFRESH, DEFAULT_REFRESH) ||
_showEvents != Boolean.valueOf(_context.getProperty(PROP_EVENTS)).booleanValue()) {
_context.router().setConfigSetting(PROP_X, "" + _width);
_context.router().setConfigSetting(PROP_Y, "" + _height);
_context.router().setConfigSetting(PROP_PERIODS, "" + _periodCount);
_context.router().setConfigSetting(PROP_REFRESH, "" + _refreshDelaySeconds);
_context.router().setConfigSetting(PROP_EVENTS, "" + _showEvents);
_context.router().saveConfig();
}
}
/** inner class, don't bother reindenting */ /** inner class, don't bother reindenting */
private static class AlphaComparator implements Comparator { private static class AlphaComparator implements Comparator {
public int compare(Object lhs, Object rhs) { public int compare(Object lhs, Object rhs) {

View File

@ -13,9 +13,9 @@
<div class="graphspanel"> <div class="graphspanel">
<div class="widepanel"> <div class="widepanel">
<jsp:useBean class="net.i2p.router.web.GraphHelper" id="graphHelper" scope="request" /> <jsp:useBean class="net.i2p.router.web.GraphHelper" id="graphHelper" scope="request" />
<jsp:setProperty name="graphHelper" property="*" />
<jsp:setProperty name="graphHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> <jsp:setProperty name="graphHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<jsp:setProperty name="graphHelper" property="*" />
<jsp:setProperty name="graphHelper" property="writer" value="<%=out%>" /> <jsp:setProperty name="graphHelper" property="writer" value="<%=out%>" />
<jsp:getProperty name="graphHelper" property="images" /> <jsp:getProperty name="graphHelper" property="images" />
<jsp:getProperty name="graphHelper" property="form" /> <jsp:getProperty name="graphHelper" property="form" />
</div></div></div></body></html> </div></div></div></body></html>

View File

@ -1,3 +1,13 @@
2010-01-18 zzz
* configclients.jsp: Fix add-new-client feature
* Console: Add a tunnel share ratio estimate
* graphs.jsp:
- Remove jrobin sig
- Set lower limit to 0
- Save settings when changed
* Reseed: Support SSL and proxies
* Translate: Catch empty string
2010-01-17 zzz 2010-01-17 zzz
* Clock: Change a CRIT to an ERROR, lower threshold for changing from 10s to 5s * Clock: Change a CRIT to an ERROR, lower threshold for changing from 10s to 5s
* configclients.jsp: Support add, delete, edit * configclients.jsp: Support add, delete, edit

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 3; public final static long BUILD = 4;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";