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