source: trunk/www/admin/clients/view_client.jsp @ 4889

Last change on this file since 4889 was 4889, checked in by Nicklas Nordborg, 13 years ago

References #1290: Change source files to UTF-8

Changed 'Hakkinen' to 'Häkkinen'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.5 KB
Line 
1<%-- $Id: view_client.jsp 4889 2009-04-06 12:52:39Z 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 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.ItemResultIterator"
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, 150);
130    }
131    function runPlugin(cmd)
132    {
133      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
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>
154    <p:path>
155      <p:pathelement title="Client applications" href="<%="index.jsp?ID="+ID%>" />
156      <p:pathelement title="<%=HTML.encodeTags(client.getName())%>" />
157    </p:path>
158   
159    <t:tabcontrol id="main" active="properties" switch="switchTab">
160    <t:tab id="properties" title="Properties">
161   
162    <tbl:toolbar
163      >
164      <tbl:button 
165        disabled="<%=writePermission ? false : true%>" 
166        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
167        onclick="editItem()" 
168        title="Edit&hellip;" 
169        tooltip="<%=writePermission ? "Edit this client application" : "You do not have permission to edit this client application"%>" 
170      />
171      <tbl:button 
172        disabled="<%=deletePermission ? false : true%>" 
173        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
174        onclick="deleteItem()" 
175        title="Delete"
176        visible="<%=!client.isRemoved()%>"
177        tooltip="<%=deletePermission ? "Delete this client application" : "You do not have permission to delete this client application"%>" 
178      />
179      <tbl:button 
180        disabled="<%=writePermission ? false : true%>" 
181        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
182        onclick="restoreItem()" 
183        title="Restore"
184        visible="<%=client.isRemoved()%>"
185        tooltip="<%=writePermission ? "Restore this client application" : "You do not have permission to restore this client application"%>" 
186      />
187      <tbl:button 
188        disabled="<%=sharePermission ? false : true%>"
189        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
190        onclick="shareItem()" 
191        title="Share&hellip;" 
192        tooltip="<%=sharePermission ? "Share this client application to other user, groups and projects" : "You do not have permission to share this client application"%>"
193      />
194      <tbl:button 
195        disabled="<%=setOwnerPermission ? false : true%>"
196        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
197        onclick="setOwner()" 
198        title="Set owner&hellip;"
199        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
200      />
201      <tbl:button 
202        image="import.gif" 
203        onclick="runPlugin('ImportItem')" 
204        title="Import&hellip;" 
205        tooltip="Import data" 
206        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
207      />
208      <tbl:button 
209        image="export.gif" 
210        onclick="runPlugin('ExportItem')" 
211        title="Export&hellip;" 
212        tooltip="Export data" 
213        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
214      />
215      <tbl:button 
216        image="runplugin.gif" 
217        onclick="runPlugin('RunPlugin')" 
218        title="Run plugin&hellip;" 
219        tooltip="Run a plugin" 
220        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
221      />
222      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
223        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
224      <tbl:button
225        image="help.gif"
226        onclick="<%="Main.openHelp('" + ID +"', 'client.view.properties')"%>"
227        title="Help&hellip;"
228        tooltip="Get help about this page"
229      />
230      </tbl:toolbar>
231    <div class="boxedbottom">
232      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(client)%></i></div>
233      <%
234      if (client.isRemoved() || client.isShared())
235      {
236        %>
237        <div class="itemstatus">
238          <base:icon 
239            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
240            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
241            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
242            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
243          <base:icon image="used.gif" 
244            onclick="showUsingItems()"
245            tooltip="Show the items that are using this one"
246            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
247          <base:icon image="shared.gif" 
248            visible="<%=client.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
249        </div>
250        <%
251      }
252      %>
253      <table class="form" cellspacing="0">
254      <tr>
255        <td class="prompt">Name</td>
256        <td><%=HTML.encodeTags(client.getName())%></td>
257      </tr>
258      <tr>
259        <td class="prompt">Registered</td>
260        <td><%=dateFormatter.format(client.getEntryDate())%></td>
261      </tr>
262      <tr>
263        <td class="prompt">External ID</td>
264        <td><%=HTML.encodeTags(client.getExternalId())%></td>
265      </tr>
266      <tr>
267        <td class="prompt">Owner</td>
268        <td><base:propertyvalue item="<%=client%>" property="owner" /></td>
269      </tr>
270      <tr>
271        <td class="prompt">Description</td>
272        <td><%=HTML.niceFormat(client.getDescription())%></td>
273      </tr>
274      </table>
275      <%
276      // Tables with users/groups/projects that this item is shared to
277      MultiPermissions mp = new MultiPermissions(Collections.singleton(client));
278      ItemResultIterator<User> users = mp.getUsers().iterate(dc);
279      ItemResultIterator<Group> groups = mp.getGroups().iterate(dc);
280      ItemResultIterator<Project> projects = mp.getProjects().iterate(dc);
281     
282      if (users.hasNext() || groups.hasNext() || projects.hasNext())
283      {
284        %>
285        <h4 class="docked">Shared to</h4>
286        <tbl:table 
287          id="itemsSharedTo"
288          clazz="itemlist"
289          columns="all"
290        >
291          <tbl:columndef 
292            id="itemType"
293            title="Item type"
294          />
295          <tbl:columndef 
296            id="name"
297            title="Name"
298          />
299          <tbl:columndef 
300            id="permissions"
301            title="Permissions"
302          />
303          <tbl:data>
304            <tbl:columns>
305            </tbl:columns>
306            <tbl:rows>
307            <%
308            while(projects.hasNext())
309            {
310              Project project = projects.next();
311              Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
312              %>     
313              <tbl:row>
314                <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
315                <tbl:cell column="name"><base:icon 
316                  image="deleted.gif" 
317                  tooltip="This item has been scheduled for deletion" 
318                  visible="<%=project.isRemoved()%>"
319                /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
320                <tbl:cell column="permissions">
321                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
322                </tbl:cell>
323              </tbl:row>
324              <%
325            }
326            while(groups.hasNext())
327            {
328              Group group = groups.next();
329              Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
330              %>
331              <tbl:row>             
332                <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
333                <tbl:cell column="name"><base:icon 
334                  image="deleted.gif" 
335                  tooltip="This item has been scheduled for deletion" 
336                  visible="<%=group.isRemoved()%>"
337                /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
338                <tbl:cell column="permissions">
339                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
340                </tbl:cell>
341              </tbl:row>
342              <% 
343            }
344            while (users.hasNext())
345            {
346              User user = users.next();
347              Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
348              %>
349              <tbl:row>             
350                <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
351                <tbl:cell column="name"><base:icon 
352                  image="deleted.gif" 
353                  tooltip="This item has been scheduled for deletion" 
354                  visible="<%=user.isRemoved()%>"
355                /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
356                <tbl:cell column="permissions">
357                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
358                </tbl:cell>
359              </tbl:row>
360              <%
361            }
362            %>
363            </tbl:rows>
364          </tbl:data>
365        </tbl:table>
366        <%
367      }
368      else
369      {
370        %>
371        <h4>Shared to</h4>
372        This client is not shared
373        (or, you don't have permission to view the ones it is shared to).
374        <%
375      }
376      %>
377     
378    </div>
379      </t:tab>
380     
381      <t:tab id="help" title="Help texts" 
382        tooltip="View and manage help texts for this client application" />
383      </t:tabcontrol>
384
385
386  </base:body>
387  </base:page>
388  <%
389}
390finally
391{
392  if (dc != null) dc.close();
393}
394
395%>
Note: See TracBrowser for help on using the repository browser.