source: trunk/www/admin/clients/view_client.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 Date Id
File size: 10.8 KB
Line 
1<%-- $Id: view_client.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.Client"
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.CLIENT;
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  Client client = Client.getById(dc, itemId);
82 
83  final boolean writePermission = client.hasPermission(Permission.WRITE);
84  final boolean deletePermission = client.hasPermission(Permission.DELETE);
85  final boolean sharePermission = client.hasPermission(Permission.SET_PERMISSION);
86  final boolean setOwnerPermission = client.hasPermission(Permission.SET_OWNER);
87  final boolean isOwner = client.isOwner();
88  final boolean isRemoved = client.isRemoved();
89  final boolean isUsed = isRemoved && client.isUsed();
90  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
91  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, client);
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%>', 'ShareClient', 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    function viewHelp()
136    {
137      location.href = 'help/index.jsp?ID=<%=ID%>&cmd=List&client_id=<%=itemId%>';
138    }
139    function switchTab(tabControlId, tabId)
140    {
141      if (tabId == 'help')
142      {
143        viewHelp();
144      }
145      else
146      {
147        TabControl.setActiveTab(tabControlId, tabId);
148      }
149    }
150    </script>
151  </base:head>
152  <base:body>
153    <p:path><p:pathelement
154      title="Client applications" href="<%="index.jsp?ID="+ID%>" 
155      /><p:pathelement title="<%=HTML.encodeTags(client.getName())%>"
156      /></p:path>
157   
158    <t:tabcontrol 
159      id="main" 
160      subclass="content mastertabcontrol" 
161      active="properties" switch="switchTab">
162    <t:tab id="properties" title="Properties">
163      <div>
164      <table class="fullform bottomborder">
165      <tr>
166        <th class="itemstatus">
167          <base:icon 
168            image="shared.gif" 
169            visible="<%=client.isShared()%>"
170            tooltip="This item is shared to other users, groups and/or projects"
171          />
172          <base:icon 
173            image="deleted.gif"
174            onclick="deleteItemPermanently()"
175            tooltip="This item has been flagged for deletion. Click to delete it now."
176            enabled="<%=deletePermanentlyPermission %>"
177            visible="<%=isRemoved%>" 
178          />
179          <base:icon image="used.gif" 
180            onclick="showUsingItems()"
181            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
182            visible="<%=isRemoved && isUsed%>" />
183        </th>
184        <td style="padding: 0px;">
185          <tbl:toolbar subclass="bottomborder">
186            <tbl:button 
187              disabled="<%=writePermission ? false : true%>" 
188              image="edit.gif" 
189              onclick="editItem()" 
190              title="Edit&hellip;" 
191              tooltip="<%=writePermission ? "Edit this client application" : "You do not have permission to edit this client application"%>" 
192            />
193            <tbl:button 
194              disabled="<%=deletePermission ? false : true%>" 
195              image="delete.gif" 
196              onclick="deleteItem()" 
197              title="Delete"
198              visible="<%=!client.isRemoved()%>"
199              tooltip="<%=deletePermission ? "Delete this client application" : "You do not have permission to delete this client application"%>" 
200            />
201            <tbl:button 
202              disabled="<%=writePermission ? false : true%>" 
203              image="restore.gif" 
204              onclick="restoreItem()" 
205              title="Restore"
206              visible="<%=client.isRemoved()%>"
207              tooltip="<%=writePermission ? "Restore this client application" : "You do not have permission to restore this client application"%>" 
208            />
209            <tbl:button 
210              disabled="<%=sharePermission ? false : true%>"
211              image="share.gif"
212              onclick="shareItem()" 
213              title="Share&hellip;" 
214              tooltip="<%=sharePermission ? "Share this client application to other user, groups and projects" : "You do not have permission to share this client application"%>"
215            />
216            <tbl:button 
217              disabled="<%=setOwnerPermission ? false : true%>"
218              image="take_ownership.png"
219              onclick="setOwner()" 
220              title="Set owner&hellip;"
221              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
222            />
223            <tbl:button 
224              image="import.gif" 
225              onclick="runPlugin('ImportItem')" 
226              title="Import&hellip;" 
227              tooltip="Import data" 
228              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
229            />
230            <tbl:button 
231              image="export.gif" 
232              onclick="runPlugin('ExportItem')" 
233              title="Export&hellip;" 
234              tooltip="Export data" 
235              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
236            />
237            <tbl:button 
238              image="runplugin.gif" 
239              onclick="runPlugin('RunPlugin')" 
240              title="Run plugin&hellip;" 
241              tooltip="Run a plugin" 
242              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
243            />
244            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
245              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
246            <tbl:button
247              image="help.png"
248              onclick="<%="Main.openHelp('" + ID +"', 'client.view.properties')"%>"
249              title="Help&hellip;"
250              tooltip="Get help about this page"
251            />
252          </tbl:toolbar>
253        </td>
254      </tr>
255      <tr>
256        <th>Name</th>
257        <td><%=HTML.encodeTags(client.getName())%></td>
258      </tr>
259      <tr>
260        <th>Registered</th>
261        <td><%=dateFormatter.format(client.getEntryDate())%></td>
262      </tr>
263      <tr>
264        <th>External ID</th>
265        <td><%=HTML.encodeTags(client.getExternalId())%></td>
266      </tr>
267      <tr>
268        <th>Owner</th>
269        <td><base:propertyvalue item="<%=client%>" property="owner" /></td>
270      </tr>
271      <tr>
272        <th>Permissions</th>
273        <td><%=PermissionUtil.getFullPermissionNames(client)%></td>
274      </tr>
275      <tr>
276        <th>Description</th>
277        <td><%=HTML.niceFormat(client.getDescription())%></td>
278      </tr>
279      </table>
280      </div>
281     
282      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
283        <jsp:param name="ID" value="<%=ID%>" />
284        <jsp:param name="item_type" value="<%=itemType.name()%>" />
285        <jsp:param name="item_id" value="<%=itemId%>" />
286        <jsp:param name="title" value="Other items related to this client application" />
287      </jsp:include>
288      <jsp:include page="../../common/share/list_share.jsp">
289        <jsp:param name="ID" value="<%=ID%>" />
290        <jsp:param name="item_type" value="<%=itemType.name()%>" />
291        <jsp:param name="item_id" value="<%=itemId%>" />
292        <jsp:param name="title" value="Shared to" />
293      </jsp:include>
294    </t:tab>
295     
296    <t:tab id="help" title="Help texts" 
297      tooltip="View and manage help texts for this client application" />
298    </t:tabcontrol>
299  </base:body>
300  </base:page>
301  <%
302}
303finally
304{
305  if (dc != null) dc.close();
306}
307
308%>
Note: See TracBrowser for help on using the repository browser.