| | |
| | | import org.apache.wicket.Component;
|
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.Request;
|
| | | import org.apache.wicket.behavior.AttributeAppender;
|
| | | import org.apache.wicket.behavior.HeaderContributor;
|
| | | import org.apache.wicket.behavior.SimpleAttributeModifier;
|
| | | import org.apache.wicket.markup.html.IHeaderContributor;
|
| | | import org.apache.wicket.markup.html.IHeaderResponse;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | | import org.apache.wicket.markup.html.image.ContextImage;
|
| | | import org.apache.wicket.model.Model;
|
| | | import org.apache.wicket.protocol.http.WebRequest;
|
| | | import org.apache.wicket.resource.ContextRelativeResource;
|
| | | import org.eclipse.jgit.diff.DiffEntry.ChangeType;
|
| | | import org.wicketstuff.googlecharts.AbstractChartData;
|
| | | import org.wicketstuff.googlecharts.IChartData;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.Constants.AccessPermission;
|
| | | import com.gitblit.Constants.FederationPullStatus;
|
| | | import com.gitblit.IStoredSettings;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.models.FederationModel;
|
| | | import com.gitblit.models.Metric;
|
| | | import com.gitblit.utils.DiffUtils.DiffComparator;
|
| | | import com.gitblit.utils.HttpUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.TimeUtils;
|
| | |
| | |
|
| | | public static void setCssClass(Component container, String value) {
|
| | | container.add(new SimpleAttributeModifier("class", value));
|
| | | }
|
| | |
|
| | | public static void addCssClass(Component container, String value) {
|
| | | container.add(new AttributeAppender("class", new Model<String>(value), " "));
|
| | | }
|
| | |
|
| | | public static void setCssStyle(Component container, String value) {
|
| | |
| | | return newImage(wicketId, "file_settings_16x16.png");
|
| | | }
|
| | |
|
| | | MarkupProcessor processor = new MarkupProcessor(GitBlitWebApp.get().settings());
|
| | | String ext = StringUtils.getFileExtension(filename).toLowerCase();
|
| | | if (processor.getMarkupExtensions().contains(ext)) {
|
| | | IStoredSettings settings = GitBlitWebApp.get().settings();
|
| | | if (MarkupProcessor.getMarkupExtensions(settings).contains(ext)) {
|
| | | return newImage(wicketId, "file_world_16x16.png");
|
| | | }
|
| | | return newImage(wicketId, "file_16x16.png");
|
| | |
| | |
|
| | | public static PageParameters newRepositoryParameter(String repositoryName) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | parameterMap.put("r", repositoryName);
|
| | | if (!StringUtils.isEmpty(repositoryName)) {
|
| | | parameterMap.put("r", repositoryName);
|
| | | }
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", objectId);
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newDiffParameter(String repositoryName,
|
| | | String objectId, DiffComparator diffComparator) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | if (StringUtils.isEmpty(objectId)) {
|
| | | return newRepositoryParameter(repositoryName);
|
| | | }
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", objectId);
|
| | | parameterMap.put("w", "" + diffComparator.ordinal());
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newDiffParameter(String repositoryName,
|
| | | String objectId, DiffComparator diffComparator, String blobPath) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | if (StringUtils.isEmpty(objectId)) {
|
| | | return newRepositoryParameter(repositoryName);
|
| | | }
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", objectId);
|
| | | parameterMap.put("w", "" + diffComparator.ordinal());
|
| | | parameterMap.put("f", blobPath);
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | |
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newBlameTypeParameter(String repositoryName,
|
| | | String commitId, String path, String blameType) {
|
| | | Map<String, String> parameterMap = new HashMap<String, String>();
|
| | | parameterMap.put("r", repositoryName);
|
| | | parameterMap.put("h", commitId);
|
| | | parameterMap.put("f", path);
|
| | | parameterMap.put("blametype", blameType);
|
| | | return new PageParameters(parameterMap);
|
| | | }
|
| | |
|
| | | public static PageParameters newTicketsParameters(String repositoryName, String... states) {
|
| | | PageParameters tParams = newRepositoryParameter(repositoryName);
|
| | | if (states != null) {
|
| | | for (String state : states) {
|
| | | tParams.add("status", state);
|
| | | }
|
| | | }
|
| | | return tParams;
|
| | | }
|
| | |
|
| | | public static PageParameters newOpenTicketsParameter(String repositoryName) {
|
| | | return newTicketsParameters(repositoryName, TicketsUI.openStatii);
|
| | | }
|
| | |
|
| | | public static String getProjectName(PageParameters params) {
|
| | | return params.getString("p", "");
|
| | | }
|
| | |
| | |
|
| | | public static String getSearchType(PageParameters params) {
|
| | | return params.getString("st", null);
|
| | | }
|
| | |
|
| | | public static DiffComparator getDiffComparator(PageParameters params) {
|
| | | int ordinal = params.getInt("w", 0);
|
| | | return DiffComparator.values()[ordinal];
|
| | | }
|
| | |
|
| | | public static int getPage(PageParameters params) {
|
| | |
| | | // past
|
| | | title = timeUtils.timeAgo(date);
|
| | | }
|
| | | if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000L) {
|
| | | if (title != null && (System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000L) {
|
| | | String tmp = dateString;
|
| | | dateString = title;
|
| | | title = tmp;
|
| | |
| | | if (TimeUtils.isToday(date, timeZone)) {
|
| | | title = timeUtils.today();
|
| | | } else if (TimeUtils.isYesterday(date, timeZone)) {
|
| | | title = timeUtils.yesterday();
|
| | | title = timeUtils.yesterday();
|
| | | } else if (date.getTime() <= System.currentTimeMillis()) {
|
| | | // past
|
| | | title = timeUtils.timeAgo(date);
|
| | | } else {
|
| | | // future
|
| | | title = timeUtils.inFuture(date);
|
| | | }
|
| | | if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000L) {
|
| | | String tmp = dateString;
|
| | |
| | | return label;
|
| | | }
|
| | |
|
| | | public static IChartData getChartData(Collection<Metric> metrics) {
|
| | | final double[] commits = new double[metrics.size()];
|
| | | final double[] tags = new double[metrics.size()];
|
| | | int i = 0;
|
| | | double max = 0;
|
| | | for (Metric m : metrics) {
|
| | | commits[i] = m.count;
|
| | | if (m.tag > 0) {
|
| | | tags[i] = m.count;
|
| | | } else {
|
| | | tags[i] = -1d;
|
| | | }
|
| | | max = Math.max(max, m.count);
|
| | | i++;
|
| | | }
|
| | | IChartData data = new AbstractChartData(max) {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public double[][] getData() {
|
| | | return new double[][] { commits, tags };
|
| | | }
|
| | | };
|
| | | return data;
|
| | | }
|
| | |
|
| | | public static double maxValue(Collection<Metric> metrics) {
|
| | | double max = Double.MIN_VALUE;
|
| | | for (Metric m : metrics) {
|
| | |
| | | }
|
| | | return max;
|
| | | }
|
| | |
|
| | | public static IChartData getScatterData(Collection<Metric> metrics) {
|
| | | final double[] y = new double[metrics.size()];
|
| | | final double[] x = new double[metrics.size()];
|
| | | int i = 0;
|
| | | double max = 0;
|
| | | for (Metric m : metrics) {
|
| | | y[i] = m.count;
|
| | | if (m.duration > 0) {
|
| | | x[i] = m.duration;
|
| | | } else {
|
| | | x[i] = -1d;
|
| | | }
|
| | | max = Math.max(max, m.count);
|
| | | i++;
|
| | | }
|
| | | IChartData data = new AbstractChartData(max) {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public double[][] getData() {
|
| | | return new double[][] { x, y };
|
| | | }
|
| | | };
|
| | | return data;
|
| | | }
|
| | |
|
| | | }
|