move some summary bar code around

This commit is contained in:
zzz
2012-01-21 15:27:58 +00:00
parent b234ce3f51
commit b003ee8748
2 changed files with 61 additions and 42 deletions

View File

@ -210,54 +210,15 @@ public class SummaryBarRenderer {
.append(_("Network"))
.append(": ")
.append(_helper.getReachability())
.append("</a></h4><hr>\n");
.append("</a></h4><hr>\n")
// display all the time so we display the final failure message, and plugin update messages too
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
} else if(
// isDone() is always false for now, see UpdateHandler
// ((!update.isDone()) &&
_helper.getAction() == null &&
_helper.getUpdateNonce() == null &&
ConfigRestartBean.getRestartTimeRemaining() > 12*60*1000) {
long nonce = _context.random().nextLong();
String prev = System.getProperty("net.i2p.router.web.UpdateHandler.nonce");
if (prev != null)
System.setProperty("net.i2p.router.web.UpdateHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
String uri = _helper.getRequestURI();
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\" 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\" 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>
.append(_("Download Unsigned<br>Update {0}", _helper.getUnsignedUpdateVersion()))
.append("</button><br>\n");
}
buf.append("</form>\n");
}
}
.append(_helper.getUpdateStatus())
.append(_helper.getRestartStatus())
buf.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
.append("<hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append(_("Show all current peer connections"))
.append("\">")

View File

@ -27,6 +27,8 @@ import net.i2p.stat.RateStat;
/**
* Simple helper to query the appropriate router for data necessary to render
* the summary sections on the router console.
*
* For the full summary bar use renderSummaryBar()
*/
public class SummaryHelper extends HelperBase {
@ -604,6 +606,62 @@ public class SummaryHelper extends HelperBase {
return NewsFetcher.getInstance(_context).unsignedUpdateVersion();
}
/**
* The update status and buttons
* @since 0.8.13 moved from SummaryBarRenderer
*/
public String getUpdateStatus() {
StringBuilder buf = new StringBuilder(512);
// display all the time so we display the final failure message, and plugin update messages too
String status = UpdateHandler.getStatus();
if (status.length() > 0) {
buf.append("<h4>").append(status).append("</h4><hr>\n");
}
if (updateAvailable() || unsignedUpdateAvailable()) {
if ("true".equals(System.getProperty(UpdateHandler.PROP_UPDATE_IN_PROGRESS))) {
// nothing
} else if(
// isDone() is always false for now, see UpdateHandler
// ((!update.isDone()) &&
getAction() == null &&
getUpdateNonce() == null &&
ConfigRestartBean.getRestartTimeRemaining() > 12*60*1000) {
long nonce = _context.random().nextLong();
String prev = System.getProperty("net.i2p.router.web.UpdateHandler.nonce");
if (prev != null)
System.setProperty("net.i2p.router.web.UpdateHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
String uri = getRequestURI();
buf.append("<form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
if (updateAvailable()) {
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", getUpdateVersion()))
.append("</button><br>\n");
}
if (unsignedUpdateAvailable()) {
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>
.append(_("Download Unsigned<br>Update {0}", getUnsignedUpdateVersion()))
.append("</button><br>\n");
}
buf.append("</form>\n");
}
}
return buf.toString();
}
/**
* The restart status and buttons
* @since 0.8.13 moved from SummaryBarRenderer
*/
public String getRestartStatus() {
return ConfigRestartBean.renderStatus(getRequestURI(), getAction(), getConsoleNonce());
}
/** output the summary bar to _out */
public void renderSummaryBar() throws IOException {
SummaryBarRenderer renderer = new SummaryBarRenderer(_context, this);