<%--
$Id$
CDDL HEADER START
The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.
See LICENSE.txt included in this distribution for the specific
language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at LICENSE.txt.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
--%>
<%@page import="org.json.simple.JSONArray"%>
<%@page import="org.opensolaris.opengrok.configuration.messages.Message"%>
<%@page import="java.util.SortedSet"%>
<%@page import="java.util.SortedSet"%>
<%@page import="java.util.Set"%>
<%@page import="java.text.ParseException"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Date"%>
<%@page import="org.opensolaris.opengrok.web.Prefix"%>
<%@page import="org.opensolaris.opengrok.web.ProjectHelper"%>
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.Collections"%>
<%@page import="java.util.Comparator"%>
<%@page import="java.util.Collection"%>
<%@page import="java.io.File"%>
<%@page import="org.opensolaris.opengrok.configuration.RuntimeEnvironment"%>
<%@page import="org.opensolaris.opengrok.history.RepositoryInfo"%>
<%@page import="org.opensolaris.opengrok.history.Repository"%>
<%@page import="org.opensolaris.opengrok.web.Util"%>
<%@page import="org.opensolaris.opengrok.configuration.Project"%>
<%@page import="org.opensolaris.opengrok.configuration.Group"%>
<%@page import="java.util.List"%>
<%@page import="org.opensolaris.opengrok.web.PageConfig"%>
<script src="<%=request.getContextPath()%>/js/repos.js" type="text/javascript"></script>
<%
{
PageConfig cfg = PageConfig.get(request);
Util.printMessages(out, cfg.getMessages());
Comparator<RepositoryInfo> comparatorRepo = new Comparator<RepositoryInfo>() {
public int compare(RepositoryInfo r1, RepositoryInfo r2) {
return r1.getDirectoryName().compareTo(r2.getDirectoryName());
}
};
ProjectHelper pHelper = cfg.getProjectHelper();
if (pHelper.getAllProjects().size() > 0) {
Set<Group> groups = pHelper.getGroups();
Set<Project> repositories = pHelper.getUngroupedRepositories();
if (groups.size() > 0) {
// recursively print all groups
%>
<div class="panel-group projects">
<div class="toggle-buttons">
<a href="#" class="accordion_show_all">
<button>Show all</button>
</a>
<a href="#" class="accordion_hide_all">
<button>Hide all</button>
</a>
</div>
<%
LinkedList<Group> stack = new LinkedList<Group>();
for ( Group x : groups ) {
if (x.getParent() == null && (pHelper.hasAllowedSubgroup(x) || cfg.isAllowed(x))) {
x.setFlag(0);
stack.addLast(x);
}
}
while ( ! stack.isEmpty() ) {
Group group = stack.element();
if (group.getFlag() > 0) {
// already processed
stack.pollFirst();
%></div><!-- body -->
</div><!-- panel --><%
continue;
}
stack.element().setFlag(1);
for (Group x : pHelper.getSubgroups(group)) {
if (cfg.isAllowed(x) || pHelper.hasAllowedSubgroup(x)) {
x.setFlag(0);
stack.addFirst(x);
}
}
%><div class="panel">
<div class="panel-heading-accordion">
<h4 class="clearfix">
<span class="pull-left">
<span class="name"><%= Util.htmlize(group.getName())%></span>
<small>
[<a href="#" class="projects_select_all">select all</a>]
(<span title="Number of groups directly in this group"><%= pHelper.getSubgroups(group).size() %></span> +
<span title="Number of repositories directly in this group"><%= pHelper.getRepositories(group).size() %></span>)
</small>
</span>
<span class="pull-right">
<span class="fold <%= pHelper.hasFavourite(group) ? "fold-up" : "fold-down"%>"></span>
</span>
</h4>
</div>
<div class="panel-body-accordion<% if (pHelper.hasFavourite(group)) { %> favourite<% } %>"
<% if (pHelper.hasFavourite(group) || pHelper.getRepositories(group).size() < 5) { %>data-accordion-visible="true"<% } %>>
<%
if (pHelper.getRepositories(group).size() > 0 ) {
%>
<table>
<thead>
<tr>
<td><b>Mirror</b></td>
<td><b>SCM Type: Parent (branch)</b></td>
<td><b>Current version</b></td>
</tr>
</thead>
<tbody>
<%
for ( Project project : pHelper.getRepositories(group)) {
List<RepositoryInfo> repos = pHelper.getRepositoryInfo(project);
String projDesc = project.getDescription();
Integer cnt = 0;
Collections.sort(repos, comparatorRepo);
%>
<%
for (RepositoryInfo ri : repos) {
if (cnt > 0 && ri.getParent() == null)
// discard repositories without a parent url
continue;
if (cnt != 0) {
projDesc = ri.getDirectoryName()
.replace(cfg.getSourceRootPath() + File.separator, "");
}
%>
<tr>
<td class="name <%= cnt > 0 ? "subrepository" : "repository" %>">
<a href="<%= request.getContextPath() + Prefix.XREF_P + "/" + projDesc%>"
title="Xref for project <%= Util.htmlize(projDesc) %>">
<%= Util.htmlize(projDesc) %>
</a>
<%
JSONArray messages = Util.messagesToJson(project.getDescription());
if (!messages.isEmpty()) { %>
<span class="important-note important-note-rounded" data-messages='<%= messages %>'>!</span>
<% } %>
</td><%
String parent = ri.getParent();
if (parent == null) {
parent = "N/A";
}
String type = ri.getType();
if (type == null) {
type = "N/A";
}
String branch = ri.getBranch();
if (branch == null) {
branch = "N/A";
}
String currentVersion = ri.getCurrentVersion();
if (currentVersion == null) {
currentVersion = "N/A";
}
%><td><%= Util.htmlize(type) %>: <%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
%><td><%
// Current index collapse threshold minimum of 10
int summaryLength = Math.max(10, cfg.getCurrentIndexedCollapseThreshold());
String cout = Util.htmlize(currentVersion);
boolean showSummary = false;
String coutSummary = currentVersion;
if (coutSummary.length() > summaryLength) {
showSummary = true;
coutSummary = coutSummary.substring(0, summaryLength - 1);
coutSummary = Util.htmlize(coutSummary);
}
if (showSummary) {
%>
<span class="rev-message-summary"><%= coutSummary %></span>
<span class="rev-message-full rev-message-hidden"><%= cout %></span>
<span data-toggle-state="less"><a class="rev-toggle-a rev-message-toggle " href="#">show more ... </a></span>
<%
}
else {
%><span class="rev-message-full"><%= cout %></span><%
}
%></td><%
%></tr><%
cnt++;
}
}
%></tbody>
</table><%
} else if ( pHelper.getRepositories(group).size() <= 0 && !pHelper.hasAllowedSubgroup(group) ) {
%>No projects<%
}
}
%></div><%
}
// print the rest of projects which don't have a group
if (repositories.size() > 0) { %>
<div class="panel-group projects">
<% if (groups.size() > 0) { %>
<div class="toggle-buttons">
<a href="#" class="accordion_show_all">
<button>Show all</button>
</a>
<a href="#" class="accordion_hide_all">
<button>Hide all</button>
</a>
</div>
<% } %>
<div class="panel">
<% if (groups.size() > 0) {%>
<div class="panel-heading-accordion">
<h4 class="clearfix">
<span class="pull-left">
<span class="name">Other</span>
<small>
[<a href="#" class="projects_select_all">select all</a>]
(<span title="Number of repositories inside"><%= repositories.size() %></span>)
</small>
</span>
<span class="pull-right">
<span class="fold <%= pHelper.hasUngroupedFavourite() ? "fold-up" : "fold-down"%>"></span>
</span>
</h4>
</div>
<% } %>
<div class="panel-body<% if (groups.size() > 0) {%>-accordion<% } %> <% if (pHelper.hasUngroupedFavourite()) { %> favourite<% } %>"
<% if (pHelper.hasUngroupedFavourite()) { %>data-accordion-visible="true"<% } %>>
<table>
<thead>
<tr>
<td><b>Mirror</b></td>
<td><b>SCM Type: Parent (branch)</b></td>
<td><b>Current version</b></td>
</tr>
</thead>
<tbody>
<%
for (Project proj : repositories) {
List<RepositoryInfo> repos = pHelper.getRepositoryInfo(proj);
String projDesc = proj.getDescription();
Integer cnt = 0;
Collections.sort(repos, comparatorRepo);
for (RepositoryInfo ri : repos) {
if (cnt > 0 && ri.getParent() == null)
// discard repositories without a parent url
continue;
if (cnt != 0) {
projDesc = ri.getDirectoryName()
.replace(cfg.getSourceRootPath() + File.separator, "");
}
%>
<tr><td class="name <%= cnt > 0 ? "subrepository" : "repository" %>">
<a href="<%= request.getContextPath() + Prefix.XREF_P + "/" + projDesc %>"
title="Xref for project <%= Util.htmlize(projDesc) %>">
<%= Util.htmlize(projDesc) %>
</a>
<%
JSONArray messages = Util.messagesToJson(proj.getDescription());
if (!messages.isEmpty()) { %>
<span class="important-note important-note-rounded" data-messages='<%= messages %>'>!</span>
<% } %>
</td><%
String parent = ri.getParent();
if (parent == null) {
parent = "N/A";
}
String type = ri.getType();
if (type == null) {
type = "N/A";
}
String branch = ri.getBranch();
if (branch == null) {
branch = "N/A";
}
String currentVersion = ri.getCurrentVersion();
if (currentVersion == null) {
currentVersion = "N/A";
}
%><td><%= Util.htmlize(type) %>: <%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
%><td><%
// Current index message collapse threshold minimum of 10
int summaryLength = Math.max(10, cfg.getCurrentIndexedCollapseThreshold());
String cout = Util.htmlize(currentVersion);
boolean showSummary = false;
String coutSummary = currentVersion;
if (coutSummary.length() > summaryLength) {
showSummary = true;
coutSummary = coutSummary.substring(0, summaryLength - 1);
coutSummary = Util.htmlize(coutSummary);
}
if (showSummary) {
%>
<span class="rev-message-summary"><%= coutSummary %></span>
<span class="rev-message-full rev-message-hidden"><%= cout %></span>
<span data-toggle-state="less"><a class="rev-toggle-a rev-message-toggle " href="#">show more ... </a></span>
<%
}
else {
%><span class="rev-message-full"><%= cout %></span><%
}
%></td><%
%></tr><%
cnt++;
}
}
%>
</tbody>
</table>
</div>
</div>
</div><%
}
}
}
%>
<br/>
<br/>