repos.jspf revision e40020b8ff95cd2a2680d1d651f6f8e40f1c35df
<%--
$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.
--%>
<script src="<%=request.getContextPath()%>/repos.js" type="text/javascript"></script>
<%@page import="java.util.Set"%>
<%@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"%>
<%
{
PageConfig cfg = PageConfig.get(request);
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">
<h2><span class="name"><%= Util.htmlize(group.getName()) %></span> <small>[<a href="#" class="projects_select_all">select all</a>]</small></h2>
</div>
<div class="panel-body-accordion <% if(pHelper.hasFavourite(group)) { %> favourite<% } %>"
<% if(pHelper.hasFavourite(group)) { %>data-accordion-visible="true"<% } %>>
<%
if(pHelper.getRepositories(group).size() > 0 ) {
%>
<table>
<thead>
<tr>
<td><b>Mirror</b></td>
<td><b>SCM type</b></td>
<td><b>Parent (branch)</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>
</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";
}
%><td><%= Util.htmlize(type) %></td><%
%><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</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">
<h2><span class="name">Other</span>
<small>[<a href="#" class="projects_select_all">select all</a>]</small>
</h2>
</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</b></td>
<td><b>Parent (branch)</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>
</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";
}
%><td><%= Util.htmlize(type) %></td><%
%><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
%></tr><%
cnt++;
}
}
%>
</tbody>
</table>
</div>
</div>
</div><%
}
}
}
%>
<br/>
<br/>