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

Last change on this file since 5941 was 5941, checked in by Nicklas Nordborg, 10 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 Id
File size: 10.5 KB
Line 
1<%-- $Id: view_hardware.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 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 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  Hardware hardware = Hardware.getById(dc, itemId);
82 
83  final boolean writePermission = hardware.hasPermission(Permission.WRITE);
84  final boolean deletePermission = hardware.hasPermission(Permission.DELETE);
85  final boolean sharePermission = hardware.hasPermission(Permission.SET_PERMISSION);
86  final boolean setOwnerPermission = hardware.hasPermission(Permission.SET_OWNER);
87  final boolean isOwner = hardware.isOwner();
88  final boolean isRemoved = hardware.isRemoved();
89  final boolean isUsed = isRemoved && hardware.isUsed();
90  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
91  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, hardware);
92  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
93  %>
94  <base:page title="<%=title%>">
95  <base:head scripts="table,js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
96    <ext:scripts context="<%=jspContext%>" />
97    <ext:stylesheets context="<%=jspContext%>" />
98    <script language="JavaScript">
99    function editItem()
100    {
101      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
102    }
103    function shareItem()
104    {
105      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareHardware', 600, 400);
106    }
107    function deleteItem()
108    {
109      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
110    }
111    function restoreItem()
112    {
113      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
114    }
115    function deleteItemPermanently()
116    {
117      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
118    }
119    function itemDeleted()
120    {
121      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
122    }
123    function showUsingItems()
124    {
125      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
126    }
127    function setOwner()
128    {
129      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
130    }
131    function runPlugin(cmd)
132    {
133      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
134    }
135    </script>
136  </base:head>
137  <base:body>
138    <p:path><p:pathelement
139      title="Hardware" href="<%="index.jsp?ID="+ID%>" 
140      /><p:pathelement title="<%=HTML.encodeTags(hardware.getName())%>" 
141      /></p:path>
142   
143    <t:tabcontrol 
144      id="main" 
145      subclass="content mastertabcontrol" 
146      active="properties">
147    <t:tab id="properties" title="Properties">
148      <div>
149      <table class="fullform bottomborder">
150      <tr>
151        <th class="itemstatus">
152          <base:icon 
153            image="shared.gif" 
154            visible="<%=hardware.isShared()%>"
155            tooltip="This item is shared to other users, groups and/or projects"
156          />
157          <base:icon 
158            image="deleted.gif"
159            onclick="deleteItemPermanently()"
160            tooltip="This item has been flagged for deletion. Click to delete it now."
161            enabled="<%=deletePermanentlyPermission %>"
162            visible="<%=isRemoved%>" 
163          />
164          <base:icon image="used.gif" 
165            onclick="showUsingItems()"
166            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
167            visible="<%=isRemoved && isUsed%>" />
168        </th>
169        <td style="padding: 0px;">
170          <tbl:toolbar subclass="bottomborder">
171            <tbl:button 
172              disabled="<%=writePermission ? false : true%>" 
173              image="edit.gif" 
174              onclick="editItem()" 
175              title="Edit&hellip;" 
176              tooltip="<%=writePermission ? "Edit this hardware" : "You do not have permission to edit this hardware"%>" 
177            />
178            <tbl:button 
179              disabled="<%=deletePermission ? false : true%>" 
180              image="delete.gif" 
181              onclick="deleteItem()" 
182              title="Delete"
183              visible="<%=!hardware.isRemoved()%>"
184              tooltip="<%=deletePermission ? "Delete this hardware" : "You do not have permission to delete this hardware"%>" 
185            />
186            <tbl:button 
187              disabled="<%=writePermission ? false : true%>" 
188              image="restore.gif" 
189              onclick="restoreItem()" 
190              title="Restore"
191              visible="<%=hardware.isRemoved()%>"
192              tooltip="<%=writePermission ? "Restore this hardware" : "You do not have permission to restore this hardware"%>" 
193            />
194            <tbl:button 
195              disabled="<%=sharePermission ? false : true%>"
196              image="share.gif"
197              onclick="shareItem()" 
198              title="Share&hellip;" 
199              tooltip="<%=sharePermission ? "Share this hardware to other user, groups and projects" : "You do not have permission to share this hardware"%>"
200            />
201            <tbl:button 
202              disabled="<%=setOwnerPermission ? false : true%>"
203              image="take_ownership.png"
204              onclick="setOwner()" 
205              title="Set owner&hellip;"
206              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
207            />
208            <tbl:button 
209              image="import.gif" 
210              onclick="runPlugin('ImportItem')" 
211              title="Import&hellip;" 
212              tooltip="Import data" 
213              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
214            />
215            <tbl:button 
216              image="export.gif" 
217              onclick="runPlugin('ExportItem')" 
218              title="Export&hellip;" 
219              tooltip="Export data" 
220              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
221            />
222            <tbl:button 
223              image="runplugin.gif" 
224              onclick="runPlugin('RunPlugin')" 
225              title="Run plugin&hellip;" 
226              tooltip="Run a plugin" 
227              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
228            />
229            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
230              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
231            <tbl:button
232              image="help.png"
233              onclick="<%="Main.openHelp('" + ID +"', 'hardware.view.properties')"%>"
234              title="Help&hellip;"
235              tooltip="Get help about this page"
236            />
237          </tbl:toolbar>
238        </td>
239      </tr>
240      <tr>
241        <th>Name</th>
242        <td><%=HTML.encodeTags(hardware.getName())%></td>
243      </tr>
244      <tr>
245        <th>Type</th>
246        <td><base:propertyvalue item="<%=hardware%>" property="itemSubtype" /></td>
247      </tr>
248      <tr>
249        <th>Registered</th>
250        <td><%=dateFormatter.format(hardware.getEntryDate())%></td>
251      </tr>
252      <tr>
253        <th>Version</th>
254        <td><%=HTML.encodeTags(hardware.getVersionString())%></td>
255      </tr>
256      <tr>
257        <th>Owner</th>
258        <td><base:propertyvalue item="<%=hardware%>" property="owner" /></td>
259      </tr>
260      <tr>
261        <th>Permissions</th>
262        <td><%=PermissionUtil.getFullPermissionNames(hardware)%></td>
263      </tr>
264      <tr>
265        <th>Description</th>
266        <td><%=HTML.niceFormat(hardware.getDescription())%></td>
267      </tr>
268      </table>
269      </div>
270      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
271        <jsp:param name="ID" value="<%=ID%>" />
272        <jsp:param name="item_type" value="<%=itemType.name()%>" />
273        <jsp:param name="item_id" value="<%=itemId%>" />
274        <jsp:param name="title" value="Other items related to this hardware" />
275      </jsp:include>
276      <jsp:include page="../../common/share/list_share.jsp">
277        <jsp:param name="ID" value="<%=ID%>" />
278        <jsp:param name="item_type" value="<%=itemType.name()%>" />
279        <jsp:param name="item_id" value="<%=itemId%>" />
280        <jsp:param name="title" value="Shared to" />
281      </jsp:include>
282    </t:tab>
283    </t:tabcontrol>
284  </base:body>
285  </base:page>
286  <%
287}
288finally
289{
290  if (dc != null) dc.close();
291}
292
293%>
Note: See TracBrowser for help on using the repository browser.