Browse Source

stats on home page are now loaded in the background (makes main site load much faster)

pull/612/head
Justin Richer 11 years ago
parent
commit
8861220632
  1. 48
      openid-connect-server-webapp/src/main/webapp/WEB-INF/tags/landingPageStats.tag
  2. 4
      openid-connect-server/src/main/java/org/mitre/openid/connect/web/ManagerController.java
  3. 3
      openid-connect-server/src/main/java/org/mitre/openid/connect/web/StatsAPI.java

48
openid-connect-server-webapp/src/main/webapp/WEB-INF/tags/landingPageStats.tag

@ -1,8 +1,44 @@
<h2>Current Statistics</h2>
<p>There have been
<span class="label label-info">${statsSummary["userCount"]}</span> user${statsSummary["userCount"] == 1 ? "" : "s"}
of this system who have logged in to
<span class="label label-info">${statsSummary["clientCount"]}</span> total site${statsSummary["clientCount"] == 1 ? "" : "s"},
for a total of
<span class="label label-info">${statsSummary["approvalCount"]}</span> site approval${statsSummary["approvalCount"] == 1 ? "" : "s"}.</p>
<p id="statsloader" class="muted">Loading statistics...</p>
<p id="stats">There have been
<span class="label label-info" id="userCount">?</span> <span id="userCountLabel">users</span>
of this system who have authorized
<span class="label label-info" id="clientCount">?</span> total <span id="clientCountLabel">sites</span>,
with a total of
<span class="label label-info" id="approvalCount">?</span> site <span id="approvalCountLabel">approvals</span>.</p>
<script type="text/javascript">
$(document).ready(function() {
$('#stats').hide();
var base = $('base').attr('href');
$.getJSON(base + 'api/stats/summary', function(data) {
var stats = data;
$('#userCount').html(stats.userCount);
if (stats.userCount == 1) {
$('#userCountLabel').append('s');
}
$('#clientCount').html(stats.clientCount);
if (stats.clientCount == 1) {
$('#clientCount').append('s');
}
$('#approvalCount').html(stats.approvalCount);
if (stats.approvalCount == 1) {
$('#approvalCount').append('s');
}
$('#statsloader').hide();
$('#stats').show();
});
});
</script>

4
openid-connect-server/src/main/java/org/mitre/openid/connect/web/ManagerController.java

@ -38,9 +38,9 @@ public class ManagerController {
@RequestMapping({"", "home", "index"})
public String showHomePage(ModelMap m) {
Map<String, Integer> summary = statsService.getSummaryStats();
//Map<String, Integer> summary = statsService.getSummaryStats();
m.put("statsSummary", summary);
//m.put("statsSummary", summary);
return "home";
}

3
openid-connect-server/src/main/java/org/mitre/openid/connect/web/StatsAPI.java

@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@PreAuthorize("hasRole('ROLE_USER')")
@RequestMapping("/api/stats")
public class StatsAPI {
@ -45,6 +44,7 @@ public class StatsAPI {
}
@PreAuthorize("hasRole('ROLE_USER')")
@RequestMapping(value = "byclientid", produces = "application/json")
public String statsByClient(ModelMap m) {
Map<Long, Integer> e = statsService.getByClientId();
@ -54,6 +54,7 @@ public class StatsAPI {
return "jsonEntityView";
}
@PreAuthorize("hasRole('ROLE_USER')")
@RequestMapping(value = "byclientid/{id}", produces = "application/json")
public String statsByClientId(@PathVariable("id") Long id, ModelMap m) {
Integer e = statsService.getCountForClientId(id);

Loading…
Cancel
Save