* Console:

- Rewrite TrustedUpdate version comparator, use for netdb version table
        so 0.7.10 will be sorted correctly
      - Reduce netdb.jsp memory usage
      - More tagging fixups
      - configclients.jsp fixup for "Web console"
This commit is contained in:
zzz
2009-10-28 18:26:50 +00:00
parent e94b478317
commit aeb6635e71
11 changed files with 97 additions and 61 deletions

View File

@ -31,9 +31,14 @@ public class ConfigClientsHandler extends FormHandler {
protected void processForm() {
if (_action.equals(_("Save Client Configuration"))) {
saveClientChanges();
} else if (_action.equals(_("Save WebApp Configuration"))) {
return;
}
if (_action.equals(_("Save WebApp Configuration"))) {
saveWebAppChanges();
} else if (_action.startsWith("Start ")) {
return;
}
// value
if (_action.startsWith("Start ")) {
String app = _action.substring(6);
int appnum = -1;
try {
@ -43,10 +48,14 @@ public class ConfigClientsHandler extends FormHandler {
startClient(appnum);
else
startWebApp(app);
} else if (_action.toLowerCase().startsWith("Start<span class=hide> ") &&
return;
}
// label (IE)
String xStart = _("Start");
if (_action.toLowerCase().startsWith(xStart + "<span class=hide> ") &&
_action.toLowerCase().endsWith("</span>")) {
// IE sucks
String app = _action.substring(23, _action.length() - 7);
String app = _action.substring(xStart.length() + 18, _action.length() - 7);
int appnum = -1;
try {
appnum = Integer.parseInt(app);
@ -56,7 +65,7 @@ public class ConfigClientsHandler extends FormHandler {
else
startWebApp(app);
} else {
addFormError(_("Unsupported") + " " + _action + ".");
addFormError(_("Unsupported") + ' ' + _action + '.');
}
}
@ -67,7 +76,7 @@ public class ConfigClientsHandler extends FormHandler {
for (int cur = 0; cur < clients.size(); cur++) {
ClientAppConfig ca = (ClientAppConfig) clients.get(cur);
Object val = _settings.get(cur + ".enabled");
if (! "webConsole".equals(ca.clientName))
if (! ("webConsole".equals(ca.clientName) || "Web console".equals(ca.clientName)))
ca.disabled = val == null;
}
ClientAppConfig.writeClientAppConfig(_context, clients);
@ -82,7 +91,7 @@ public class ConfigClientsHandler extends FormHandler {
}
ClientAppConfig ca = (ClientAppConfig) clients.get(i);
LoadClientAppsJob.runClient(ca.className, ca.clientName, LoadClientAppsJob.parseArgs(ca.args), configClient_log);
addFormNotice(_("Client") + " " + ca.clientName + " " + _("started") + ".");
addFormNotice(_("Client") + ' ' + _(ca.clientName) + ' ' + _("started") + '.');
}
private void saveWebAppChanges() {
@ -117,9 +126,9 @@ public class ConfigClientsHandler extends FormHandler {
path = new File(path, app + ".war");
s.addWebApplication("/"+ app, path.getAbsolutePath()).start();
// no passwords... initialize(wac);
addFormNotice("WebApp <a href=\"/" + app + "/\">" + app + "</a> " + _("started") + ".");
addFormNotice(_("WebApp") + " <a href=\"/" + app + "/\">" + _(app) + "</a> " + _("started") + '.');
} catch (Exception ioe) {
addFormError(_("Failed to start") + " " + app + " " + ioe + ".");
addFormError(_("Failed to start") + ' ' + _(app) + " " + ioe + '.');
}
return;
}

View File

@ -19,7 +19,8 @@ public class ConfigClientsHelper extends HelperBase {
List clients = ClientAppConfig.getClientApps(_context);
for (int cur = 0; cur < clients.size(); cur++) {
ClientAppConfig ca = (ClientAppConfig) clients.get(cur);
renderForm(buf, ""+cur, ca.clientName, false, !ca.disabled, "webConsole".equals(ca.clientName),
renderForm(buf, ""+cur, ca.clientName, false, !ca.disabled,
"webConsole".equals(ca.clientName) || "Web console".equals(ca.clientName),
ca.className + ((ca.args != null) ? " " + ca.args : ""));
}

View File

@ -98,11 +98,11 @@ public class ConfigRestartBean {
return Long.MAX_VALUE/2; // summaryframe.jsp adds a safety factor so we don't want to overflow...
}
public static String _(String s, RouterContext ctx) {
private static String _(String s, RouterContext ctx) {
return Messages.getString(s, ctx);
}
public static String _(String s, Object o, RouterContext ctx) {
private static String _(String s, Object o, RouterContext ctx) {
return Messages.getString(s, o, ctx);
}
}

View File

@ -132,7 +132,9 @@ public class ConfigTunnelsHandler extends FormHandler {
}
if (updated > 0)
addFormNotice("Updated settings for " + updated + " pools.");
// the count isn't really correct anyway, since we don't check for actual changes
//addFormNotice("Updated settings for " + updated + " pools.");
addFormNotice(_("Updated settings for all pools."));
if (saveRequired) {
boolean saved = _context.router().saveConfig();

View File

@ -18,6 +18,7 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import net.i2p.crypto.TrustedUpdate;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
@ -131,14 +132,9 @@ public class NetDbRenderer {
}
public void renderStatusHTML(Writer out, boolean full) throws IOException {
int size = _context.netDb().getKnownRouters() * 512;
if (full)
size *= 4;
StringBuilder buf = new StringBuilder(size);
out.write("<h2>" + _("Network Database Contents") + " (<a href=\"netdb.jsp?l=1\">" + _("View") + " LeaseSets</a>)</h2>\n");
if (!_context.netDb().isInitialized()) {
buf.append("" + _("Not initialized") + "\n");
out.write(buf.toString());
out.write(_("Not initialized"));
out.flush();
return;
}
@ -146,11 +142,12 @@ public class NetDbRenderer {
Hash us = _context.routerHash();
out.write("<a name=\"routers\" ></a><h3>" + _("Routers") + " (<a href=\"netdb.jsp");
if (full)
out.write("#routers\" >" + _("view without") + "");
out.write("#routers\" >" + _("view without"));
else
out.write("?f=1#routers\" >" + _("view with") + "");
out.write(" " + _("stats") + "</a>)</h3>\n");
out.write("?f=1#routers\" >" + _("view with"));
out.write(' ' + _("stats") + "</a>)</h3>\n");
StringBuilder buf = new StringBuilder(8192);
RouterInfo ourInfo = _context.router().getRouterInfo();
renderRouterInfo(buf, ourInfo, true, true);
out.write(buf.toString());
@ -181,7 +178,7 @@ public class NetDbRenderer {
buf.append("<table border=\"0\" cellspacing=\"30\"><tr><td>");
List<String> versionList = new ArrayList(versions.objects());
if (versionList.size() > 0) {
Collections.sort(versionList, Collections.reverseOrder());
Collections.sort(versionList, Collections.reverseOrder(new TrustedUpdate.VersionComparator()));
buf.append("<table>\n");
buf.append("<tr><th>" + _("Version") + "</th><th>" + _("Count") + "</th></tr>\n");
for (String routerVersion : versionList) {

View File

@ -339,7 +339,7 @@ class ProfileOrganizerRenderer {
* Do not double the single quotes in the parameter.
* Use autoboxing to call with ints, longs, floats, etc.
*/
public String _(String s, Object o) {
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}

View File

@ -396,18 +396,21 @@ public class SummaryHelper extends HelperBase {
return buf.toString();
}
/** compare translated nicknames - put "shared clients" first in the sort */
private class AlphaComparator implements Comparator {
public int compare(Object lhs, Object rhs) {
String lname = getName((Destination)lhs);
String rname = getName((Destination)rhs);
if (lname.equals("shared clients"))
String xsc = _("shared clients");
if (lname.equals(xsc))
return -1;
if (rname.equals("shared clients"))
if (rname.equals(xsc))
return 1;
return Collator.getInstance().compare(lname, rname);
}
}
/** translate here so collation works above */
private String getName(Destination d) {
TunnelPoolSettings in = _context.tunnelManager().getInboundSettings(d.calculateHash());
String name = (in != null ? in.getDestinationNickname() : null);
@ -416,6 +419,10 @@ public class SummaryHelper extends HelperBase {
name = (out != null ? out.getDestinationNickname() : null);
if (name == null)
name = d.calculateHash().toBase64().substring(0,6);
else
name = _(name);
} else {
name = _(name);
}
return name;
}

View File

@ -50,13 +50,14 @@ public class TunnelRenderer {
TunnelPool outPool = null;
in = clientInboundPools.get(client);
outPool = clientOutboundPools.get(client);
// TODO the following code is duplicated in SummaryHelper
String name = (in != null ? in.getSettings().getDestinationNickname() : null);
if ( (name == null) && (outPool != null) )
name = outPool.getSettings().getDestinationNickname();
if (name == null)
name = client.toBase64().substring(0,4);
out.write("<h2><a name=\"" + client.toBase64().substring(0,4)
+ "\" ></a>" + _("Client tunnels for") + " " + name);
+ "\" ></a>" + _("Client tunnels for") + ' ' + _(name));
if (_context.clientManager().isLocal(client))
out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">" + _("config") + "</a>):</h2>\n");
else
@ -68,7 +69,7 @@ public class TunnelRenderer {
Collections.sort(participating, new TunnelComparator());
out.write("<h2><a name=\"participating\"></a>" + _("Participating tunnels") + ":</h2><table>\n");
out.write("<tr><th>" + _("Receive on") + "</th><th>" + _("From") + "</th><th>"
+ "" + _("Send on") + "</th><th>" + _("To") + "</th><th>" + _("Expiration") + "</th>"
+ _("Send on") + "</th><th>" + _("To") + "</th><th>" + _("Expiration") + "</th>"
+ "<th>" + _("Usage") + "</th><th>" + _("Rate") + "</th><th>" + _("Role") + "</th></tr>\n");
long processed = 0;
RateStat rs = _context.statManager().getRate("tunnel.participatingMessageCount");

View File

@ -25,5 +25,15 @@ class Dummy {
_("My eepsite web server");
_("Browser launch at startup");
_("BOB application bridge");
// tunnel nicknames, taken from i2ptunnel.config so they will display
// nicely under 'local destinations' in the summary bar
// note that if the wording changes in i2ptunnel.config, we have to
// keep the old string here as well for existing installs
_("shared clients");
_("IRC proxy");
_("eepsite");
// hardcoded in i2psnark
_("I2PSnark");
}
}