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

Last change on this file since 5937 was 5937, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • Fixes rest of view pages in biomaterials menu.
  • Use SVG filter to make disabled button images grayscale.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 11.1 KB
Line 
1<%-- $Id: view_group.jsp 5937 2012-01-27 11:00:26Z 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>
128    <p:path>
129      <p:pathelement title="Groups" href="<%="index.jsp?ID="+ID%>" />
130      <p:pathelement title="<%=HTML.encodeTags(group.getName())%>" />
131    </p:path>
132   
133    <t:tabcontrol id="main" active="properties">
134    <t:tab id="properties" title="Properties">
135   
136    <tbl:toolbar
137      >
138      <tbl:button 
139        disabled="<%=writePermission ? false : true%>" 
140        image="edit.gif" 
141        onclick="editItem()" 
142        title="Edit&hellip;" 
143        tooltip="<%=writePermission ? "Edit this group" : "You do not have permission to edit this group"%>" 
144      />
145      <tbl:button 
146        disabled="<%=deletePermission ? false : true%>" 
147        image="delete.gif" 
148        onclick="deleteItem()" 
149        title="Delete"
150        visible="<%=!group.isRemoved()%>"
151        tooltip="<%=deletePermission ? "Delete this group" : "You do not have permission to delete this group"%>" 
152      />
153      <tbl:button 
154        disabled="<%=writePermission ? false : true%>" 
155        image="restore.gif" 
156        onclick="restoreItem()" 
157        title="Restore"
158        visible="<%=group.isRemoved()%>"
159        tooltip="<%=writePermission ? "Restore this group" : "You do not have permission to restore this group"%>" 
160      />
161      <tbl:button 
162        image="import.gif" 
163        onclick="runPlugin('ImportItem')" 
164        title="Import&hellip;" 
165        tooltip="Import data" 
166        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
167      />
168      <tbl:button 
169        image="export.gif" 
170        onclick="runPlugin('ExportItem')" 
171        title="Export&hellip;" 
172        tooltip="Export data" 
173        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
174      />
175      <tbl:button 
176        image="runplugin.gif" 
177        onclick="runPlugin('RunPlugin')" 
178        title="Run plugin&hellip;" 
179        tooltip="Run a plugin" 
180        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
181      />
182      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
183        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
184      <tbl:button
185        image="help.png"
186        onclick="<%="Main.openHelp('" + ID +"', 'group.view.properties')"%>"
187        title="Help&hellip;"
188        tooltip="Get help about this page"
189      />
190      </tbl:toolbar>
191    <div class="boxedbottom">
192      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(group)%></i></div>
193      <%
194      if (group.isRemoved())
195      {
196        %>
197        <div class="itemstatus">
198          <base:icon 
199            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
200            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
201            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
202            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
203          <base:icon image="used.gif" 
204            onclick="showUsingItems()"
205            tooltip="Show the items that are using this one"
206            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
207        </div>
208        <%
209      }
210      %>
211      <table class="form" cellspacing=0>
212      <tr>
213        <td class="prompt">Name</td>
214        <td><%=HTML.encodeTags(group.getName())%></td>
215      </tr>
216      <tr>
217        <td class="prompt">Registered</td>
218        <td><%=dateFormatter.format(group.getEntryDate())%></td>
219      </tr>
220      <tr>
221        <td class="prompt">System ID</td>
222        <td><%=HTML.encodeTags(group.getSystemId())%></td>
223      </tr>
224      <tr>
225        <td class="prompt">Quota</td>
226        <td><base:propertyvalue item="<%=group%>" property="quota" /></td>
227      </tr>
228      <tr>
229        <td class="prompt">Is default</td>
230        <td><%=group.isDefault() ? "yes" : "no"%></td>
231      </tr>
232      <tr>
233        <td class="prompt">Hidden members</td>
234        <td><%=group.hasHiddenMembers() ? "yes" : "no"%></td>
235      </tr>
236      <tr>
237        <td class="prompt">Description</td>
238        <td><%=HTML.niceFormat(group.getDescription())%></td>
239      </tr>
240      </table>
241     
242      <%
243      ItemQuery<User> userQuery = group.getUsers();
244      userQuery.include(Include.ALL);
245      userQuery.order(Orders.asc(Hql.property("name")));
246      ItemResultList<User> users = userQuery.list(dc);
247     
248      ItemQuery<Group> groupQuery = group.getGroups();
249      groupQuery.include(Include.ALL);
250      groupQuery.order(Orders.asc(Hql.property("name")));
251      ItemResultList<Group> groups = groupQuery.list(dc);
252     
253      if (groups.size() == 0 && users.size() == 0)
254      {
255        %>
256        <h4>Members</h4>
257        There are no members of this group (or, you don't have permission to view them).
258        <%
259      }
260      else
261      {
262        %>
263        <base:section 
264          id="members" 
265          title="<%="Members (" + (users.size() + groups.size()) + ")"%>"
266          context="<%=cc%>"
267          >       
268          <tbl:table
269            id="members"
270           
271            columns="all"
272            >
273          <tbl:columndef 
274            id="name"
275            title="Name"
276          />
277          <tbl:columndef 
278            id="type"
279            title="Type"
280          />
281          <tbl:columndef 
282            id="description"
283            title="Description"
284          />
285          <tbl:data>
286            <tbl:columns>
287            </tbl:columns>
288            <tbl:rows>
289            <%
290            for (User user : users)
291            {
292              %>
293              <tbl:row>
294                <tbl:cell column="name"><base:icon 
295                    image="deleted.gif" 
296                    tooltip="This item has been scheduled for deletion" 
297                    visible="<%=user.isRemoved()%>"
298                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
299                <tbl:cell column="type">User</tbl:cell>
300                <tbl:cell column="description"><%=HTML.encodeTags(user.getDescription())%></tbl:cell>
301              </tbl:row>
302              <%
303            }
304            for (Group child : groups)
305            {
306              %>
307              <tbl:row>
308                <tbl:cell column="name"><base:icon 
309                    image="deleted.gif" 
310                    tooltip="This item has been scheduled for deletion" 
311                    visible="<%=child.isRemoved()%>"
312                  /><%=Base.getLinkedName(ID, child, false, true)%></tbl:cell>
313                <tbl:cell column="type">Group</tbl:cell>
314                <tbl:cell column="description"><%=HTML.encodeTags(child.getDescription())%></tbl:cell>
315              </tbl:row>
316              <%
317            }
318            %>
319            </tbl:rows>
320          </tbl:data>
321          </tbl:table>
322        </base:section>
323        <%
324      }
325      %>
326      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
327        <jsp:param name="ID" value="<%=ID%>" />
328        <jsp:param name="item_type" value="<%=itemType.name()%>" />
329        <jsp:param name="item_id" value="<%=itemId%>" />
330        <jsp:param name="title" value="Other items related to this group" />
331      </jsp:include>
332    </div>
333      </t:tab>
334      </t:tabcontrol>
335
336  </base:body>
337  </base:page>
338  <%
339}
340finally
341{
342  if (dc != null) dc.close();
343}
344
345%>
Note: See TracBrowser for help on using the repository browser.