forked from I2P_Developers/i2p.i2p
Added a config page for summary bar
This commit is contained in:
@ -19,6 +19,7 @@ public class CSSHelper extends HelperBase {
|
|||||||
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 = "60";
|
||||||
|
public static final int MIN_REFRESH = 5;
|
||||||
private static final String PROP_XFRAME = "routerconsole.disableXFrame";
|
private static final String PROP_XFRAME = "routerconsole.disableXFrame";
|
||||||
|
|
||||||
public String getTheme(String userAgent) {
|
public String getTheme(String userAgent) {
|
||||||
|
@ -11,12 +11,12 @@ public class ConfigNavHelper extends HelperBase {
|
|||||||
|
|
||||||
/** configX.jsp */
|
/** configX.jsp */
|
||||||
private static final String pages[] =
|
private static final String pages[] =
|
||||||
{"", "net", "ui", "home", "service", "update", "tunnels",
|
{"", "net", "ui", "sidebar", "home", "service", "update", "tunnels",
|
||||||
"clients", "peer", "keyring", "logging", "stats",
|
"clients", "peer", "keyring", "logging", "stats",
|
||||||
"reseed", "advanced" };
|
"reseed", "advanced" };
|
||||||
|
|
||||||
private static final String titles[] =
|
private static final String titles[] =
|
||||||
{_x("Bandwidth"), _x("Network"), _x("UI"), _x("Home Page"),
|
{_x("Bandwidth"), _x("Network"), _x("UI"), _x("Summary Bar"), _x("Home Page"),
|
||||||
_x("Service"), _x("Update"), _x("Tunnels"),
|
_x("Service"), _x("Update"), _x("Tunnels"),
|
||||||
_x("Clients"), _x("Peers"), _x("Keyring"), _x("Logging"), _x("Stats"),
|
_x("Clients"), _x("Peers"), _x("Keyring"), _x("Logging"), _x("Stats"),
|
||||||
_x("Reseeding"), _x("Advanced") };
|
_x("Reseeding"), _x("Advanced") };
|
||||||
|
@ -8,6 +8,7 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
@ -17,6 +18,7 @@ import net.i2p.data.RouterAddress;
|
|||||||
import net.i2p.data.RouterInfo;
|
import net.i2p.data.RouterInfo;
|
||||||
import net.i2p.router.CommSystemFacade;
|
import net.i2p.router.CommSystemFacade;
|
||||||
import net.i2p.router.Router;
|
import net.i2p.router.Router;
|
||||||
|
import net.i2p.router.RouterContext;
|
||||||
import net.i2p.router.RouterVersion;
|
import net.i2p.router.RouterVersion;
|
||||||
import net.i2p.router.TunnelPoolSettings;
|
import net.i2p.router.TunnelPoolSettings;
|
||||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
||||||
@ -748,11 +750,11 @@ public class SummaryHelper extends HelperBase {
|
|||||||
return config.split("" + S);
|
return config.split("" + S);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveSummaryBarSections(String[] sections) {
|
static void saveSummaryBarSections(RouterContext ctx, Map<Integer, String> sections) {
|
||||||
StringBuilder buf = new StringBuilder(512);
|
StringBuilder buf = new StringBuilder(512);
|
||||||
for(int i = 0; i < sections.length; i++)
|
for(String section : sections.values())
|
||||||
buf.append(sections[i]).append(S);
|
buf.append(section).append(S);
|
||||||
_context.router().saveConfig(PROP_SUMMARYBAR, buf.toString());
|
ctx.router().saveConfig(PROP_SUMMARYBAR, buf.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** output the summary bar to _out */
|
/** output the summary bar to _out */
|
||||||
@ -778,4 +780,33 @@ public class SummaryHelper extends HelperBase {
|
|||||||
private String _requestURI;
|
private String _requestURI;
|
||||||
public void setRequestURI(String s) { _requestURI = s; }
|
public void setRequestURI(String s) { _requestURI = s; }
|
||||||
public String getRequestURI() { return _requestURI; }
|
public String getRequestURI() { return _requestURI; }
|
||||||
|
|
||||||
|
public String getConfigTable() {
|
||||||
|
String[] sections = getSummaryBarSections();
|
||||||
|
StringBuilder buf = new StringBuilder(1024);
|
||||||
|
buf.append("<table><tr><th>")
|
||||||
|
.append(_("Remove"))
|
||||||
|
.append("</th><th>")
|
||||||
|
.append(_("Order"))
|
||||||
|
.append("</th><th>")
|
||||||
|
.append(_("Name"))
|
||||||
|
.append("</th></tr>\n");
|
||||||
|
for (int i = 0; i < sections.length; i++) {
|
||||||
|
buf.append("<tr><td align=\"center\"><input type=\"checkbox\" class=\"optbox\" name=\"delete_")
|
||||||
|
.append(i)
|
||||||
|
.append("\"></td><td align=\"center\"><input type=\"text\" name=\"order_")
|
||||||
|
.append(i + "_" + sections[i])
|
||||||
|
.append("\" value=\"")
|
||||||
|
.append(i)
|
||||||
|
.append("\"></td><td align=\"left\">")
|
||||||
|
.append(sections[i])
|
||||||
|
.append("</td></tr>\n");
|
||||||
|
}
|
||||||
|
buf.append("<tr><td align=\"center\"><b>")
|
||||||
|
.append(_("Add")).append(":</b>" +
|
||||||
|
"</td><td align=\"left\"><input type=\"text\" name=\"order\"></td>" +
|
||||||
|
"<td align=\"left\"><input type=\"text\" name=\"name\"></td></tr>");
|
||||||
|
buf.append("</table>\n");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
74
apps/routerconsole/jsp/configsidebar.jsp
Normal file
74
apps/routerconsole/jsp/configsidebar.jsp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<%@page contentType="text/html"%>
|
||||||
|
<%@page pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html><head>
|
||||||
|
<%@include file="css.jsi" %>
|
||||||
|
<%=intl.title("config summary bar")%>
|
||||||
|
<style type='text/css'>
|
||||||
|
input.default {
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="/js/ajax.js" type="text/javascript"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
||||||
|
function requestAjax1() { ajax("/xhr1.jsp", "xhr", <%=intl.getRefresh()%>000); }
|
||||||
|
function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); }
|
||||||
|
</script>
|
||||||
|
</head><body onload="initAjax()">
|
||||||
|
|
||||||
|
<%@include file="summary.jsi" %>
|
||||||
|
<h1><%=intl._("I2P Summary Bar Configuration")%></h1>
|
||||||
|
<div class="main" id="main">
|
||||||
|
<%@include file="confignav.jsi" %>
|
||||||
|
|
||||||
|
<jsp:useBean class="net.i2p.router.web.ConfigSummaryHandler" id="formhandler" scope="request" />
|
||||||
|
<% formhandler.storeMethod(request.getMethod()); %>
|
||||||
|
<jsp:setProperty name="formhandler" property="*" />
|
||||||
|
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
|
||||||
|
<jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
|
||||||
|
<jsp:getProperty name="formhandler" property="allMessages" />
|
||||||
|
<%
|
||||||
|
String pageNonce = formhandler.getNewNonce();
|
||||||
|
%>
|
||||||
|
<jsp:useBean class="net.i2p.router.web.SummaryHelper" id="summaryhelper" scope="request" />
|
||||||
|
<jsp:setProperty name="summaryhelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
|
||||||
|
|
||||||
|
<h3><%=intl._("Refresh Interval")%></h3>
|
||||||
|
<form action="" method="POST">
|
||||||
|
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
||||||
|
<input type="hidden" name="group" value="0">
|
||||||
|
<input type="text" name="refreshInterval" value="<jsp:getProperty name="intl" property="refresh" />" >
|
||||||
|
<%=intl._("seconds")%>
|
||||||
|
<input type="submit" name="action" class="accept" value="<%=intl._("Save")%>" >
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h3><%=intl._("Use preset layout")%></h3>
|
||||||
|
<p><%=intl._("Several preset layouts for the summary bar are available.")%>
|
||||||
|
<%=intl._("Note that choosing one of the presets will cause the current summary bar configuration to be lost.")%></p>
|
||||||
|
<hr><div class="formaction">
|
||||||
|
<form action="" method="POST">
|
||||||
|
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
||||||
|
<input type="hidden" name="group" value="1">
|
||||||
|
<input type="submit" class="reload" name="action" value="<%=intl._("Use full preset")%>" >
|
||||||
|
<input type="submit" class="reload" name="action" value="<%=intl._("Use reduced preset")%>" >
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3><%=intl._("Customise Summary Bar")%></h3>
|
||||||
|
<form action="" method="POST">
|
||||||
|
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
||||||
|
<input type="hidden" name="group" value="2">
|
||||||
|
<jsp:getProperty name="summaryhelper" property="configTable" />
|
||||||
|
<div class="formaction">
|
||||||
|
<input type="submit" name="action" class="default" value="<%=intl._("Add item")%>" >
|
||||||
|
<input type="submit" name="action" class="delete" value="<%=intl._("Delete selected")%>" >
|
||||||
|
<input type="reset" class="cancel" value="<%=intl._("Cancel")%>" >
|
||||||
|
<input type="submit" name="action" class="reload" value="<%=intl._("Save order")%>" >
|
||||||
|
<input type="submit" name="action" class="add" value="<%=intl._("Add item")%>" >
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div></body></html>
|
Reference in New Issue
Block a user