source: trunk/www/admin/groups/view_group.jsp @ 5941

Last change on this file since 5941 was 5941, checked in by Nicklas Nordborg, 11 years ago

References #1655: GUI improvements

View pages for all items in the Adminstrate menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 11.2 KB
Line 
1<%-- $Id: view_group.jsp 5941 2012-02-01 13:26:23Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Nicklas Nordborg
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.SystemItems"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.Group"
34  import="net.sf.basedb.core.Quota"
35  import="net.sf.basedb.core.User"
36  import="net.sf.basedb.core.PermissionDeniedException"
37  import="net.sf.basedb.core.PluginDefinition"
38  import="net.sf.basedb.core.ItemQuery"
39  import="net.sf.basedb.core.ItemResultList"
40  import="net.sf.basedb.core.Include"
41  import="net.sf.basedb.core.query.Orders"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.clients.web.Base"
46  import="net.sf.basedb.clients.web.PermissionUtil"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.Values"
49  import="net.sf.basedb.util.formatter.Formatter"
50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
51  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
52  import="net.sf.basedb.clients.web.extensions.JspContext"
53  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
54  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
55  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
56  import="java.util.Date"
57  import="java.util.Map"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
61<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
62<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
63<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
64<%!
65  private static final Item itemType = Item.GROUP;
66  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
67%>
68<%
69final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
70final String ID = sc.getId();
71final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
72final int itemId = cc.getId();
73final float scale = Base.getScale(sc);
74final DbControl dc = sc.newDbControl();
75try
76{
77  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
78  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
79
80  String title = null;
81  Group group = Group.getById(dc, itemId);
82 
83  final boolean writePermission = group.hasPermission(Permission.WRITE);
84  final boolean deletePermission = group.hasPermission(Permission.DELETE);
85  final boolean isRemoved = group.isRemoved();
86  final boolean isUsed = isRemoved && group.isUsed();
87  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
88  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, group);
89  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
90  %>
91  <base:page title="<%=title%>">
92  <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
93    <ext:scripts context="<%=jspContext%>" />
94    <ext:stylesheets context="<%=jspContext%>" />
95    <script language="JavaScript">
96    function editItem()
97    {
98      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
99    }
100    function deleteItem()
101    {
102      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
103    }
104    function restoreItem()
105    {
106      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
107    }
108    function deleteItemPermanently()
109    {
110      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
111    }
112    function itemDeleted()
113    {
114      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
115    }
116    function showUsingItems()
117    {
118      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
119    }
120    function runPlugin(cmd)
121    {
122      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
123    }
124    </script>
125  </base:head>
126  <base:body>
127    <p:path><p:pathelement 
128      title="Groups" href="<%="index.jsp?ID="+ID%>" 
129      /><p:pathelement title="<%=HTML.encodeTags(group.getName())%>" 
130      /></p:path>
131   
132    <t:tabcontrol 
133      id="main" 
134      subclass="content mastertabcontrol" 
135      active="properties">
136    <t:tab id="properties" title="Properties">
137      <div>
138      <table class="fullform bottomborder">
139      <tr>
140        <th class="itemstatus">
141          <base:icon 
142            image="deleted.gif"
143            onclick="deleteItemPermanently()"
144            tooltip="This item has been flagged for deletion. Click to delete it now."
145            enabled="<%=deletePermanentlyPermission %>"
146            visible="<%=isRemoved%>" 
147          />
148          <base:icon image="used.gif" 
149            onclick="showUsingItems()"
150            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
151            visible="<%=isRemoved && isUsed%>" />
152        </th>
153        <td style="padding: 0px;">
154          <tbl:toolbar subclass="bottomborder">
155            <tbl:button 
156              disabled="<%=writePermission ? false : true%>" 
157              image="edit.gif" 
158              onclick="editItem()" 
159              title="Edit&hellip;" 
160              tooltip="<%=writePermission ? "Edit this group" : "You do not have permission to edit this group"%>" 
161            />
162            <tbl:button 
163              disabled="<%=deletePermission ? false : true%>" 
164              image="delete.gif" 
165              onclick="deleteItem()" 
166              title="Delete"
167              visible="<%=!group.isRemoved()%>"
168              tooltip="<%=deletePermission ? "Delete this group" : "You do not have permission to delete this group"%>" 
169            />
170            <tbl:button 
171              disabled="<%=writePermission ? false : true%>" 
172              image="restore.gif" 
173              onclick="restoreItem()" 
174              title="Restore"
175              visible="<%=group.isRemoved()%>"
176              tooltip="<%=writePermission ? "Restore this group" : "You do not have permission to restore this group"%>" 
177            />
178            <tbl:button 
179              image="import.gif" 
180              onclick="runPlugin('ImportItem')" 
181              title="Import&hellip;" 
182              tooltip="Import data" 
183              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
184            />
185            <tbl:button 
186              image="export.gif" 
187              onclick="runPlugin('ExportItem')" 
188              title="Export&hellip;" 
189              tooltip="Export data" 
190              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
191            />
192            <tbl:button 
193              image="runplugin.gif" 
194              onclick="runPlugin('RunPlugin')" 
195              title="Run plugin&hellip;" 
196              tooltip="Run a plugin" 
197              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
198            />
199            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
200              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
201            <tbl:button
202              image="help.png"
203              onclick="<%="Main.openHelp('" + ID +"', 'group.view.properties')"%>"
204              title="Help&hellip;"
205              tooltip="Get help about this page"
206            />
207          </tbl:toolbar>
208        </td>
209      </tr>
210      <tr>
211        <th>Name</th>
212        <td><%=HTML.encodeTags(group.getName())%></td>
213      </tr>
214      <tr>
215        <th>Registered</th>
216        <td><%=dateFormatter.format(group.getEntryDate())%></td>
217      </tr>
218      <tr>
219        <th>System ID</th>
220        <td><%=HTML.encodeTags(group.getSystemId())%></td>
221      </tr>
222      <tr>
223        <th>Quota</th>
224        <td><base:propertyvalue item="<%=group%>" property="quota" /></td>
225      </tr>
226      <tr>
227        <th>Is default</th>
228        <td><%=group.isDefault() ? "yes" : "no"%></td>
229      </tr>
230      <tr>
231        <th>Hidden members</th>
232        <td><%=group.hasHiddenMembers() ? "yes" : "no"%></td>
233      </tr>
234      <tr>
235        <th>Permissions</th>
236        <td><%=PermissionUtil.getFullPermissionNames(group)%></td>
237      </tr>
238      <tr>
239        <th>Description</th>
240        <td><%=HTML.niceFormat(group.getDescription())%></td>
241      </tr>
242      </table>
243      </div>
244     
245      <%
246      ItemQuery<User> userQuery = group.getUsers();
247      userQuery.include(Include.ALL);
248      userQuery.order(Orders.asc(Hql.property("name")));
249      ItemResultList<User> users = userQuery.list(dc);
250     
251      ItemQuery<Group> groupQuery = group.getGroups();
252      groupQuery.include(Include.ALL);
253      groupQuery.order(Orders.asc(Hql.property("name")));
254      ItemResultList<Group> groups = groupQuery.list(dc);
255      int numMembers = groups.size() + users.size();
256      %>
257      <base:section 
258        id="members" 
259        title="<%="Members (" + (users.size() + groups.size()) + ")"%>"
260        context="<%=cc%>"
261        >
262        <%
263        if (numMembers == 0)
264        {
265          %>
266          <div class="messagecontainer note">
267          There are no members in this group (or, you don't have permission to view them).
268          </div>
269          <%
270        }
271        else
272        {
273          %>
274          <tbl:table
275            id="members"
276            columns="all"
277            >
278          <tbl:columndef 
279            id="name"
280            title="Name"
281          />
282          <tbl:columndef 
283            id="type"
284            title="Type"
285          />
286          <tbl:columndef 
287            id="description"
288            title="Description"
289          />
290          <tbl:data>
291            <tbl:headers>
292              <tbl:headerrow>
293                <tbl:columnheaders />
294              </tbl:headerrow>
295            </tbl:headers>
296            <tbl:rows>
297            <%
298            for (User user : users)
299            {
300              %>
301              <tbl:row>
302                <tbl:cell column="name"><base:icon 
303                    image="deleted.gif" 
304                    tooltip="This item has been scheduled for deletion" 
305                    visible="<%=user.isRemoved()%>"
306                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
307                <tbl:cell column="type">User</tbl:cell>
308                <tbl:cell column="description"><%=HTML.encodeTags(user.getDescription())%></tbl:cell>
309              </tbl:row>
310              <%
311            }
312            for (Group child : groups)
313            {
314              %>
315              <tbl:row>
316                <tbl:cell column="name"><base:icon 
317                    image="deleted.gif" 
318                    tooltip="This item has been scheduled for deletion" 
319                    visible="<%=child.isRemoved()%>"
320                  /><%=Base.getLinkedName(ID, child, false, true)%></tbl:cell>
321                <tbl:cell column="type">Group</tbl:cell>
322                <tbl:cell column="description"><%=HTML.encodeTags(child.getDescription())%></tbl:cell>
323              </tbl:row>
324              <%
325            }
326            %>
327            </tbl:rows>
328          </tbl:data>
329          </tbl:table>
330          <%
331        }
332        %>
333      </base:section>
334      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
335        <jsp:param name="ID" value="<%=ID%>" />
336        <jsp:param name="item_type" value="<%=itemType.name()%>" />
337        <jsp:param name="item_id" value="<%=itemId%>" />
338        <jsp:param name="title" value="Other items related to this group" />
339      </jsp:include>
340    </t:tab>
341    </t:tabcontrol>
342  </base:body>
343  </base:page>
344  <%
345}
346finally
347{
348  if (dc != null) dc.close();
349}
350
351%>
Note: See TracBrowser for help on using the repository browser.