]> source.dussan.org Git - gitblit.git/commitdiff
Improve time filter language and handling of daysBack parameter
authorJames Moger <james.moger@gitblit.com>
Mon, 24 Jun 2013 18:02:54 +0000 (14:02 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 24 Jun 2013 18:02:54 +0000 (14:02 -0400)
releases.moxie
src/main/distrib/data/gitblit.properties
src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
src/main/java/com/gitblit/wicket/PageRegistration.java
src/main/java/com/gitblit/wicket/WicketUtils.java
src/main/java/com/gitblit/wicket/pages/ActivityPage.java
src/main/java/com/gitblit/wicket/pages/DashboardPage.java
src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
src/main/java/com/gitblit/wicket/pages/ProjectPage.java
src/main/java/com/gitblit/wicket/pages/RootPage.java

index 02f1c7bc56c9bf08e5c660686715fe9cf33d727f..ba6951e2fb9c1d989a6d6f82f853230f76e8e303 100644 (file)
@@ -127,7 +127,8 @@ r17: {
        - { name: 'realm.salesforce.orgId', defaultValue: 0 }\r
        - { name: 'realm.windows.defaultDomain', defaultValue: ' ' }\r
        - { name: 'realm.windows.backingUserService', defaultValue: 'users.conf' }\r
-       - { name: 'web.activityDurationChoices', defaultValue: '7 14 21 28' }\r
+       - { name: 'web.activityDuration', defaultValue: 7 }\r
+       - { name: 'web.activityDurationChoices', defaultValue: '1 3 7 14 21 28' }\r
        - { name: 'web.activityCacheDays', defaultValue: 14 }\r
        - { name: 'web.allowAppCloneLinks', defaultValue: 'true' }\r
        - { name: 'web.forceDefaultLocale', defaultValue: ' ' }\r
index a3270e459f5fffdb31b491a2f1771bec1f757678..d5573a61c122ad1daa3bb2a9f96fb928da4ce54e 100644 (file)
@@ -825,7 +825,7 @@ web.activityDuration = 7
 #\r
 # SPACE-DELIMITED\r
 # SINCE 1.3.0\r
-web.activityDurationChoices = 7 14 21 28\r
+web.activityDurationChoices = 1 3 7 14 21 28\r
 \r
 # The number of days of commits to cache in memory for the dashboard, activity,\r
 # and project pages.  A value of 0 will disable all caching and will parse commits\r
index 34ba138c9f10bd51716d7bb8e95399e4d5921e68..bca0dc0d1ed6e09c158118f07d3d7aa1dda440cc 100644 (file)
@@ -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
index 6cbd8626b135fd3f659d1b28d2ea2c71d77698b6..b0cb4705e2fb6fc4e900fa7c306e98a06a146b5b 100644 (file)
@@ -152,13 +152,8 @@ public class PageRegistration implements Serializable {
                                parameters = new PageParameters(params);\r
                                if (parameters.containsKey(parameter)) {\r
                                        isSelected = params.getString(parameter).equals(value);\r
-                                       if (isSelected) {\r
-                                               // already selected, so remove this enables toggling\r
-                                               parameters.remove(parameter);\r
-                                       } else {\r
-                                               // set the new selection value\r
-                                               setParameter(parameter, value);\r
-                                       }\r
+                                       // set the new selection value\r
+                                       setParameter(parameter, value);\r
                                } else {\r
                                        // not currently selected\r
                                        isSelected = false;\r
@@ -167,7 +162,7 @@ public class PageRegistration implements Serializable {
                        }\r
                }\r
 \r
-               private void setParameter(String parameter, String value) {\r
+               protected void setParameter(String parameter, String value) {\r
                        if (!StringUtils.isEmpty(parameter)) {\r
                                if (StringUtils.isEmpty(value)) {\r
                                        this.parameters.remove(parameter);\r
@@ -224,4 +219,25 @@ public class PageRegistration implements Serializable {
                        return displayText;\r
                }\r
        }\r
+       \r
+       public static class DropDownToggleItem extends DropDownMenuItem {\r
+               \r
+               private static final long serialVersionUID = 1L;\r
+\r
+               /**\r
+                * Toggle Menu Item constructor that preserves aggregate parameters.\r
+                * \r
+                * @param displayText\r
+                * @param parameter\r
+                * @param value\r
+                */\r
+               public DropDownToggleItem(String displayText, String parameter, String value,\r
+                               PageParameters params) {\r
+                       super(displayText, parameter, value, params);\r
+                       if (isSelected) {\r
+                               // already selected, so remove this enables toggling\r
+                               parameters.remove(parameter);\r
+                       }\r
+               }\r
+       }\r
 }
\ No newline at end of file
index d2c14fc4067216e1d809453b3cd65cbb91aaa196..87f2f3ffdf23f6dd22e75e71a261b38d73e43ffb 100644 (file)
@@ -431,7 +431,7 @@ public class WicketUtils {
        }\r
 \r
        public static int getDaysBack(PageParameters params) {\r
-               return params.getInt("db", 7);\r
+               return params.getInt("db", 0);\r
        }\r
 \r
        public static String getUsername(PageParameters params) {\r
index 61838ba20e94275408889e02378e04ce27610c43..694fa603a88876b6250e4adc30b8e5f97abe75f0 100644 (file)
@@ -61,7 +61,7 @@ public class ActivityPage extends RootPage {
                // parameters\r
                int daysBack = WicketUtils.getDaysBack(params);\r
                if (daysBack < 1) {\r
-                       daysBack = 14;\r
+                       daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
                }\r
                String objectId = WicketUtils.getObject(params);\r
 \r
@@ -70,9 +70,26 @@ public class ActivityPage extends RootPage {
                List<Activity> recentActivity = ActivityUtils.getRecentActivity(models, \r
                                daysBack, objectId, getTimeZone());\r
 \r
+               String headerPattern;\r
+               if (daysBack == 1) {\r
+                       // today\r
+                       if (recentActivity.size() == 0) {\r
+                               headerPattern = getString("gb.todaysActivityNone");\r
+                       } else {\r
+                               headerPattern = getString("gb.todaysActivityStats");\r
+                       }\r
+               } else {\r
+                       // multiple days\r
+                       if (recentActivity.size() == 0) {\r
+                               headerPattern = getString("gb.recentActivityNone");\r
+                       } else {\r
+                               headerPattern = getString("gb.recentActivityStats");\r
+                       }\r
+               }\r
+               \r
                if (recentActivity.size() == 0) {\r
                        // no activity, skip graphs and activity panel\r
-                       add(new Label("subheader", MessageFormat.format(getString("gb.recentActivityNone"),\r
+                       add(new Label("subheader", MessageFormat.format(headerPattern,\r
                                        daysBack)));\r
                        add(new Label("activityPanel"));\r
                } else {\r
@@ -86,7 +103,7 @@ public class ActivityPage extends RootPage {
                        int totalAuthors = uniqueAuthors.size();\r
 \r
                        // add the subheader with stat numbers\r
-                       add(new Label("subheader", MessageFormat.format(getString("gb.recentActivityStats"),\r
+                       add(new Label("subheader", MessageFormat.format(headerPattern,\r
                                        daysBack, totalCommits, totalAuthors)));\r
 \r
                        // create the activity charts\r
index 64d525546769968037cc9074639eb8b239662037..db3092ded9a47e6e38eb148173d6262b0cc5238c 100644 (file)
@@ -96,12 +96,20 @@ public abstract class DashboardPage extends RootPage {
                        // quiet or no starred repositories\r
                        if (repositories.size() == 0) {\r
                                if (UserModel.ANONYMOUS.equals(user)) {\r
-                                       activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack))); \r
+                                       if (daysBack == 1) {\r
+                                               activityFragment.add(new Label("digests", getString("gb.noActivityToday")));\r
+                                       } else {\r
+                                               activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));\r
+                                       }\r
                                } else {\r
                                        activityFragment.add(new LinkPanel("digests", null, getString("gb.findSomeRepositories"), RepositoriesPage.class));\r
                                }\r
                        } else {\r
-                               activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));\r
+                               if (daysBack == 1) {\r
+                                       activityFragment.add(new Label("digests", getString("gb.noActivityToday")));\r
+                               } else {\r
+                                       activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));\r
+                               }\r
                        }\r
                } else {\r
                        // show daily commit digest feed\r
@@ -228,7 +236,23 @@ public abstract class DashboardPage extends RootPage {
                        }\r
                }\r
                \r
-               frag.add(new Label("feedheader", MessageFormat.format(getString("gb.recentActivityStats"),\r
+               String headerPattern;\r
+               if (daysBack == 1) {\r
+                       // today\r
+                       if (totalCommits == 0) {\r
+                               headerPattern = getString("gb.todaysActivityNone");\r
+                       } else {\r
+                               headerPattern = getString("gb.todaysActivityStats");\r
+                       }\r
+               } else {\r
+                       // multiple days\r
+                       if (totalCommits == 0) {\r
+                               headerPattern = getString("gb.recentActivityNone");\r
+                       } else {\r
+                               headerPattern = getString("gb.recentActivityStats");\r
+                       }\r
+               }\r
+               frag.add(new Label("feedheader", MessageFormat.format(headerPattern,\r
                                daysBack, totalCommits, authorMetrics.size())));\r
 \r
                // build google charts\r
index 69dadbd0531b229bc22f991628d3e194b2a0a7e3..d951da3104e661f2758a99505b8ba6f81fad3235 100644 (file)
@@ -94,7 +94,7 @@ public class MyDashboardPage extends DashboardPage {
                // parameters\r
                int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);\r
                if (daysBack < 1) {\r
-                       daysBack = 7;\r
+                       daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
                }\r
                Calendar c = Calendar.getInstance();\r
                c.add(Calendar.DATE, -1*daysBack);\r
index fbd1db024183b49425fb9174c0040891453a8851..97a31f98b5aa5e1bca517c6c28a507b31cdb47b9 100644 (file)
@@ -106,12 +106,12 @@ public class ProjectPage extends DashboardPage {
                }\r
                int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);\r
                if (daysBack < 1) {\r
-                       daysBack = 7;\r
+                       daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);\r
                }\r
                // reset the daysback parameter so that we have a complete project\r
                // repository list.  the recent activity will be built up by the\r
                // reflog utils.\r
-               params.put("db", 0);\r
+               params.remove("db");\r
                \r
                List<RepositoryModel> repositories = getRepositories(params);\r
                Collections.sort(repositories, new Comparator<RepositoryModel>() {\r
index 8760f5c59ed14e00120b918dc385289eec2969af..f4ac907b67a4c5d58f8cadf21494f9907474a811 100644 (file)
@@ -52,6 +52,7 @@ import com.gitblit.utils.StringUtils;
 import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.PageRegistration;\r
 import com.gitblit.wicket.PageRegistration.DropDownMenuItem;\r
+import com.gitblit.wicket.PageRegistration.DropDownToggleItem;\r
 import com.gitblit.wicket.SessionlessForm;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.GravatarImage;\r
@@ -256,7 +257,7 @@ public abstract class RootPage extends BasePage {
                        List<String> sets = new ArrayList<String>(setMap.keySet());\r
                        Collections.sort(sets);\r
                        for (String set : sets) {\r
-                               filters.add(new DropDownMenuItem(MessageFormat.format("{0} ({1})", set,\r
+                               filters.add(new DropDownToggleItem(MessageFormat.format("{0} ({1})", set,\r
                                                setMap.get(set).get()), "set", set, params));\r
                        }\r
                        // divider\r
@@ -268,7 +269,7 @@ public abstract class RootPage extends BasePage {
                        List<TeamModel> teams = new ArrayList<TeamModel>(user.teams);\r
                        Collections.sort(teams);\r
                        for (TeamModel team : teams) {\r
-                               filters.add(new DropDownMenuItem(MessageFormat.format("{0} ({1})", team.name,\r
+                               filters.add(new DropDownToggleItem(MessageFormat.format("{0} ({1})", team.name,\r
                                                team.repositories.size()), "team", team.name, params));\r
                        }\r
                        // divider\r
@@ -283,7 +284,7 @@ public abstract class RootPage extends BasePage {
                        for (String expression : expressions) {\r
                                if (!StringUtils.isEmpty(expression)) {\r
                                        addedExpression = true;\r
-                                       filters.add(new DropDownMenuItem(null, "x", expression, params));\r
+                                       filters.add(new DropDownToggleItem(null, "x", expression, params));\r
                                }\r
                        }\r
                        // if we added any custom expressions, add a divider\r
@@ -300,7 +301,7 @@ public abstract class RootPage extends BasePage {
                if (daysBack < 1) {\r
                        daysBack = 7;\r
                }\r
-               PageParameters clonedParams;;\r
+               PageParameters clonedParams;\r
                if (params == null) {\r
                        clonedParams = new PageParameters();\r
                } else {\r
@@ -314,14 +315,18 @@ public abstract class RootPage extends BasePage {
                List<DropDownMenuItem> items = new ArrayList<DropDownMenuItem>();\r
                Set<Integer> choicesSet = new TreeSet<Integer>(GitBlit.getIntegers(Keys.web.activityDurationChoices));\r
                if (choicesSet.isEmpty()) {\r
-                        choicesSet.addAll(Arrays.asList(7, 14, 28, 60, 90, 180));\r
+                        choicesSet.addAll(Arrays.asList(1, 3, 7, 14, 21, 28));\r
                }\r
                List<Integer> choices = new ArrayList<Integer>(choicesSet);\r
                Collections.sort(choices);\r
                String lastDaysPattern = getString("gb.lastNDays");\r
                for (Integer db : choices) {\r
-                       String txt = MessageFormat.format(lastDaysPattern, db);\r
-                       items.add(new DropDownMenuItem(txt, "db", db.toString(), clonedParams));\r
+                       if (db == 1) {\r
+                               items.add(new DropDownMenuItem(getString("gb.time.today"), "db", db.toString(), clonedParams));\r
+                       } else {\r
+                               String txt = MessageFormat.format(lastDaysPattern, db);\r
+                               items.add(new DropDownMenuItem(txt, "db", db.toString(), clonedParams));\r
+                       }\r
                }\r
                items.add(new DropDownMenuItem());\r
                return items;\r