package net.pterodactylus.wotns.ui.web;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.wotns.freenet.wot.OwnIdentity;
import net.pterodactylus.wotns.web.FreenetRequest;
/**
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
+
+ Set<OwnIdentity> ownIdentities = identityManager.getAllOwnIdentities();
+ List<OwnIdentity> enabledIdentities = new ArrayList<OwnIdentity>();
+ List<OwnIdentity> disabledIdentities = new ArrayList<OwnIdentity>();
+ for (OwnIdentity ownIdentity : ownIdentities) {
+ if (ownIdentity.hasContext("WoTNS")) {
+ enabledIdentities.add(ownIdentity);
+ } else {
+ disabledIdentities.add(ownIdentity);
+ }
+ }
+ templateContext.set("enabledIdentities", enabledIdentities);
+ templateContext.set("disabledIdentities", disabledIdentities);
+
}
}
<h1>WoTNS</h1>
<p>Yay, Index!</p>
-<h1>Manage Names</h1>
-<form method="get" action="manage.html">
- <select name="ownIdentity">
- <option disabled="true">Choose identity…</option>
- <%foreach ownIdentities ownIdentity>
- <option value="<%ownIdentity.id|html>"><%ownIdentity.nickname|html></option>
- <%/foreach>
- </select>
- <button type="submit" name="manage">Manage</button>
-</form>
+
+<%foreach enabledIdentities identity>
+ <%first>
+ <h1>Enabled Identities</h1>
+ <%/first>
+ <form action="enableIdentity.html" method="post">
+ <input type="hidden" name="formPassword" value="<%formPassword|html>"/>
+ <input type="hidden" name="ownIdentity" value="<%identity.id|html>"/>
+ <a href="manage.html?ownIdentity=<%identity.id|html>"><%identity.nickname|html></a>
+ <button type="submit" name="disable">Disable</button>
+ </form>
+<%/foreach>
+
+<%foreach disabledIdentities identity>
+ <%first>
+ <h1>Disabled Identities</h1>
+ <%/first>
+ <form action="enableIdentity.html" method="post">
+ <input type="hidden" name="formPassword" value="<%formPassword|html>"/>
+ <input type="hidden" name="ownIdentity" value="<%identity.id|html>"/>
+ <%identity.nickname|html>
+ <button type="submit" name="enable">Enable</button>
+ </form>
+<%/foreach>