From e86fd161d977602329704537726a0a55dc7e34fe Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 07 Apr 2014 23:48:10 -0400
Subject: [PATCH] Redirect on canceling edit repository to Summary Page
---
src/main/java/com/gitblit/wicket/pages/ActivityPage.java | 56 ++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
index 61838ba..070caf3 100644
--- a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
@@ -27,14 +27,16 @@
import org.apache.wicket.PageParameters;
import org.apache.wicket.behavior.HeaderContributor;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Fragment;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.Activity;
import com.gitblit.models.Metric;
import com.gitblit.models.RepositoryModel;
import com.gitblit.utils.ActivityUtils;
import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.CacheControl;
+import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.PageRegistration;
import com.gitblit.wicket.PageRegistration.DropDownMenuItem;
import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration;
@@ -48,10 +50,12 @@
/**
* Activity Page shows a list of recent commits across all visible Gitblit
* repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
+
+@CacheControl(LastModified.ACTIVITY)
public class ActivityPage extends RootPage {
public ActivityPage(PageParameters params) {
@@ -61,19 +65,42 @@
// parameters
int daysBack = WicketUtils.getDaysBack(params);
if (daysBack < 1) {
- daysBack = 14;
+ daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
}
String objectId = WicketUtils.getObject(params);
// determine repositories to view and retrieve the activity
List<RepositoryModel> models = getRepositories(params);
- List<Activity> recentActivity = ActivityUtils.getRecentActivity(models,
- daysBack, objectId, getTimeZone());
+ List<Activity> recentActivity = ActivityUtils.getRecentActivity(
+ app().settings(),
+ app().repositories(),
+ models,
+ daysBack,
+ objectId,
+ getTimeZone());
+
+ String headerPattern;
+ if (daysBack == 1) {
+ // today
+ if (recentActivity.size() == 0) {
+ headerPattern = getString("gb.todaysActivityNone");
+ } else {
+ headerPattern = getString("gb.todaysActivityStats");
+ }
+ } else {
+ // multiple days
+ if (recentActivity.size() == 0) {
+ headerPattern = getString("gb.recentActivityNone");
+ } else {
+ headerPattern = getString("gb.recentActivityStats");
+ }
+ }
if (recentActivity.size() == 0) {
// no activity, skip graphs and activity panel
- add(new Label("subheader", MessageFormat.format(getString("gb.recentActivityNone"),
+ add(new Label("subheader", MessageFormat.format(headerPattern,
daysBack)));
+ add(new Label("chartsPanel").setVisible(false));
add(new Label("activityPanel"));
} else {
// calculate total commits and total authors
@@ -86,12 +113,17 @@
int totalAuthors = uniqueAuthors.size();
// add the subheader with stat numbers
- add(new Label("subheader", MessageFormat.format(getString("gb.recentActivityStats"),
+ add(new Label("subheader", MessageFormat.format(headerPattern,
daysBack, totalCommits, totalAuthors)));
// create the activity charts
- GoogleCharts charts = createCharts(recentActivity);
- add(new HeaderContributor(charts));
+ if (app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
+ GoogleCharts charts = createCharts(recentActivity);
+ add(new HeaderContributor(charts));
+ add(new Fragment("chartsPanel", "chartsFragment", this));
+ } else {
+ add(new Label("chartsPanel").setVisible(false));
+ }
// add activity panel
add(new ActivityPanel("activityPanel", recentActivity));
@@ -109,7 +141,7 @@
ActivityPage.class);
PageParameters currentParameters = getPageParameters();
- int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
+ int daysBack = app().settings().getInteger(Keys.web.activityDuration, 7);
if (currentParameters != null && !currentParameters.containsKey("db")) {
currentParameters.put("db", daysBack);
}
@@ -130,7 +162,7 @@
/**
* Creates the daily activity line chart, the active repositories pie chart,
* and the active authors pie chart
- *
+ *
* @param recentActivity
* @return
*/
--
Gitblit v1.9.1