source: trunk/www/views/devices/view_device.jsp @ 7407

Last change on this file since 7407 was 7407, checked in by Nicklas Nordborg, 5 years ago

References #2097: Implement support for device verification

Added list/view/edit pages to the web client for devices.

File size: 6.8 KB
Line 
1<%-- $Id7 $
2  ------------------------------------------------------------------
3  Copyright (C) 2017 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.Item"
28  import="net.sf.basedb.core.ItemContext"
29  import="net.sf.basedb.core.Permission"
30  import="net.sf.basedb.core.UserDevice"
31  import="net.sf.basedb.core.PermissionDeniedException"
32  import="net.sf.basedb.core.PluginDefinition"
33  import="net.sf.basedb.core.plugin.GuiContext"
34  import="net.sf.basedb.core.plugin.Plugin"
35  import="net.sf.basedb.core.Project"
36  import="net.sf.basedb.util.Values"
37  import="net.sf.basedb.clients.web.Base"
38  import="net.sf.basedb.clients.web.PermissionUtil"
39  import="net.sf.basedb.clients.web.util.HTML"
40  import="net.sf.basedb.util.formatter.Formatter"
41  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
42  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
43  import="net.sf.basedb.clients.web.extensions.JspContext"
44  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
45  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
46  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
47  import="java.util.Date"
48  import="java.util.Collections"
49  import="java.util.List"
50  import="java.util.Map"
51  import="java.util.Set"
52%>
53<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
54<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
55<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
56<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
57<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
58<%!
59  private static final Item itemType = Item.USERDEVICE;
60  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
61%>
62<%
63final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
64final String ID = sc.getId();
65final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
66final int itemId = cc.getId();
67final String tab = Values.getString(request.getParameter("tab"), "properties");
68final float scale = Base.getScale(sc);
69final DbControl dc = sc.newDbControl();
70try
71{
72  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
73  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
74  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
75
76  String title = null;
77  final UserDevice device = UserDevice.getById(dc, itemId);
78 
79  final boolean writePermission = device.hasPermission(Permission.WRITE);
80  final boolean deletePermission = device.hasPermission(Permission.DELETE);
81  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, device);
82  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
83  %>
84  <base:page title="<%=title%>" id="view-page">
85  <base:head scripts="table.js,tabcontrol-2.js,~devices.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
86    <ext:scripts context="<%=jspContext%>" />
87    <ext:stylesheets context="<%=jspContext%>" />
88  </base:head>
89  <base:body>
90    <p:path><p:pathelement
91      title="Devices" href="<%="index.jsp?ID="+ID%>" 
92      /><p:pathelement title="<%=HTML.encodeTags(device.getName())%>"
93      /></p:path>
94    <div id="page-data" data-item-id="<%=itemId%>"></div>
95   
96    <t:tabcontrol 
97      id="main" 
98      subclass="content mastertabcontrol" 
99      active="<%=tab%>">
100    <t:tab id="properties" title="Properties">
101      <div>
102      <table class="fullform bottomborder">
103      <tr>
104        <th class="itemstatus">
105        </th>
106        <td style="padding: 0px;">
107          <tbl:toolbar subclass="bottomborder bg-filled-50">
108            <tbl:button 
109              id="btnEdit"
110              disabled="<%=!writePermission%>" 
111              image="edit.png" 
112              title="Edit&hellip;" 
113              tooltip="<%=writePermission ? "Edit this device" : "You do not have permission to edit this device"%>" 
114            />
115            <tbl:button 
116              id="btnDelete"
117              disabled="<%=!deletePermission%>" 
118              image="delete.png" 
119              title="Delete"
120              tooltip="<%=deletePermission ? "Delete this device" : "You do not have permission to delete this device"%>" 
121            />
122            <tbl:button 
123              id="btnExport"
124              image="export.png"
125              data-plugin-type="EXPORT" 
126              title="Export&hellip;" 
127              tooltip="Export data" 
128              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
129            />
130            <tbl:button 
131              id="btnRunPlugin"
132              image="runplugin.png" 
133              data-plugin-type="OTHER" 
134              title="Run plugin&hellip;" 
135              tooltip="Run a plugin" 
136              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
137            />
138            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
139              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
140            <tbl:button
141              image="help.png"
142              subclass="auto-init"
143              data-auto-init="help"
144              data-help-id="device.view.properties"
145              title="Help&hellip;"
146              tooltip="Get help about this page"
147            />
148          </tbl:toolbar>
149        </td>
150      </tr>
151      <tr>
152        <th>Name</th>
153        <td><%=HTML.encodeTags(device.getName())%></td>
154      </tr>
155      <tr>
156        <th>Registered</th>
157        <td><%=dateFormatter.format(device.getEntryDate())%></td>
158      </tr>
159      <tr>
160        <th>Last used</th>
161        <td><%=dateTimeFormatter.format(device.getLastUsed())%></td>
162      </tr>
163      <tr>
164        <th>User</th>
165        <td><base:propertyvalue item="<%=device%>" property="user" /></td>
166      </tr>
167      <tr>
168        <th>Client application</th>
169        <td><base:propertyvalue item="<%=device%>" property="client" /></td>
170      </tr>
171      <tr>
172        <th>User agent</th>
173        <td><%=HTML.niceFormat(device.getUserAgent())%></td>
174      </tr>
175      <tr>
176        <th>Permissions</th>
177        <td><%=PermissionUtil.getFullPermissionNames(device)%></td>
178      </tr>
179      <tr>
180        <th>Description</th>
181        <td><%=HTML.niceFormat(device.getDescription())%></td>
182      </tr>
183      </table>
184      </div>
185    </t:tab>
186    </t:tabcontrol>
187
188  </base:body>
189  </base:page>
190  <%
191}
192finally
193{
194  if (dc != null) dc.close();
195}
196
197%>
Note: See TracBrowser for help on using the repository browser.