James Moger
2013-11-26 4fcac9d2cbdafb51e3ee9ca3b3da64fd86103174
src/main/java/com/gitblit/wicket/pages/DashboardPage.java
@@ -15,7 +15,6 @@
 */
package com.gitblit.wicket.pages;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -76,7 +75,7 @@
      c.add(Calendar.DATE, -1*daysBack);
      Date minimumDate = c.getTime();
      TimeZone timezone = getTimeZone();
      // create daily commit digest feed
      List<DailyLogEntry> digests = new ArrayList<DailyLogEntry>();
      for (RepositoryModel model : repositories) {
@@ -90,7 +89,7 @@
            repository.close();
         }
      }
      Fragment activityFragment = new Fragment("activity", "activityFragment", this);
      add(activityFragment);
      activityFragment.add(new Label("feedTitle", feedTitle));
@@ -119,7 +118,7 @@
         DigestsPanel digestsPanel = new DigestsPanel("digests", digests);
         activityFragment.add(digestsPanel);
      }
      // add the nifty charts
      if (!ArrayUtils.isEmpty(digests)) {
         // aggregate author exclusions
@@ -141,43 +140,6 @@
         activityFragment.add(new Label("feedheader").setVisible(false));
      }
   }
   protected Fragment createNgList(String wicketId, String fragmentId, String ngController, List<RepositoryModel> repositories) {
      String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");
      final DateFormat df = new SimpleDateFormat(format);
      df.setTimeZone(getTimeZone());
      Fragment fragment = new Fragment(wicketId, fragmentId, this);
      List<RepoListItem> list = new ArrayList<RepoListItem>();
      for (RepositoryModel repo : repositories) {
         String name = StringUtils.stripDotGit(repo.name);
         String path = "";
         if (name.indexOf('/') > -1) {
            path = name.substring(0, name.lastIndexOf('/') + 1);
            name = name.substring(name.lastIndexOf('/') + 1);
         }
         RepoListItem item = new RepoListItem();
         item.n = name;
         item.p = path;
         item.r = repo.name;
         item.i = repo.description;
         item.s = GitBlit.self().getStarCount(repo);
         item.t = getTimeUtils().timeAgo(repo.lastChange);
         item.d = df.format(repo.lastChange);
         item.c = StringUtils.getColor(StringUtils.stripDotGit(repo.name));
         item.wc = repo.isBare ? 0 : 1;
         list.add(item);
      }
      // inject an AngularJS controller with static data
      NgController ctrl = new NgController(ngController);
      ctrl.addVariable(wicketId, list);
      add(new HeaderContributor(ctrl));
      return fragment;
   }
   @Override
   protected void addDropDownMenus(List<PageRegistration> pages) {
@@ -185,8 +147,6 @@
      DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters",
            GitBlitWebApp.HOME_PAGE_CLASS);
      // preserve time filter option on repository choices
      menu.menuItems.addAll(getRepositoryFilterItems(params));
      // preserve repository filter option on time choices
      menu.menuItems.addAll(getTimeFilterItems(params));
@@ -203,7 +163,7 @@
   /**
    * Creates the daily activity line chart, the active repositories pie chart,
    * and the active authors pie chart
    *
    *
    * @param recentChanges
    * @param authorExclusions
    * @param daysBack
@@ -223,7 +183,7 @@
            repositoryMetrics.put(repository, new Metric(repository));
         }
         repositoryMetrics.get(repository).count += 1;
         for (RepositoryCommit commit : change.getCommits()) {
            totalCommits++;
            String author = StringUtils.removeNewlines(commit.getAuthorIdent().getName());
@@ -237,7 +197,7 @@
            }
         }
      }
      String headerPattern;
      if (daysBack == 1) {
         // today
@@ -257,43 +217,32 @@
      frag.add(new Label("feedheader", MessageFormat.format(headerPattern,
            daysBack, totalCommits, authorMetrics.size())));
      // build google charts
      GoogleCharts charts = new GoogleCharts();
      if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
         // build google charts
         GoogleCharts charts = new GoogleCharts();
      // active repositories pie chart
      GoogleChart chart = new GooglePieChart("chartRepositories", getString("gb.activeRepositories"),
            getString("gb.repository"), getString("gb.commits"));
      for (Metric metric : repositoryMetrics.values()) {
         chart.addValue(metric.name, metric.count);
         // active repositories pie chart
         GoogleChart chart = new GooglePieChart("chartRepositories", getString("gb.activeRepositories"),
               getString("gb.repository"), getString("gb.commits"));
         for (Metric metric : repositoryMetrics.values()) {
            chart.addValue(metric.name, metric.count);
         }
         chart.setShowLegend(false);
         charts.addChart(chart);
         // active authors pie chart
         chart = new GooglePieChart("chartAuthors", getString("gb.activeAuthors"),
               getString("gb.author"), getString("gb.commits"));
         for (Metric metric : authorMetrics.values()) {
            chart.addValue(metric.name, metric.count);
         }
         chart.setShowLegend(false);
         charts.addChart(chart);
         add(new HeaderContributor(charts));
         frag.add(new Fragment("charts", "chartsFragment", this));
      } else {
         frag.add(new Label("charts").setVisible(false));
      }
      chart.setShowLegend(false);
      charts.addChart(chart);
      // active authors pie chart
      chart = new GooglePieChart("chartAuthors", getString("gb.activeAuthors"),
            getString("gb.author"), getString("gb.commits"));
      for (Metric metric : authorMetrics.values()) {
         chart.addValue(metric.name, metric.count);
      }
      chart.setShowLegend(false);
      charts.addChart(chart);
      add(new HeaderContributor(charts));
      frag.add(new Fragment("charts", "chartsFragment", this));
   }
   protected class RepoListItem implements Serializable {
      private static final long serialVersionUID = 1L;
      String r; // repository
      String n; // name
      String p; // project/path
      String t; // time ago
      String d; // last updated
      String i; // information/description
      long s; // stars
      String c; // html color
      int wc; // working copy, 1 = true
   }
}