Compare commits

...

3 Commits

Author SHA1 Message Date
zzz
23b61a32cc improve map initialization 2024-07-14 09:43:40 -04:00
zzz
05706131b9 switch from lists to a table
strip prefixes in each section
CSS to follow
2024-07-12 12:07:56 -04:00
zzz
7250ab558c Console: Split up advanced config into sections
only if routerconsole.advanced is not set
2024-01-07 13:52:14 -05:00
2 changed files with 61 additions and 7 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,66 @@ 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 {
String[] ss = {
"crypto", "Crypto",
"desktopgui", "System Tray",
"i2cp", "I2CP",
"i2np", "I2NP",
"i2p", "I2P",
"jbigi", "JBigI",
"netdb", "NetDB",
"prng", "Random",
"router", "Router",
"routerconsole", "Router Console",
"stat", "Statistics",
"time", "Time" };
for (int i = 0; i < ss.length; i += 2) {
_headers.put(ss[i], ss[i+1]);
}
}
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;
if (!adv)
buf.append("<table id=\"advcfgtable\">\n");
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)) {
lastType = type;
String dtype = _headers.get(type);
if (dtype == null)
dtype = type;
dtype = DataHelper.escapeHTML(dtype);
buf.append("<tr><th colspan=\"2\">[").append(_t(dtype)).append("]</th></tr>\n");
}
}
String name = DataHelper.escapeHTML(key);
String val = DataHelper.escapeHTML(e.getValue());
buf.append(name).append('=').append(val).append('\n');
if (adv) {
buf.append(name).append('=').append(val).append('\n');
} else {
if (name.length() > lastType.length())
name = name.substring(lastType.length() + 1);
buf.append("<tr><td>").append(name).append("</td><td>").append(val).append("</td></tr>\n");
}
}
if (!adv)
buf.append("</table>\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">