* Console:

- Split up config network page
    - CSS tweaks and cleanups
    - Change some form notices to errors
    - Spiff up the buttons

    new silk icons: See licenses/LICENSE-SilkIcons.txt
    new toopie icon: Shrunk from existing one
This commit is contained in:
zzz
2011-11-30 23:23:41 +00:00
parent b3fcdb8e46
commit 080cc962fb
41 changed files with 464 additions and 335 deletions

View File

@ -68,7 +68,7 @@ public class ConfigAdvancedHandler extends FormHandler {
if (saved)
addFormNotice(_("Configuration saved successfully"));
else
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs"));
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs"));
//if (_forceRestart) {
// addFormNotice("Performing a soft restart");

View File

@ -257,18 +257,18 @@ public class ConfigClientsHelper extends HelperBase {
}
buf.append("></td><td align=\"center\" width=\"15%\">");
if (showStartButton && (!ro) && !edit) {
buf.append("<button type=\"submit\" name=\"action\" value=\"Start ").append(index).append("\" >" + _("Start") + "<span class=hide> ").append(index).append("</span></button>");
buf.append("<button type=\"submit\" class=\"accept\" name=\"action\" value=\"Start ").append(index).append("\" >" + _("Start") + "<span class=hide> ").append(index).append("</span></button>");
}
if (showEditButton && (!edit) && !ro)
buf.append("<button type=\"submit\" name=\"edit\" value=\"Edit ").append(index).append("\" >" + _("Edit") + "<span class=hide> ").append(index).append("</span></button>");
buf.append("<button type=\"submit\" class=\"add\" name=\"edit\" value=\"Edit ").append(index).append("\" >" + _("Edit") + "<span class=hide> ").append(index).append("</span></button>");
if (showStopButton && (!edit))
buf.append("<button type=\"submit\" name=\"action\" value=\"Stop ").append(index).append("\" >" + _("Stop") + "<span class=hide> ").append(index).append("</span></button>");
buf.append("<button type=\"submit\" class=\"stop\" name=\"action\" value=\"Stop ").append(index).append("\" >" + _("Stop") + "<span class=hide> ").append(index).append("</span></button>");
if (showUpdateButton && (!edit) && !ro) {
buf.append("<button type=\"submit\" name=\"action\" value=\"Check ").append(index).append("\" >" + _("Check for updates") + "<span class=hide> ").append(index).append("</span></button>");
buf.append("<button type=\"submit\" name=\"action\" value=\"Update ").append(index).append("\" >" + _("Update") + "<span class=hide> ").append(index).append("</span></button>");
buf.append("<button type=\"submit\" class=\"check\" name=\"action\" value=\"Check ").append(index).append("\" >" + _("Check for updates") + "<span class=hide> ").append(index).append("</span></button>");
buf.append("<button type=\"submit\" class=\"download\" name=\"action\" value=\"Update ").append(index).append("\" >" + _("Update") + "<span class=hide> ").append(index).append("</span></button>");
}
if (showDeleteButton && (!edit) && !ro) {
buf.append("<button type=\"submit\" name=\"action\" value=\"Delete ").append(index)
buf.append("<button type=\"submit\" class=\"delete\" name=\"action\" value=\"Delete ").append(index)
.append("\" onclick=\"if (!confirm('")
.append(_("Are you sure you want to delete {0}?", _(name)))
.append("')) { return false; }\">")

View File

@ -159,7 +159,7 @@ public class ConfigLoggingHandler extends FormHandler {
if (saved)
addFormNotice(_("Log configuration saved"));
else
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs");
addFormError("Error saving the configuration (applied but not saved) - please see the error logs");
}
}
}

View File

@ -10,12 +10,12 @@ public class ConfigNavHelper extends HelperBase {
/** configX.jsp */
private static final String pages[] =
{"", "ui", "service", "update", "tunnels",
{"", "net", "ui", "service", "update", "tunnels",
"clients", "peer", "keyring", "logging", "stats",
"reseed", "advanced" };
private static final String titles[] =
{_x("Network"), _x("UI"), _x("Service"), _x("Update"), _x("Tunnels"),
{_x("Bandwidth"), _x("Network"), _x("UI"), _x("Service"), _x("Update"), _x("Tunnels"),
_x("Clients"), _x("Peers"), _x("Keyring"), _x("Logging"), _x("Stats"),
_x("Reseeding"), _x("Advanced") };

View File

@ -44,7 +44,7 @@ public class ConfigNetHandler extends FormHandler {
private String _reseedFrom;
private boolean _enableLoadTesting;
private String _sharePct;
private static final boolean _ratesOnly = false; // always false - delete me
private boolean _ratesOnly;
private static final String PROP_HIDDEN = Router.PROP_HIDDEN_HIDDEN; // see Router for other choice
@Override
@ -120,6 +120,11 @@ public class ConfigNetHandler extends FormHandler {
_sharePct = (pct != null ? pct.trim() : null);
}
/** @since 0.8.12 */
public void setRatesOnly(String foo) {
_ratesOnly = true;
}
private void recheckReachability() {
_context.commSystem().recheckReachability();
addFormNotice(_("Rechecking router reachability..."));
@ -274,12 +279,10 @@ public class ConfigNetHandler extends FormHandler {
}
boolean saved = _context.router().saveConfig();
if ( (_action != null) && (_("Save changes").equals(_action)) ) {
if (saved)
addFormNotice(_("Configuration saved successfully"));
else
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs"));
}
if (saved)
addFormNotice(_("Configuration saved successfully"));
else
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs"));
if (switchRequired) {
hiddenSwitch();
@ -341,6 +344,7 @@ public class ConfigNetHandler extends FormHandler {
private void updateRates() {
boolean updated = false;
boolean bwUpdated = false;
if (_sharePct != null) {
String old = _context.router().getConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE);
@ -361,7 +365,7 @@ public class ConfigNetHandler extends FormHandler {
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, "" + rate);
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, "" + kb);
} catch (NumberFormatException nfe) {}
updated = true;
bwUpdated = true;
}
if ( (_outboundRate != null) && (_outboundRate.length() > 0) &&
!_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BANDWIDTH))) {
@ -372,6 +376,11 @@ public class ConfigNetHandler extends FormHandler {
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, "" + rate);
_context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, "" + kb);
} catch (NumberFormatException nfe) {}
bwUpdated = true;
}
if (bwUpdated) {
addFormNotice(_("Updated bandwidth limits"));
updated = true;
}
@ -427,9 +436,7 @@ public class ConfigNetHandler extends FormHandler {
***********/
if (updated && !_ratesOnly) {
if (updated)
_context.bandwidthLimiter().reinitialize();
addFormNotice(_("Updated bandwidth limits"));
}
}
}

View File

@ -228,7 +228,7 @@ public class ConfigNetHelper extends HelperBase {
public String getSharePercentageBox() {
int pct = (int) (100 * _context.router().getSharePercentage());
StringBuilder buf = new StringBuilder(256);
buf.append("<select style=\"text-align: right;\" name=\"sharePercentage\">\n");
buf.append("<select style=\"text-align: right !important;\" name=\"sharePercentage\">\n");
boolean found = false;
for (int i = 30; i <= 110; i += 10) {
int val = i;

View File

@ -9,11 +9,13 @@ import net.i2p.router.RouterContext;
*
*/
public class ConfigRestartBean {
/** all these are tagged below so no need to _x them here */
static final String[] SET1 = {"shutdownImmediate", "Shutdown immediately", "cancelShutdown", "Cancel shutdown"};
static final String[] SET2 = {"restartImmediate", "Restart immediately", "cancelShutdown", "Cancel restart"};
static final String[] SET3 = {"restart", "Restart", "shutdown", "Shutdown"};
static final String[] SET4 = {"shutdown", "Shutdown"};
/** all these are tagged below so no need to _x them here.
* order is: form value, form class, display text.
*/
static final String[] SET1 = {"shutdownImmediate", "stop", "Shutdown immediately", "cancelShutdown", "cancel", "Cancel shutdown"};
static final String[] SET2 = {"restartImmediate", "reload", "Restart immediately", "cancelShutdown", "cancel", "Cancel restart"};
static final String[] SET3 = {"restart", "reload", "Restart", "shutdown", "stop", "Shutdown"};
static final String[] SET4 = {"shutdown", "stop", "Shutdown"};
public static String getNonce() {
RouterContext ctx = ContextHelper.getContext(null);
@ -58,21 +60,21 @@ public class ConfigRestartBean {
long timeRemaining = ctx.router().getShutdownTimeRemaining();
StringBuilder buf = new StringBuilder(128);
if ((shuttingDown || restarting) && timeRemaining <= 0) {
buf.append("<center><b>");
buf.append("<h4>");
if (restarting)
buf.append(_("Restart imminent", ctx));
else
buf.append(_("Shutdown imminent", ctx));
buf.append("</b></center>");
buf.append("</h4>");
} else if (shuttingDown) {
buf.append("<center><b>");
buf.append("<h4>");
buf.append(_("Shutdown in {0}", DataHelper.formatDuration2(timeRemaining), ctx));
buf.append("</b></center><br>");
buf.append("</h4><hr>");
buttons(ctx, buf, urlBase, systemNonce, SET1);
} else if (restarting) {
buf.append("<center><b>");
buf.append("<h4>");
buf.append(_("Restart in {0}", DataHelper.formatDuration2(timeRemaining), ctx));
buf.append("</b></center><br>");
buf.append("</h4><hr>");
buttons(ctx, buf, urlBase, systemNonce, SET2);
} else {
if (ctx.hasWrapper())
@ -83,12 +85,16 @@ public class ConfigRestartBean {
return buf.toString();
}
/** @param s value,label,... pairs */
/** @param s value,class,label,... triplets */
private static void buttons(RouterContext ctx, StringBuilder buf, String url, String nonce, String[] s) {
buf.append("<form action=\"").append(url).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"consoleNonce\" value=\"").append(nonce).append("\" >\n");
for (int i = 0; i < s.length; i+= 2)
buf.append("<button type=\"submit\" name=\"action\" value=\"").append(s[i]).append("\" >").append(_(s[i+1], ctx)).append("</button>\n");
for (int i = 0; i < s.length; i+= 3) {
buf.append("<button type=\"submit\" name=\"action\" value=\"")
.append(s[i]).append("\" class=\"")
.append(s[i+1]).append("\" >")
.append(_(s[i+2], ctx)).append("</button>\n");
}
buf.append("</form>\n");
}

View File

@ -139,7 +139,7 @@ public class ConfigTunnelsHandler extends FormHandler {
if (saved)
addFormNotice(_("Exploratory tunnel configuration saved successfully."));
else
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs."));
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}
}
private static final int getInt(Object val) {

View File

@ -33,7 +33,7 @@ public class ConfigUIHandler extends FormHandler {
_("Refresh the page to view.") +
"</a>");
} else {
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs."));
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
}
}
}

View File

@ -195,7 +195,7 @@ public class GraphHelper extends FormHandler {
if (persistent)
_out.write(" checked=\"true\"");
_out.write(">" +
"<hr><div class=\"formaction\"><input type=\"submit\" value=\"" + _("Save settings and redraw graphs") + "\"></div></form>");
"<hr><div class=\"formaction\"><input type=\"submit\" class=\"acceot\" value=\"" + _("Save settings and redraw graphs") + "\"></div></form>");
} catch (IOException ioe) {
ioe.printStackTrace();
}

View File

@ -204,7 +204,7 @@ public class SummaryBarRenderer {
.append(_helper.getUptime())
.append("</td></tr></table>\n" +
"<hr><h4><a href=\"/config#help\" target=\"_top\" title=\"")
"<hr><h4><a href=\"/confignet#help\" target=\"_top\" title=\"")
.append(_("Help with configuring your firewall and router for optimal I2P performance"))
.append("\">")
.append(_("Network"))
@ -214,7 +214,10 @@ public class SummaryBarRenderer {
// display all the time so we display the final failure message, and plugin update messages too
buf.append(UpdateHandler.getStatus());
String status = UpdateHandler.getStatus();
if (status.length() > 0) {
buf.append("<h4>").append(status).append("</h4><hr>\n");
}
if (_helper.updateAvailable() || _helper.unsignedUpdateAvailable()) {
if ("true".equals(System.getProperty(UpdateHandler.PROP_UPDATE_IN_PROGRESS))) {
// nothing
@ -233,13 +236,13 @@ public class SummaryBarRenderer {
buf.append("<form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
if (_helper.updateAvailable()) {
buf.append("<button type=\"submit\" name=\"updateAction\" value=\"signed\" >")
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"signed\" >")
// Note to translators: parameter is a version, e.g. "0.8.4"
.append(_("Download {0} Update", _helper.getUpdateVersion()))
.append("</button><br>\n");
}
if (_helper.unsignedUpdateAvailable()) {
buf.append("<button type=\"submit\" name=\"updateAction\" value=\"Unsigned\" >")
buf.append("<button type=\"submit\" class=\"download\" name=\"updateAction\" value=\"Unsigned\" >")
// Note to translators: parameter is a date and time, e.g. "02-Mar 20:34 UTC"
// <br> is optional, to help the browser make the lines even in the button
// If the translation is shorter than the English, you should probably not include <br>
@ -305,7 +308,7 @@ public class SummaryBarRenderer {
boolean anotherLine = false;
if (_helper.showFirewallWarning()) {
buf.append("<h4><a href=\"/config\" target=\"_top\" title=\"")
buf.append("<h4><a href=\"/confignet\" target=\"_top\" title=\"")
.append(_("Help with firewall configuration"))
.append("\">")
.append(_("Check NAT/firewall"))
@ -328,7 +331,7 @@ public class SummaryBarRenderer {
String uri = _helper.getRequestURI();
buf.append("<p><form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"reseedNonce\" value=\"").append(nonce).append("\" >\n");
buf.append("<button type=\"submit\" value=\"Reseed\" >").append(_("Reseed")).append("</button></form></p>\n");
buf.append("<button type=\"submit\" class=\"reload\" value=\"Reseed\" >").append(_("Reseed")).append("</button></form></p>\n");
}
anotherLine = true;
}