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

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

References #2097: Implement support for device verification

Added a "User-Agent" analyzer library (https://github.com/nielsbasjes/yauaa). It is used to automatically generate the name of new devices. For example: Firefox 55 on Windows 10.0 (Desktop)

Added UserDeviceData.lastRemoteId property to store the ip address of the device the last time it was used.

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