repos.jspf revision 838924562130977ca1a3d3839d146fcda39ea1af
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%--
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik$Id$
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen AustvikCDDL HEADER START
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen AustvikThe contents of this file are subject to the terms of the
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen AustvikCommon Development and Distribution License (the "License").
bb3eaa576162703921d669302217a3214c506602Jorgen AustvikYou may not use this file except in compliance with the License.
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen AustvikSee LICENSE.txt included in this distribution for the specific
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austviklanguage governing permissions and limitations under the License.
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen AustvikWhen distributing Covered Code, include this CDDL HEADER in each
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvikfile and include the License file at LICENSE.txt.
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen AustvikIf applicable, add the following below this CDDL HEADER, with the
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvikfields enclosed by brackets "[]" replaced with your own identifying
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvikinformation: Portions Copyright [yyyy] [name of copyright owner]
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen AustvikCDDL HEADER END
c30f98cf1e15f631ec1bda650923bf8e211ace78Knut Anders Hatlen
cf7ead0f677898593369e3964f6cbbe2e4566cbbJorgen AustvikCopyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik--%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="org.opensolaris.opengrok.configuration.messages.Message"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.SortedSet"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.SortedSet"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.Set"%>
cf7ead0f677898593369e3964f6cbbe2e4566cbbJorgen Austvik<%@page import="java.text.ParseException"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.ArrayList"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.Date"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="org.opensolaris.opengrok.web.Prefix"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="org.opensolaris.opengrok.web.ProjectHelper"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.LinkedList"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.Collections"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.Comparator"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.util.Collection"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="java.io.File"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="org.opensolaris.opengrok.configuration.RuntimeEnvironment"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="org.opensolaris.opengrok.history.RepositoryInfo"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="org.opensolaris.opengrok.history.Repository"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@page import="org.opensolaris.opengrok.web.Util"%>
08a0c20ec18b20b9b4223a086bc3916f4a4bfab5Jorgen Austvik<%@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">
<h2 class="clearfix">
<span class="pull-left">
<span class="name"><%= Util.htmlize(group.getName())%></span>
<small>[<a href="#" class="projects_select_all">select all</a>]</small>
</span>
<span class="pull-right">
<span class="fold <%= pHelper.hasFavourite(group) ? "fold-up" : "fold-down"%>"></span>
</span>
</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>
<%
SortedSet<Message> messages = cfg.getEnv().getMessages(project.getDescription());
%>
<% if(!messages.isEmpty()) { %>
<span class="important-note important-note-rounded" data-messages='<%= Util.messagesToJson(messages).toJSONString() %>'>!</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";
}
%><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 class="clearfix">
<span class="pull-left">
<span class="name">Other</span>
<small>[<a href="#" class="projects_select_all">select all</a>]</small>
</span>
<span class="pull-right">
<span class="fold <%= pHelper.hasUngroupedFavourite() ? "fold-up" : "fold-down"%>"></span>
</span>
</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>
<%
SortedSet<Message> messages = cfg.getEnv().getMessages(proj.getDescription());
%>
<% if(!messages.isEmpty()) { %>
<span class="important-note important-note-rounded" data-messages='<%= Util.messagesToJson(messages).toJSONString() %>'>!</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";
}
%><td><%= Util.htmlize(type) %></td><%
%><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
%></tr><%
cnt++;
}
}
%>
</tbody>
</table>
</div>
</div>
</div><%
}
}
}
%>
<br/>
<br/>