diff options
author | James Moger <james.moger@gitblit.com> | 2013-06-24 14:02:54 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-06-24 14:02:54 -0400 |
commit | 5abe3350a38b3cdfc28ac2839860d28b88f2306a (patch) | |
tree | 4ff7c87bcdd3f8cb7635a065bc13fb1b288f8713 /src | |
parent | f59874809d61baf25244756cb280beaeecc33e96 (diff) | |
download | gitblit-5abe3350a38b3cdfc28ac2839860d28b88f2306a.tar.gz gitblit-5abe3350a38b3cdfc28ac2839860d28b88f2306a.zip |
Improve time filter language and handling of daysBack parameter
Diffstat (limited to 'src')
9 files changed, 92 insertions, 27 deletions
diff --git a/src/main/distrib/data/gitblit.properties b/src/main/distrib/data/gitblit.properties index a3270e45..d5573a61 100644 --- a/src/main/distrib/data/gitblit.properties +++ b/src/main/distrib/data/gitblit.properties @@ -825,7 +825,7 @@ web.activityDuration = 7 #
# SPACE-DELIMITED
# SINCE 1.3.0
-web.activityDurationChoices = 7 14 21 28
+web.activityDurationChoices = 1 3 7 14 21 28
# The number of days of commits to cache in memory for the dashboard, activity,
# and project pages. A value of 0 will disable all caching and will parse commits
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties index 34ba138c..bca0dc0d 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties @@ -497,4 +497,7 @@ gb.active = active gb.starred = starred gb.owned = owned gb.starredAndOwned = starred & owned -gb.reviewPatchset = review {0} patchset {1}
\ No newline at end of file +gb.reviewPatchset = review {0} patchset {1} +gb.todaysActivityStats = today / {1} commits by {2} authors +gb.todaysActivityNone = today / none +gb.noActivityToday = there has been no activity today
\ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/PageRegistration.java b/src/main/java/com/gitblit/wicket/PageRegistration.java index 6cbd8626..b0cb4705 100644 --- a/src/main/java/com/gitblit/wicket/PageRegistration.java +++ b/src/main/java/com/gitblit/wicket/PageRegistration.java @@ -152,13 +152,8 @@ public class PageRegistration implements Serializable { parameters = new PageParameters(params);
if (parameters.containsKey(parameter)) {
isSelected = params.getString(parameter).equals(value);
- if (isSelected) {
- // already selected, so remove this enables toggling
- parameters.remove(parameter);
- } else {
- // set the new selection value
- setParameter(parameter, value);
- }
+ // set the new selection value
+ setParameter(parameter, value);
} else {
// not currently selected
isSelected = false;
@@ -167,7 +162,7 @@ public class PageRegistration implements Serializable { }
}
- private void setParameter(String parameter, String value) {
+ protected void setParameter(String parameter, String value) {
if (!StringUtils.isEmpty(parameter)) {
if (StringUtils.isEmpty(value)) {
this.parameters.remove(parameter);
@@ -224,4 +219,25 @@ public class PageRegistration implements Serializable { return displayText;
}
}
+
+ public static class DropDownToggleItem extends DropDownMenuItem {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Toggle Menu Item constructor that preserves aggregate parameters.
+ *
+ * @param displayText
+ * @param parameter
+ * @param value
+ */
+ public DropDownToggleItem(String displayText, String parameter, String value,
+ PageParameters params) {
+ super(displayText, parameter, value, params);
+ if (isSelected) {
+ // already selected, so remove this enables toggling
+ parameters.remove(parameter);
+ }
+ }
+ }
}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java index d2c14fc4..87f2f3ff 100644 --- a/src/main/java/com/gitblit/wicket/WicketUtils.java +++ b/src/main/java/com/gitblit/wicket/WicketUtils.java @@ -431,7 +431,7 @@ public class WicketUtils { }
public static int getDaysBack(PageParameters params) {
- return params.getInt("db", 7);
+ return params.getInt("db", 0);
}
public static String getUsername(PageParameters params) {
diff --git a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java index 61838ba2..694fa603 100644 --- a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java +++ b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java @@ -61,7 +61,7 @@ public class ActivityPage extends RootPage { // parameters
int daysBack = WicketUtils.getDaysBack(params);
if (daysBack < 1) {
- daysBack = 14;
+ daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
}
String objectId = WicketUtils.getObject(params);
@@ -70,9 +70,26 @@ public class ActivityPage extends RootPage { List<Activity> recentActivity = ActivityUtils.getRecentActivity(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("activityPanel"));
} else {
@@ -86,7 +103,7 @@ public class ActivityPage extends RootPage { 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
diff --git a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java index 64d52554..db3092de 100644 --- a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java @@ -96,12 +96,20 @@ public abstract class DashboardPage extends RootPage { // quiet or no starred repositories
if (repositories.size() == 0) {
if (UserModel.ANONYMOUS.equals(user)) {
- activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
+ if (daysBack == 1) {
+ activityFragment.add(new Label("digests", getString("gb.noActivityToday")));
+ } else {
+ activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
+ }
} else {
activityFragment.add(new LinkPanel("digests", null, getString("gb.findSomeRepositories"), RepositoriesPage.class));
}
} else {
- activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
+ if (daysBack == 1) {
+ activityFragment.add(new Label("digests", getString("gb.noActivityToday")));
+ } else {
+ activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
+ }
}
} else {
// show daily commit digest feed
@@ -228,7 +236,23 @@ public abstract class DashboardPage extends RootPage { }
}
- frag.add(new Label("feedheader", MessageFormat.format(getString("gb.recentActivityStats"),
+ String headerPattern;
+ if (daysBack == 1) {
+ // today
+ if (totalCommits == 0) {
+ headerPattern = getString("gb.todaysActivityNone");
+ } else {
+ headerPattern = getString("gb.todaysActivityStats");
+ }
+ } else {
+ // multiple days
+ if (totalCommits == 0) {
+ headerPattern = getString("gb.recentActivityNone");
+ } else {
+ headerPattern = getString("gb.recentActivityStats");
+ }
+ }
+ frag.add(new Label("feedheader", MessageFormat.format(headerPattern,
daysBack, totalCommits, authorMetrics.size())));
// build google charts
diff --git a/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java b/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java index 69dadbd0..d951da31 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java @@ -94,7 +94,7 @@ public class MyDashboardPage extends DashboardPage { // parameters
int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
if (daysBack < 1) {
- daysBack = 7;
+ daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
}
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -1*daysBack);
diff --git a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java index fbd1db02..97a31f98 100644 --- a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java +++ b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java @@ -106,12 +106,12 @@ public class ProjectPage extends DashboardPage { }
int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
if (daysBack < 1) {
- daysBack = 7;
+ daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
}
// reset the daysback parameter so that we have a complete project
// repository list. the recent activity will be built up by the
// reflog utils.
- params.put("db", 0);
+ params.remove("db");
List<RepositoryModel> repositories = getRepositories(params);
Collections.sort(repositories, new Comparator<RepositoryModel>() {
diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java index 8760f5c5..f4ac907b 100644 --- a/src/main/java/com/gitblit/wicket/pages/RootPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java @@ -52,6 +52,7 @@ import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.PageRegistration;
import com.gitblit.wicket.PageRegistration.DropDownMenuItem;
+import com.gitblit.wicket.PageRegistration.DropDownToggleItem;
import com.gitblit.wicket.SessionlessForm;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.GravatarImage;
@@ -256,7 +257,7 @@ public abstract class RootPage extends BasePage { List<String> sets = new ArrayList<String>(setMap.keySet());
Collections.sort(sets);
for (String set : sets) {
- filters.add(new DropDownMenuItem(MessageFormat.format("{0} ({1})", set,
+ filters.add(new DropDownToggleItem(MessageFormat.format("{0} ({1})", set,
setMap.get(set).get()), "set", set, params));
}
// divider
@@ -268,7 +269,7 @@ public abstract class RootPage extends BasePage { List<TeamModel> teams = new ArrayList<TeamModel>(user.teams);
Collections.sort(teams);
for (TeamModel team : teams) {
- filters.add(new DropDownMenuItem(MessageFormat.format("{0} ({1})", team.name,
+ filters.add(new DropDownToggleItem(MessageFormat.format("{0} ({1})", team.name,
team.repositories.size()), "team", team.name, params));
}
// divider
@@ -283,7 +284,7 @@ public abstract class RootPage extends BasePage { for (String expression : expressions) {
if (!StringUtils.isEmpty(expression)) {
addedExpression = true;
- filters.add(new DropDownMenuItem(null, "x", expression, params));
+ filters.add(new DropDownToggleItem(null, "x", expression, params));
}
}
// if we added any custom expressions, add a divider
@@ -300,7 +301,7 @@ public abstract class RootPage extends BasePage { if (daysBack < 1) {
daysBack = 7;
}
- PageParameters clonedParams;;
+ PageParameters clonedParams;
if (params == null) {
clonedParams = new PageParameters();
} else {
@@ -314,14 +315,18 @@ public abstract class RootPage extends BasePage { List<DropDownMenuItem> items = new ArrayList<DropDownMenuItem>();
Set<Integer> choicesSet = new TreeSet<Integer>(GitBlit.getIntegers(Keys.web.activityDurationChoices));
if (choicesSet.isEmpty()) {
- choicesSet.addAll(Arrays.asList(7, 14, 28, 60, 90, 180));
+ choicesSet.addAll(Arrays.asList(1, 3, 7, 14, 21, 28));
}
List<Integer> choices = new ArrayList<Integer>(choicesSet);
Collections.sort(choices);
String lastDaysPattern = getString("gb.lastNDays");
for (Integer db : choices) {
- String txt = MessageFormat.format(lastDaysPattern, db);
- items.add(new DropDownMenuItem(txt, "db", db.toString(), clonedParams));
+ if (db == 1) {
+ items.add(new DropDownMenuItem(getString("gb.time.today"), "db", db.toString(), clonedParams));
+ } else {
+ String txt = MessageFormat.format(lastDaysPattern, db);
+ items.add(new DropDownMenuItem(txt, "db", db.toString(), clonedParams));
+ }
}
items.add(new DropDownMenuItem());
return items;
|