source: trunk/www/admin/hardware/view_hardware.jsp @ 6328

Last change on this file since 6328 was 6328, checked in by olle, 9 years ago

Refs #1771. Support for annotatable Hardware items added.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.8 KB
Line 
1<%-- $Id: view_hardware.jsp 6328 2013-10-15 12:11:28Z olle $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Martin Svensson
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.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.ItemResultList"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.Hardware"
36  import="net.sf.basedb.core.User"
37  import="net.sf.basedb.core.MultiPermissions"
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.clients.web.Base"
44  import="net.sf.basedb.clients.web.PermissionUtil"
45  import="net.sf.basedb.clients.web.util.HTML"
46  import="net.sf.basedb.util.Values"
47  import="net.sf.basedb.util.formatter.Formatter"
48  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
49  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
50  import="net.sf.basedb.clients.web.extensions.JspContext"
51  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
52  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
53  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
54  import="java.util.Date"
55  import="java.util.Collections"
56  import="java.util.Map"
57  import="java.util.Set"
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.HARDWARE;
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 String tab = Values.getStringOrNull(request.getParameter("tab"));
74final float scale = Base.getScale(sc);
75final DbControl dc = sc.newDbControl();
76try
77{
78  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
79  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
80
81  String title = null;
82  Hardware hardware = Hardware.getById(dc, itemId);
83 
84  final boolean writePermission = hardware.hasPermission(Permission.WRITE);
85  final boolean deletePermission = hardware.hasPermission(Permission.DELETE);
86  final boolean sharePermission = hardware.hasPermission(Permission.SET_PERMISSION);
87  final boolean setOwnerPermission = hardware.hasPermission(Permission.SET_OWNER);
88  final boolean isOwner = hardware.isOwner();
89  final boolean isRemoved = hardware.isRemoved();
90  final boolean isUsed = isRemoved && hardware.isUsed();
91  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
92  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, hardware);
93  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
94  %>
95  <base:page title="<%=title%>" id="view-page">
96  <base:head scripts="table,js,tabcontrol-2.js,~hardware.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
97    <ext:scripts context="<%=jspContext%>" />
98    <ext:stylesheets context="<%=jspContext%>" />
99  </base:head>
100  <base:body>
101    <p:path><p:pathelement
102      title="Hardware" href="<%="index.jsp?ID="+ID%>" 
103      /><p:pathelement title="<%=HTML.encodeTags(hardware.getName())%>" 
104      /></p:path>
105    <div id="page-data" data-item-id="<%=itemId%>"></div>
106   
107    <t:tabcontrol 
108      id="main" 
109      subclass="content mastertabcontrol" 
110      active="<%=tab%>">
111    <t:tab id="properties" title="Properties">
112      <div>
113      <table class="fullform bottomborder">
114      <tr>
115        <th class="itemstatus">
116          <base:icon 
117            image="shared.png" 
118            visible="<%=hardware.isShared()%>"
119            tooltip="This item is shared to other users, groups and/or projects"
120          />
121          <base:icon 
122            id="btnDeletePermanently"
123            image="deleted.png"
124            tooltip="This item has been flagged for deletion. Click to delete it now."
125            enabled="<%=deletePermanentlyPermission %>"
126            visible="<%=isRemoved%>" 
127          />
128          <base:icon 
129            id="btnUsingItems"
130            image="used.png" 
131            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
132            visible="<%=isRemoved && isUsed%>" />
133        </th>
134        <td style="padding: 0px;">
135          <tbl:toolbar subclass="bottomborder">
136            <tbl:button 
137              id="btnEdit"
138              disabled="<%=!writePermission%>" 
139              image="edit.png" 
140              title="Edit&hellip;" 
141              tooltip="<%=writePermission ? "Edit this hardware" : "You do not have permission to edit this hardware"%>" 
142            />
143            <tbl:button 
144              id="btnDelete"
145              disabled="<%=!deletePermission%>" 
146              image="delete.png" 
147              title="Delete"
148              visible="<%=!hardware.isRemoved()%>"
149              tooltip="<%=deletePermission ? "Delete this hardware" : "You do not have permission to delete this hardware"%>" 
150            />
151            <tbl:button 
152              id="btnRestore"
153              disabled="<%=!writePermission%>" 
154              image="restore.png" 
155              title="Restore"
156              visible="<%=hardware.isRemoved()%>"
157              tooltip="<%=writePermission ? "Restore this hardware" : "You do not have permission to restore this hardware"%>" 
158            />
159            <tbl:button 
160              id="btnShare"
161              disabled="<%=!sharePermission%>"
162              image="share.png"
163              title="Share&hellip;" 
164              tooltip="<%=sharePermission ? "Share this hardware to other user, groups and projects" : "You do not have permission to share this hardware"%>"
165            />
166            <tbl:button 
167              id="btnSetOwner"
168              disabled="<%=!setOwnerPermission%>"
169              image="take_ownership.png"
170              title="Set owner&hellip;"
171              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
172            />
173            <tbl:button 
174              id="btnImport"
175              image="import.png" 
176              data-plugin-type="IMPORT" 
177              title="Import&hellip;" 
178              tooltip="Import data" 
179              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
180            />
181            <tbl:button 
182              id="btnExport"
183              image="export.png"
184              data-plugin-type="EXPORT" 
185              title="Export&hellip;" 
186              tooltip="Export data" 
187              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
188            />
189            <tbl:button 
190              id="btnRunPlugin"
191              image="runplugin.png" 
192              data-plugin-type="OTHER" 
193              title="Run plugin&hellip;" 
194              tooltip="Run a plugin" 
195              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
196            />
197            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
198              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
199            <tbl:button
200              image="help.png"
201              subclass="auto-init"
202              data-auto-init="help"
203              data-help-id="hardware.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(hardware.getName())%></td>
213      </tr>
214      <tr>
215        <th>Type</th>
216        <td><base:propertyvalue item="<%=hardware%>" property="itemSubtype" /></td>
217      </tr>
218      <tr>
219        <th>Registered</th>
220        <td><%=dateFormatter.format(hardware.getEntryDate())%></td>
221      </tr>
222      <tr>
223        <th>Version</th>
224        <td><%=HTML.encodeTags(hardware.getVersionString())%></td>
225      </tr>
226      <tr>
227        <th>Owner</th>
228        <td><base:propertyvalue item="<%=hardware%>" property="owner" /></td>
229      </tr>
230      <tr>
231        <th>Permissions</th>
232        <td><%=PermissionUtil.getFullPermissionNames(hardware)%></td>
233      </tr>
234      <tr>
235        <th>Description</th>
236        <td><%=HTML.niceFormat(hardware.getDescription())%></td>
237      </tr>
238      </table>
239      </div>
240      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
241        <jsp:param name="ID" value="<%=ID%>" />
242        <jsp:param name="item_type" value="<%=itemType.name()%>" />
243        <jsp:param name="item_id" value="<%=itemId%>" />
244        <jsp:param name="title" value="Other items related to this hardware" />
245      </jsp:include>
246      <jsp:include page="../../common/share/list_share.jsp">
247        <jsp:param name="ID" value="<%=ID%>" />
248        <jsp:param name="item_type" value="<%=itemType.name()%>" />
249        <jsp:param name="item_id" value="<%=itemId%>" />
250        <jsp:param name="title" value="Shared to" />
251      </jsp:include>
252    </t:tab>
253    <t:tab id="annotations" title="Annotations" 
254      tooltip="View annotation values" clazz="white">
255      <jsp:include page="../../common/annotations/list_frameset.jsp">
256        <jsp:param name="item_type" value="<%=itemType.name()%>" />
257        <jsp:param name="item_id" value="<%=itemId%>" />
258        <jsp:param name="ID" value="<%=ID%>" />
259      </jsp:include>
260    </t:tab>
261    </t:tabcontrol>
262  </base:body>
263  </base:page>
264  <%
265}
266finally
267{
268  if (dc != null) dc.close();
269}
270
271%>
Note: See TracBrowser for help on using the repository browser.