source: trunk/www/views/permissiontemplates/view_template.jsp @ 5939

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

References #1655: GUI improvements

View pages for:

  • File server
  • Projects
  • Permission templates
  • Physical, derived and raw bioassays
  • Experiments, bioassay set
  • Formulas
  • Reporters
  • Reporter lists
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 10.4 KB
Line 
1<%-- $Id $
2  ------------------------------------------------------------------
3  Copyright (C) 2010 Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23--%>
24<%@ page pageEncoding="UTF-8" session="false"
25  import="net.sf.basedb.core.SessionControl"
26  import="net.sf.basedb.core.DbControl"
27  import="net.sf.basedb.core.SystemItems"
28  import="net.sf.basedb.core.Group"
29  import="net.sf.basedb.core.Include"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.ItemQuery"
33  import="net.sf.basedb.core.ItemResultList"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.PermissionTemplate"
36  import="net.sf.basedb.core.MultiPermissions"
37  import="net.sf.basedb.core.User"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.core.PluginDefinition"
40  import="net.sf.basedb.core.plugin.GuiContext"
41  import="net.sf.basedb.core.plugin.Plugin"
42  import="net.sf.basedb.core.Project"
43  import="net.sf.basedb.core.query.Orders"
44  import="net.sf.basedb.core.query.Hql"
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.Collections"
58  import="java.util.Map"
59  import="java.util.Set"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
63<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
64<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
65<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
66<%!
67  private static final Item itemType = Item.PERMISSIONTEMPLATE;
68  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
69%>
70<%
71final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
72final String ID = sc.getId();
73final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
74final int itemId = cc.getId();
75final float scale = Base.getScale(sc);
76final DbControl dc = sc.newDbControl();
77try
78{
79  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
80  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
81
82  String title = null;
83  PermissionTemplate template = PermissionTemplate.getById(dc, itemId);
84 
85  final boolean writePermission = template.hasPermission(Permission.WRITE);
86  final boolean deletePermission = template.hasPermission(Permission.DELETE);
87  final boolean sharePermission = template.hasPermission(Permission.SET_PERMISSION);
88  final boolean usePermission = template.hasPermission(Permission.USE);
89  final boolean setOwnerPermission = template.hasPermission(Permission.SET_OWNER);
90  final boolean isRemoved = template.isRemoved();
91  final boolean isUsed = isRemoved && template.isUsed();
92  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
93  final boolean isOwner = template.isOwner();
94  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, template);
95  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
96  %>
97  <base:page title="<%=title%>">
98  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
99    <ext:scripts context="<%=jspContext%>" />
100    <ext:stylesheets context="<%=jspContext%>" />
101    <script language="JavaScript">
102    function editItem()
103    {
104      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
105    }
106    function shareItem()
107    {
108      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePermissionTemplate', 600, 400);
109    }
110    function deleteItem()
111    {
112      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
113    }
114    function restoreItem()
115    {
116      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
117    }
118    function deleteItemPermanently()
119    {
120      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
121    }
122    function itemDeleted()
123    {
124      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
125    }
126    function showUsingItems()
127    {
128      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
129    }
130    function setOwner()
131    {
132      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
133    }
134    function runPlugin(cmd)
135    {
136      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
137    }
138    </script>
139  </base:head>
140  <base:body>
141    <p:path><p:pathelement 
142      title="Permission templates" href="<%="index.jsp?ID="+ID%>" 
143      /><p:pathelement title="<%=HTML.encodeTags(template.getName())%>"
144      /></p:path>
145   
146    <t:tabcontrol 
147      id="main" 
148      subclass="content mastertabcontrol" 
149      active="properties">
150    <t:tab id="properties" title="Properties">
151      <div>
152      <table class="fullform bottomborder">
153      <tr>
154        <th class="itemstatus">
155          <base:icon 
156            image="shared.gif" 
157            visible="<%=template.isShared()%>"
158            tooltip="This item is shared to other users, groups and/or projects"
159          />
160          <base:icon 
161            image="deleted.gif"
162            onclick="deleteItemPermanently()"
163            tooltip="This item has been flagged for deletion. Click to delete it now."
164            enabled="<%=deletePermanentlyPermission %>"
165            visible="<%=isRemoved%>" 
166          />
167          <base:icon image="used.gif" 
168            onclick="showUsingItems()"
169            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
170            visible="<%=isRemoved && isUsed%>" />
171        </th>
172        <td style="padding: 0px;">
173          <tbl:toolbar subclass="bottomborder">
174            <tbl:button 
175              disabled="<%=writePermission ? false : true%>" 
176              image="edit.gif" 
177              onclick="editItem()" 
178              title="Edit&hellip;" 
179              tooltip="<%=writePermission ? "Edit this permission template" : "You do not have permission to edit this permission template"%>" 
180            />
181            <tbl:button 
182              disabled="<%=deletePermission ? false : true%>" 
183              image="delete.gif" 
184              onclick="deleteItem()" 
185              title="Delete"
186              visible="<%=!template.isRemoved()%>"
187              tooltip="<%=deletePermission ? "Delete this permission template" : "You do not have permission to delete this permission template"%>" 
188            />
189            <tbl:button 
190              disabled="<%=writePermission ? false : true%>" 
191              image="restore.gif" 
192              onclick="restoreItem()" 
193              title="Restore"
194              visible="<%=template.isRemoved()%>"
195              tooltip="<%=writePermission ? "Restore this permission template" : "You do not have permission to restore this permission template"%>" 
196            />
197            <tbl:button 
198              disabled="<%=sharePermission ? false : true%>"
199              image="share.gif"
200              onclick="shareItem()" 
201              title="Permissions&hellip;" 
202              tooltip="<%=sharePermission ? "Set permission on this permission template" : "You do not have permission to modify this permission template"%>"
203            />
204            <tbl:button 
205              disabled="<%=setOwnerPermission ? false : true%>"
206              image="take_ownership.png"
207              onclick="setOwner()" 
208              title="Set owner&hellip;"
209              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
210            />
211            <tbl:button 
212              image="import.gif" 
213              onclick="runPlugin('ImportItem')" 
214              title="Import&hellip;" 
215              tooltip="Import data" 
216              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
217            />
218            <tbl:button 
219              image="export.gif" 
220              onclick="runPlugin('ExportItem')" 
221              title="Export&hellip;" 
222              tooltip="Export data" 
223              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
224            />
225            <tbl:button 
226              image="runplugin.gif" 
227              onclick="runPlugin('RunPlugin')" 
228              title="Run plugin&hellip;" 
229              tooltip="Run a plugin" 
230              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
231            />
232            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
233              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
234            <tbl:button
235              image="help.png"
236              onclick="<%="Main.openHelp('" + ID +"', 'permissiontemplate.view.properties')"%>"
237              title="Help&hellip;"
238              tooltip="Get help about this page"
239            /> 
240          </tbl:toolbar>
241        </td>
242      </tr>
243      <tr>
244        <th>Name</th>
245        <td><%=HTML.encodeTags(template.getName())%></td>
246      </tr>
247      <tr>
248        <th>Owner</th>
249        <td><base:propertyvalue item="<%=template%>" property="owner"/></td>
250      </tr>
251      <tr>
252        <th>Permissions</th>
253        <td><%=PermissionUtil.getFullPermissionNames(template)%></td>
254      </tr>
255      <tr>
256        <th>Description</th>
257        <td><%=HTML.niceFormat(template.getDescription())%></td>
258      </tr>
259      </table>
260      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
261        <jsp:param name="ID" value="<%=ID%>" />
262        <jsp:param name="item_type" value="<%=itemType.name()%>" />
263        <jsp:param name="item_id" value="<%=itemId%>" />
264        <jsp:param name="title" value="Other items related to this template" />
265      </jsp:include>
266      <jsp:include page="../../common/share/list_share.jsp">
267        <jsp:param name="ID" value="<%=ID%>" />
268        <jsp:param name="item_type" value="<%=itemType.name()%>" />
269        <jsp:param name="item_id" value="<%=itemId%>" />
270        <jsp:param name="title" value="Shared to" />
271      </jsp:include>
272    </t:tab>
273    </t:tabcontrol>
274
275  </base:body>
276  </base:page>
277  <%
278}
279finally
280{
281  if (dc != null) dc.close();
282}
283
284%>
Note: See TracBrowser for help on using the repository browser.