]> WPIA git - gigi.git/commitdiff
Merge changes I23396e9a,I6e5f6bef,I29ea805e,Ia02c4f96
authorBenny Baumann <BenBE1987@gmx.net>
Wed, 1 Mar 2017 07:40:24 +0000 (08:40 +0100)
committerGerrit Code Review <gigi-system@dogcraft.de>
Wed, 1 Mar 2017 07:40:24 +0000 (08:40 +0100)
* changes:
  fix: remove blank from translation string
  upd: display "none" when there are no groups to be displayed
  fix: quick development-restart
  upd: replace old main page with dashboard

src/club/wpia/gigi/output/GroupIterator.java [deleted file]
src/club/wpia/gigi/output/GroupList.java [new file with mode: 0644]
src/club/wpia/gigi/pages/MainPage.java
src/club/wpia/gigi/pages/MainPage.templ
src/club/wpia/gigi/pages/account/MyDetailsForm.java
src/club/wpia/gigi/pages/account/MyDetailsRoles.templ
src/club/wpia/gigi/pages/account/certs/RequestCertificate.templ
src/club/wpia/gigi/pages/account/domain/PingConfigForm.templ
src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.java
src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.templ
util-testing/club/wpia/gigi/DevelLauncher.java

diff --git a/src/club/wpia/gigi/output/GroupIterator.java b/src/club/wpia/gigi/output/GroupIterator.java
deleted file mode 100644 (file)
index d195c6c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package club.wpia.gigi.output;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import club.wpia.gigi.dbObjects.Group;
-import club.wpia.gigi.localisation.Language;
-import club.wpia.gigi.output.template.IterableDataset;
-
-public class GroupIterator implements IterableDataset {
-
-    private final boolean asSupport;
-
-    private final Iterator<Group> i;
-
-    public GroupIterator(Iterator<Group> i, boolean asSupport) {
-        this.asSupport = asSupport;
-        this.i = i;
-    }
-
-    private int j = 0;
-
-    @Override
-    public boolean next(Language l, Map<String, Object> vars) {
-        while (i.hasNext()) {
-            Group g = i.next();
-            if (g.isManagedBySupport() == asSupport) {
-                vars.put("group_concat", (j > 0 ? ", " : ""));
-                vars.put("group", g.getName());
-                j++;
-                return true;
-            }
-        }
-
-        return false;
-    }
-}
diff --git a/src/club/wpia/gigi/output/GroupList.java b/src/club/wpia/gigi/output/GroupList.java
new file mode 100644 (file)
index 0000000..c1dd4b7
--- /dev/null
@@ -0,0 +1,40 @@
+package club.wpia.gigi.output;
+
+import java.io.PrintWriter;
+import java.util.Map;
+
+import club.wpia.gigi.dbObjects.Group;
+import club.wpia.gigi.localisation.Language;
+import club.wpia.gigi.output.template.Outputable;
+
+public class GroupList implements Outputable {
+
+    private final Iterable<Group> groups;
+
+    private final boolean supportGroups;
+
+    public GroupList(Iterable<Group> groups, boolean supportGroups) {
+        this.groups = groups;
+        this.supportGroups = supportGroups;
+    }
+
+    @Override
+    public void output(PrintWriter out, Language l, Map<String, Object> vars) {
+        boolean fst = true;
+        for (Group g : groups) {
+            if (g.isManagedBySupport() != supportGroups) {
+                continue;
+            }
+            if ( !fst) {
+                out.write(", ");
+            } else {
+                fst = false;
+            }
+            g.getName().output(out, l, vars);
+        }
+        if (fst) {
+            out.println(l.getTranslation("none"));
+        }
+    }
+
+}
index f55e90d309b113b886a1e0ebd58df32a03c0ad9d..6d279109121f8694e6b5380837c99368182307d9 100644 (file)
@@ -1,11 +1,23 @@
 package club.wpia.gigi.pages;
 
 import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import club.wpia.gigi.dbObjects.Certificate;
+import club.wpia.gigi.dbObjects.Domain;
+import club.wpia.gigi.dbObjects.EmailAddress;
+import club.wpia.gigi.dbObjects.Group;
+import club.wpia.gigi.dbObjects.Organisation;
+import club.wpia.gigi.dbObjects.User;
+import club.wpia.gigi.localisation.Language;
+import club.wpia.gigi.output.GroupList;
+import club.wpia.gigi.output.template.IterableDataset;
 import club.wpia.gigi.output.template.Template;
 
 public class MainPage extends Page {
@@ -20,7 +32,77 @@ public class MainPage extends Page {
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
         Map<String, Object> vars = getDefaultVars(req);
         if (LoginPage.getUser(req) != null) {
+            User u = LoginPage.getUser(req);
+            vars.put("username", u.getPreferredName());
+            final Set<Group> gr = u.getGroups();
+            vars.put("support-groups", new GroupList(gr, true));
+            vars.put("groups", new GroupList(gr, false));
+            vars.put("ra-agent", u.canVerify());
+            vars.put("vp", u.getVerificationPoints());
+            vars.put("xp", u.getExperiencePoints());
+
+            Certificate[] c = u.getCertificates(false);
+            vars.put("c-no", c.length);
+
+            final EmailAddress[] emails = u.getEmails();
+            IterableDataset ds = new IterableDataset() {
+
+                private int point = 0;
+
+                @Override
+                public boolean next(Language l, Map<String, Object> vars) {
+                    if (point >= emails.length) {
+                        return false;
+                    }
+                    EmailAddress emailAddress = emails[point];
+                    vars.put("verification", l.getTranslation(emailAddress.isVerified() ? "Verified" : "Unverified"));
+                    vars.put("last_verification", emailAddress.getLastPing(true));
+                    vars.put("address", emailAddress.getAddress());
+                    point++;
+                    return true;
+                }
+            };
+            vars.put("emails", ds);
+
+            final Domain[] doms = u.getDomains();
+            IterableDataset dts = new IterableDataset() {
+
+                private int point = 0;
+
+                @Override
+                public boolean next(Language l, Map<String, Object> vars) {
+                    if (point >= doms.length) {
+                        return false;
+                    }
+                    Domain domain = doms[point];
+                    vars.put("domain", domain.getSuffix());
+                    vars.put("status", l.getTranslation(domain.isVerified() ? "Verified" : "Unverified"));
+                    point++;
+                    return true;
+                }
+            };
+            vars.put("domains", dts);
+            vars.put("nodomains", doms.length == 0);
+
+            final List<Organisation> o = u.getOrganisations();
+            vars.put("orgas", new IterableDataset() {
+
+                Iterator<Organisation> it = o.iterator();
+
+                @Override
+                public boolean next(Language l, Map<String, Object> vars) {
+                    if ( !it.hasNext()) {
+                        return false;
+                    }
+                    Organisation o = it.next();
+                    vars.put("orgName", o.getName());
+                    vars.put("orgID", o.getId());
+                    return true;
+                }
+            });
+            vars.put("hasorgs", !o.isEmpty());
             getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
+
         } else {
             notLog.output(resp.getWriter(), getLanguage(req), vars);
         }
index 8352e0ccd54f04bceed02aa7bfc0d14b049a486f..04b8085126ac1a69b895bea0eb20f954594cda1b 100644 (file)
@@ -1,13 +1,79 @@
-<p><?=_Welcome to your account section of the website. Below is a description of the different sections and what they're for.?></p>
-<H4><?=_ET?></H4>
-<p><?=_If you would like to view news items or change languages you can click the logout or go home links. Go home doesn't log you out of the system, just returns you to the front of the website. Logout logs you out of the system.?></p>
-<H4><?=_My Details?></H4>
-<p><?=_In this section you will be able to edit your personal information (if you haven't been verified), update your pass phrase, and lost pass phrase questions. You will also be able to set your location for the Web of Trust, it also effects the email announcement settings which among other things can be set to notify you if you're within 200km of a planned verification event. You'll also be able to set additional contact information when you become fully trusted, so others can contact you to meet up outside official events.?></p>
-<h4><?=_Email Accounts and Client Certificates?></h4>
-<p><?=_The email account section is for adding/updating/removing email accounts which can be used to issue client certificates against. The client certificate section steps you through generating a certificate signing request for one or more emails you've registered in the email account section.?></p>
-<h4><?=_Domains and Server Certificates.?></h4>
-<p><?=_Before you can start issuing certificates for your website, irc server, smtp server, pop3, imap etc you will need to add domains to your account under the domain menu. You can also remove domains from here as well. Once you've added a domain you are free then to go into the Server Certificate section and start pasting CSR into the website and have the website return you a valid certificate for up to 2 years if you have 50 trust points, or 6 months for no trust points.?></p>
-<h4><?=_Org Client and Server Certificates?></h4>
-<p><?=_Once you have verified your company you will see these menu options. They allow you to issue as many certificates as you like without proving individual email accounts as you like, further more you are able to get your company details on the certificate.?></p>
-<h4><?=_ET Web of Trust?></h4>
-<p><?=_The Web of Trust system ET uses is similar to that many involved with GPG/PGP use, they hold face to face meetings to verify each others photo identities match their GPG/PGP key information. ET differs however in that we have modified things to work within the PKI framework, for you to gain trust in the system you must first locate someone already trusted. The trust person depending how many people they've trusted or meet before will determine how many points they can issue to you. Once you've met up you can show your ID and you will need to fill out a verification form which the person verifying your details must retain for verification reasons.?></p>
+<h3><?=_Welcome back, ${username}!?></h3>
+<h4><?=_Subscriber information?></h4>
+<div class="well">
+<? if($ra-agent) { ?><p><?=_You are an RA Agent.?></p><? } ?>
+<p><?=_Assigned support permissions?>: <?=$support-groups?></p>
+<p><?=_Assigned user-managed permissions?>: <?=$groups?> (<?=_!'<a href="/account/details">'more!'</a>'?>)</p>
+<p><?=_${vp} Verification Points and ${xp} Experience Points.?> (<?=_!'<a href="/wot/points">'more!'</a>'?>)</p>
+</div>
+
+<h4><?=_Certificate Information?></h4>
+<div class="well">
+<p><?=_${c-no} certificate(s) are issued for your account.?> (<?=_!'<a href="/account/certs">'more!'</a>'?>)</p>
+</div>
+
+<h4><?=_Subscribed domains and email addresses?></h4>
+<div class="panel panel-default">
+<div class="panel-heading">
+<?=_Your account lists the following email addresses?> (<?=_!'<a href="/account/mails">'more!'</a>'?>):
+</div>
+<table class="table">
+  <thead>
+  <tr>
+    <th><?=_Address?></th>
+    <th><?=_Status?></th>
+    <th><?=_Last successful verification?></th>
+  </tr>
+  </thead>
+  <tbody>
+  <? foreach($emails) {?>
+       <tr>
+               <td><?=$address?></td>
+               <td><?=$verification?></td>
+               <td><? if($last_verification) { ?><?=$last_verification?><? } else { ?><?=_N/A?><? } ?></td>
+       </tr>
+ <? } ?>
+  </tbody>
+</table>
+</div>
+
+<div class="panel panel-default">
+<div class="panel-heading">
+<?=_Your account lists the following domains?> (<?=_!'<a href="/account/domains">'more!'</a>'?>):
+</div>
+<? if($nodomains) { ?>
+<div class="panel-body">
+<?=_Currently no domains are registered for your account.?>
+</div>
+<? } else { ?>
+<table class="table">
+  <thead>
+  <tr>
+    <th><?=_Domain?></th>
+    <th><?=_Status?></th>
+  </tr>
+  </thead>
+  <tbody>
+  <? foreach($domains) { ?>
+  <tr>
+    <td><?=$domain?></td>
+    <td><?=$status?></td>
+  </tr>
+  <? } ?>
+</tbody></table>
+<? } ?>
+</div>
+
+<? if($hasorgs) { ?>
+<h4><?=_Organisations?></h4>
+<div class="well">
+ <p><?=_You are listed as administrator for these organisations?>:</p>
+ <ul>
+ <? foreach($orgas) { ?>
+  <li><?=$orgName?></li>
+ <? } ?>
+ </ul>
+ <p><?=_!'<a href="/account/details">'change to organisation administrator context!'</a>'?></p>
+</div>
+<? } ?>
+
index e4834a150016d4a309af154efd28ee6a08a575ac..13d038808fb5c050b32539cf076ce15cc63750ba 100644 (file)
@@ -14,7 +14,7 @@ import club.wpia.gigi.localisation.Language;
 import club.wpia.gigi.output.ArrayIterable;
 import club.wpia.gigi.output.CountrySelector;
 import club.wpia.gigi.output.DateSelector;
-import club.wpia.gigi.output.GroupIterator;
+import club.wpia.gigi.output.GroupList;
 import club.wpia.gigi.output.GroupSelector;
 import club.wpia.gigi.output.NameInput;
 import club.wpia.gigi.output.template.Form;
@@ -157,8 +157,8 @@ public class MyDetailsForm extends Form {
         }
 
         final Set<Group> gr = target.getGroups();
-        vars.put("support-groups", new GroupIterator(gr.iterator(), true));
-        vars.put("groups", new GroupIterator(gr.iterator(), false));
+        vars.put("support-groups", new GroupList(gr, true));
+        vars.put("groups", new GroupList(gr, false));
         vars.put("groupSelector", selectedGroup);
         roles.output(out, l, vars);
     }
index d4d7c2f9ae51e30ec574985d488d43144ed568db..b25d11d7e8b6c969c63ca9545007ad0138329b24 100644 (file)
@@ -2,9 +2,9 @@
   <div class="panel-heading"><?=_Permissions / Group Assignments?></div>
   <div class="panel-body">
   <h4><?=_Support Managed Permissions?>:</h4>
-  <? foreach($support-groups) { ?><?=$group_concat?><?=$group?><? } ?>
+  <?=$support-groups?>
   <h4><?=_User Managed Permissions?>:</h4>
-  <? foreach($groups) { ?><?=$group_concat?><?=$group?><? } ?>
+  <?=$groups?>
   <h4><?=_Set User Managed Permissions?>:</h4>
   <?=$groupSelector?> <button class="btn btn-info" name="action" value="addGroup"><?=_Add Group?></button> <button class="btn btn-info" name="action" value="removeGroup"><?=_Remove Group?></button>
   </div>
index 8c3b05f76e1224757fd176811e34fc49be3adaac..7995d6a9968d63a9a9d743b4484a8c0c216bc49c 100644 (file)
@@ -1,5 +1,5 @@
-<p><?=_${appName} offers two ways to create a certificate.?> 
-<?=_One is to paste a certificate signing request (CSR) created from an existing or newly created private key.?> <?=_ If you do not know what a CSR is or how to create one take a look at the !(/wiki/CSR)FAQ!'</a>'.?> 
+<p><?=_${appName} offers two ways to create a certificate.?>
+<?=_One is to paste a certificate signing request (CSR) created from an existing or newly created private key.?> <?=_If you do not know what a CSR is or how to create one take a look at the !(/wiki/CSR)FAQ!'</a>'.?> 
 <?=_As an alternative you can generate the private key inside your browser and export it once the certificate has been issued.?></p>
 <form method="post">
 <table class="table">
index 8280c8d2ab33b6d16fa204bd47d84b8da8ba2607..4a1055379d060dc5f3bd5551200ce00fa61f9548 100644 (file)
@@ -20,7 +20,7 @@
 <div class="panel panel-info panel-activatable">
   <div class="panel-heading"><input type="checkbox" name="HTTPType" value="y"<?=$!http?>> <?=_Verify by reading HTTP-content?></div>
   <div class="panel-body">
-    <?=_Please make the following content available under ?><pre class='string'>http://<span class='exampleDomain'>example.org</span>/<?=$httpPrefix?><?=$tokenName?>.txt</pre><br/>
+    <?=_Please make the following content available at?> <pre class='string'>http://<span class='exampleDomain'>example.org</span>/<?=$httpPrefix?><?=$tokenName?>.txt</pre><br/>
     <pre><?=$tokenValue?></pre>
   </div>
 </div>
index a7b1be77b4fbe9332cc834eab9b12ab8ba449d56..fe2ecb2ba80928f4efc3aedadd21804b6ca7c422 100644 (file)
@@ -14,7 +14,7 @@ import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.localisation.Language;
 import club.wpia.gigi.output.ArrayIterable;
 import club.wpia.gigi.output.DateSelector;
-import club.wpia.gigi.output.GroupIterator;
+import club.wpia.gigi.output.GroupList;
 import club.wpia.gigi.output.GroupSelector;
 import club.wpia.gigi.output.template.Form;
 import club.wpia.gigi.output.template.Template;
@@ -93,8 +93,8 @@ public class SupportUserDetailsForm extends Form {
         vars.put("verificationPoints", user.getVerificationPoints());
         vars.put("exppoints", user.getExperiencePoints());
         final Set<Group> gr = user.getGroups();
-        vars.put("support-groups", new GroupIterator(gr.iterator(), true));
-        vars.put("groups", new GroupIterator(gr.iterator(), false));
+        vars.put("support-groups", new GroupList(gr, true));
+        vars.put("groups", new GroupList(gr, false));
         vars.put("groupSelector", value);
         t.output(out, l, vars);
     }
index 1a75afd7d3c9ddffb86b18da843d2d4a1c319201..2206f3e50ae13b53889bce4df740d15945777009 100644 (file)
 
         <tr>
             <td><?=_Support Managed Groups?>:</td>
-            <td><p><? foreach($support-groups) { ?><?=$group_concat?><?=$group?><? } ?></p>
+            <td><p><?=$support-groups?></p>
             <p><?=$groupSelector?><input class="btn btn-info" type='submit' value='<?=_Add Group?>' name='addGroup'> <input class="btn btn-info" type='submit' value='<?=_Remove Group?>' name='removeGroup'></p>
             </td>
         </tr>
 
         <tr>
             <td><?=_User Managed Groups?>:</td>
-            <td><p><? foreach($groups) { ?><?=$group_concat?><?=$group?><? } ?></p>
+            <td><p><?=$groups?></p>
             </td>
         </tr>
 
index 306c6474304b30c8a7cb2681117a98f58e7cf6e8..9789637a6b7c3fa8e6548fb119cf3e8c58907c3b 100644 (file)
@@ -103,7 +103,7 @@ public class DevelLauncher {
     private static void killPreviousInstance(Properties mainProps) {
         try {
             String targetPort = mainProps.getProperty("http.port");
-            String targetHost = mainProps.getProperty("name.www");
+            String targetHost = mainProps.getProperty("name.www", "www." + mainProps.getProperty("name.suffix"));
             URL u = new URL("http://" + targetHost + ":" + targetPort + "/kill");
             u.openStream();
         } catch (IOException e) {