Console: Split up advanced config into sections

only if routerconsole.advanced is not set
This commit is contained in:
zzz
2024-01-07 13:52:14 -05:00
parent 23fa8b9295
commit 7250ab558c
2 changed files with 51 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
package net.i2p.router.web.helpers;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -29,23 +30,57 @@ public class ConfigAdvancedHelper extends HelperBase {
_hideKeys = new HashSet<String>(Arrays.asList(keys));
}
private static final Map<String, String> _headers = new HashMap<String, String>(16);
static {
_headers.put("crypto", "Crypto");
_headers.put("desktopgui", "System Tray");
_headers.put("i2cp", "I2CP");
_headers.put("i2np", "I2NP");
_headers.put("i2p", "I2P");
_headers.put("jbigi", "JBigI");
_headers.put("netdb", "NetDB");
_headers.put("prng", "Random");
_headers.put("router", "Router");
_headers.put("routerconsole", "Router Console");
_headers.put("stat", "Statistics");
_headers.put("time", "Time");
}
public String getSettings() {
StringBuilder buf = new StringBuilder(4*1024);
TreeMap<String, String> sorted = new TreeMap<String, String>();
sorted.putAll(_context.router().getConfigMap());
boolean adv = isAdvanced();
String lastType = null;
for (Map.Entry<String, String> e : sorted.entrySet()) {
String key = e.getKey();
if (!adv &&
( _hideKeys.contains(key) ||
key.startsWith("i2cp.auth.") ||
key.startsWith(PROP_AUTH_PFX))) {
continue;
if (!adv) {
if ( _hideKeys.contains(key) ||
key.startsWith("i2cp.auth.") ||
key.startsWith(PROP_AUTH_PFX))
continue;
String type = key;
int dot = key.indexOf('.');
if (dot > 0)
type = type.substring(0, dot);
if (!type.equals(lastType)) {
if (lastType != null)
buf.append("</ul>\n");
lastType = type;
String dtype = _headers.get(type);
if (dtype == null)
dtype = type;
buf.append("<h4>").append(_t(dtype)).append("</h4>\n<ul><li>");
} else {
buf.append("<li>");
}
}
String name = DataHelper.escapeHTML(key);
String val = DataHelper.escapeHTML(e.getValue());
buf.append(name).append('=').append(val).append('\n');
}
if (!adv)
buf.append("</ul>\n");
return buf.toString();
}

View File

@@ -73,7 +73,17 @@
</td></tr>
<% } // isAdvanced %>
<tr><td class="tabletextarea">
<textarea id="advancedsettings" rows="32" cols="60" name="nofilter_config" wrap="off" spellcheck="false" <% if (!advancedhelper.isAdvanced()) { %>readonly="readonly"<% } %>><%=advConfig%></textarea>
<%
if (advancedhelper.isAdvanced()) {
%>
<textarea id="advancedsettings" rows="32" cols="60" name="nofilter_config" wrap="off" spellcheck="false" >
<% } // isAdvanced %>
<%=advConfig%>
<%
if (advancedhelper.isAdvanced()) {
%>
</textarea>
<% } // isAdvanced %>
</td></tr>
<% if (advancedhelper.isAdvanced()) { %>
<tr><td class="optionsave" align="right">