]> WPIA git - gigi.git/commitdiff
upd: replace old main page with dashboard
authorINOPIAE <m.maengel@inopiae.de>
Wed, 22 Feb 2017 07:19:06 +0000 (08:19 +0100)
committerFelix Dörre <felix@dogcraft.de>
Mon, 27 Feb 2017 23:08:55 +0000 (00:08 +0100)
fixes issue #121

Change-Id: Ia02c4f96b52471b8ea40210095eb2e9fece2a6d2

src/club/wpia/gigi/pages/MainPage.java
src/club/wpia/gigi/pages/MainPage.templ

index f55e90d309b113b886a1e0ebd58df32a03c0ad9d..882e3a1de07f52b049e25c684560f45a0de94cba 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.GroupIterator;
+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 GroupIterator(gr.iterator(), true));
+            vars.put("groups", new GroupIterator(gr.iterator(), 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..607f0fe690f005b6eac697208732c037ea08e189 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?>: <? foreach($support-groups) { ?><?=$group_concat?><?=$group?><? } ?></p>
+<p><?=_Assigned user-managed permissions?>: <? foreach($groups) { ?><?=$group_concat?><?=$group?><? } ?> (<?=_!'<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>
+<? } ?>
+