1 | <%-- $Id: list_sessions.jsp 6703 2015-02-02 09:52:20Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | Copyright (C) 2007 Johan Enell |
---|
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.Item" |
---|
30 | import="net.sf.basedb.core.Session" |
---|
31 | import="net.sf.basedb.core.User" |
---|
32 | import="net.sf.basedb.core.ItemQuery" |
---|
33 | import="net.sf.basedb.core.Include" |
---|
34 | import="net.sf.basedb.core.ItemResultIterator" |
---|
35 | import="net.sf.basedb.core.ItemResultList" |
---|
36 | import="net.sf.basedb.core.ItemContext" |
---|
37 | import="net.sf.basedb.core.Permission" |
---|
38 | import="net.sf.basedb.core.PluginDefinition" |
---|
39 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
40 | import="net.sf.basedb.core.query.Hql" |
---|
41 | import="net.sf.basedb.core.query.Restrictions" |
---|
42 | import="net.sf.basedb.core.query.Expressions" |
---|
43 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
44 | import="net.sf.basedb.core.plugin.Plugin" |
---|
45 | import="net.sf.basedb.util.Enumeration" |
---|
46 | import="net.sf.basedb.clients.web.Base" |
---|
47 | import="net.sf.basedb.clients.web.ModeInfo" |
---|
48 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
49 | import="net.sf.basedb.clients.web.util.HTML" |
---|
50 | import="net.sf.basedb.util.Values" |
---|
51 | import="net.sf.basedb.util.formatter.Formatter" |
---|
52 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
53 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
54 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
55 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
56 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
57 | import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
---|
58 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
59 | import="java.util.List" |
---|
60 | import="java.util.Map" |
---|
61 | import="java.util.Date" |
---|
62 | %> |
---|
63 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
64 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
65 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
66 | <%! |
---|
67 | private static final Item itemType = Item.SESSION; |
---|
68 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST); |
---|
69 | %> |
---|
70 | <% |
---|
71 | final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType); |
---|
72 | final String ID = sc.getId(); |
---|
73 | final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType); |
---|
74 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
75 | |
---|
76 | final ModeInfo mode = ModeInfo.get(request.getParameter("mode")); |
---|
77 | final String callback = request.getParameter("callback"); |
---|
78 | final String title = mode.generateTitle("session", "sessions"); |
---|
79 | final DbControl dc = sc.newDbControl(); |
---|
80 | ItemResultIterator<Session> sessions = null; |
---|
81 | try |
---|
82 | { |
---|
83 | final User user = cc.getInclude().contains(Include.OTHERS) ? |
---|
84 | null : User.getById(dc, sc.getLoggedInUserId()); |
---|
85 | |
---|
86 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
87 | try |
---|
88 | { |
---|
89 | final ItemQuery<Session> query = Base.getConfiguredQuery(dc, cc, true, Session.getQuery(user), mode); |
---|
90 | sessions = query.iterate(dc); |
---|
91 | } |
---|
92 | catch (Throwable t) |
---|
93 | { |
---|
94 | cc.setMessage(t.getMessage()); |
---|
95 | } |
---|
96 | int numListed = 0; |
---|
97 | Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
98 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null); |
---|
99 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
100 | ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext); |
---|
101 | %> |
---|
102 | <base:page title="<%=title==null ? "Sessions" : title%>" type="<%=mode.getPageType()%>" id="list-page"> |
---|
103 | <base:head scripts="table.js,~sessions.js" styles="table.css,toolbar.css"> |
---|
104 | <ext:scripts context="<%=jspContext%>" /> |
---|
105 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
106 | </base:head> |
---|
107 | |
---|
108 | <base:body> |
---|
109 | <h1><%=title==null ? "Sessions" : title%></h1> |
---|
110 | <div class="content"> |
---|
111 | <tbl:table |
---|
112 | id="sessions" |
---|
113 | columns="<%=cc.getSetting("columns")%>" |
---|
114 | sortby="<%=cc.getSortProperty()%>" |
---|
115 | direction="<%=cc.getSortDirection()%>" |
---|
116 | action="index.jsp" |
---|
117 | sc="<%=sc%>" |
---|
118 | item="<%=itemType%>" |
---|
119 | filterrows="<%=cc.getFilterRows()%>" |
---|
120 | subclass="fulltable" |
---|
121 | > |
---|
122 | <tbl:hidden |
---|
123 | name="mode" |
---|
124 | value="<%=mode.getName()%>" |
---|
125 | /> |
---|
126 | <tbl:hidden |
---|
127 | name="callback" |
---|
128 | value="<%=callback%>" |
---|
129 | skip="<%=callback == null%>" |
---|
130 | /> |
---|
131 | <tbl:columndef |
---|
132 | id="id" |
---|
133 | clazz="uniquecol" |
---|
134 | property="id" |
---|
135 | datatype="int" |
---|
136 | title="ID" |
---|
137 | sortable="true" |
---|
138 | filterable="true" |
---|
139 | exportable="true" |
---|
140 | /> |
---|
141 | <tbl:columndef |
---|
142 | id="loginTime" |
---|
143 | property="loginTime" |
---|
144 | datatype="timestamp" |
---|
145 | title="Login time" |
---|
146 | sortable="true" |
---|
147 | filterable="true" |
---|
148 | exportable="true" |
---|
149 | show="always" |
---|
150 | /> |
---|
151 | <tbl:columndef |
---|
152 | id="logoutTime" |
---|
153 | property="logoutTime" |
---|
154 | datatype="timestamp" |
---|
155 | title="Logout time" |
---|
156 | sortable="true" |
---|
157 | filterable="true" |
---|
158 | exportable="true" |
---|
159 | formatter="<%=dateTimeFormatter%>" |
---|
160 | /> |
---|
161 | <tbl:columndef |
---|
162 | id="impersonated" |
---|
163 | property="impersonated" |
---|
164 | datatype="boolean" |
---|
165 | title="Impersonated" |
---|
166 | sortable="true" |
---|
167 | filterable="true" |
---|
168 | exportable="true" |
---|
169 | /> |
---|
170 | <tbl:columndef |
---|
171 | id="client" |
---|
172 | property="client.name" |
---|
173 | datatype="string" |
---|
174 | title="Client application" |
---|
175 | sortable="true" |
---|
176 | filterable="true" |
---|
177 | exportable="true" |
---|
178 | /> |
---|
179 | <tbl:columndef |
---|
180 | id="remoteId" |
---|
181 | property="remoteId" |
---|
182 | datatype="string" |
---|
183 | title="Remote ID" |
---|
184 | sortable="true" |
---|
185 | filterable="true" |
---|
186 | exportable="true" |
---|
187 | /> |
---|
188 | <tbl:columndef |
---|
189 | id="comment" |
---|
190 | property="loginComment" |
---|
191 | datatype="string" |
---|
192 | title="Comment" |
---|
193 | sortable="true" |
---|
194 | filterable="true" |
---|
195 | exportable="true" |
---|
196 | /> |
---|
197 | <tbl:columndef |
---|
198 | id="user" |
---|
199 | property="user.name" |
---|
200 | datatype="string" |
---|
201 | title="User" |
---|
202 | sortable="true" |
---|
203 | filterable="true" |
---|
204 | exportable="true" |
---|
205 | /> |
---|
206 | <tbl:columndef |
---|
207 | id="permission" |
---|
208 | title="Permission" |
---|
209 | /> |
---|
210 | <tbl:columndef |
---|
211 | id="xt-columns" |
---|
212 | extensions="<%=columnsInvoker%>" |
---|
213 | jspcontext="<%=jspContext%>" |
---|
214 | /> |
---|
215 | <div class="panelgroup bg-filled-50 bottomborder"> |
---|
216 | <tbl:toolbar |
---|
217 | subclass="bottomborder" |
---|
218 | visible="<%=mode.hasToolbar()%>" |
---|
219 | > |
---|
220 | <tbl:button |
---|
221 | id="btnColumns" |
---|
222 | image="columns.png" |
---|
223 | title="Columns…" |
---|
224 | tooltip="Show, hide and re-order columns" |
---|
225 | /> |
---|
226 | <tbl:button |
---|
227 | id="btnExport" |
---|
228 | data-plugin-type="EXPORT" |
---|
229 | image="export.png" |
---|
230 | title="Export…" |
---|
231 | tooltip="Export data" |
---|
232 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
233 | /> |
---|
234 | <tbl:button |
---|
235 | id="btnRunPlugin" |
---|
236 | data-plugin-type="OTHER" |
---|
237 | image="runplugin.png" |
---|
238 | title="Run plugin…" |
---|
239 | tooltip="Run a plugin" |
---|
240 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
241 | /> |
---|
242 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
243 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
244 | </tbl:toolbar> |
---|
245 | <tbl:panel> |
---|
246 | <tbl:presetselector /> |
---|
247 | <tbl:navigator |
---|
248 | page="<%=cc.getPage()%>" |
---|
249 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
250 | totalrows="<%=sessions == null ? 0 : sessions.getTotalCount()%>" |
---|
251 | visible="<%=mode.hasNavigator()%>" |
---|
252 | /> |
---|
253 | </tbl:panel> |
---|
254 | </div> |
---|
255 | <tbl:data> |
---|
256 | <tbl:headers> |
---|
257 | <tbl:headerrow> |
---|
258 | <tbl:header colspan="3" /> |
---|
259 | <tbl:columnheaders /> |
---|
260 | </tbl:headerrow> |
---|
261 | <% |
---|
262 | int numFilters = cc.getNumPropertyFilters(); |
---|
263 | int numRows = cc.getFilterRows(); |
---|
264 | for (int filterNo = 0; filterNo < numRows; filterNo++) |
---|
265 | { |
---|
266 | boolean lastRow = filterNo == numRows-1; |
---|
267 | %> |
---|
268 | <tbl:headerrow> |
---|
269 | <tbl:header subclass="index" /> |
---|
270 | <tbl:header |
---|
271 | subclass="check" |
---|
272 | visible="<%=mode.hasCheck()%>" |
---|
273 | ><base:icon |
---|
274 | id="check.uncheck" |
---|
275 | image="check_uncheck.png" |
---|
276 | tooltip="Check/uncheck all" |
---|
277 | visible="<%=lastRow%>" |
---|
278 | /></tbl:header> |
---|
279 | <tbl:header |
---|
280 | subclass="check" |
---|
281 | visible="<%=mode.hasRadio()%>" |
---|
282 | /> |
---|
283 | <tbl:header |
---|
284 | subclass="icons" |
---|
285 | visible="<%=mode.hasIcons()%>" |
---|
286 | > |
---|
287 | <base:icon |
---|
288 | subclass="link table-filter-row-action" |
---|
289 | image="add.png" |
---|
290 | tooltip="Add extra filter row" |
---|
291 | visible="<%=lastRow%>" |
---|
292 | /><base:icon |
---|
293 | subclass="link table-filter-row-action" |
---|
294 | image="remove.png" |
---|
295 | tooltip="Remove this filter row" |
---|
296 | visible="<%=numRows > 1 || numFilters > 0 %>" |
---|
297 | data-remove-row="<%=filterNo%>" |
---|
298 | /> |
---|
299 | </tbl:header> |
---|
300 | <tbl:propertyfilter row="<%=filterNo%>" /> |
---|
301 | </tbl:headerrow> |
---|
302 | <% |
---|
303 | } |
---|
304 | %> |
---|
305 | </tbl:headers> |
---|
306 | <tbl:rows> |
---|
307 | <% |
---|
308 | if (cc.getMessage() != null) |
---|
309 | { |
---|
310 | %> |
---|
311 | <tbl:panel subclass="bg-filled-50"> |
---|
312 | <div class="messagecontainer error"><%=cc.getMessage()%></div> |
---|
313 | </tbl:panel> |
---|
314 | <% |
---|
315 | cc.setMessage(null); |
---|
316 | } |
---|
317 | int index = cc.getPage()*cc.getRowsPerPage(); |
---|
318 | int selectedItemId = cc.getId(); |
---|
319 | if (sessions != null) |
---|
320 | { |
---|
321 | String tooltip = mode.isSelectionMode() ? |
---|
322 | "Select this item" : "View this item"; |
---|
323 | while (sessions.hasNext()) |
---|
324 | { |
---|
325 | Session item = sessions.next(); |
---|
326 | int itemId = item.getId(); |
---|
327 | String name = "TODO"; |
---|
328 | index++; |
---|
329 | numListed++; |
---|
330 | %> |
---|
331 | <tbl:row> |
---|
332 | <tbl:header |
---|
333 | clazz="index" |
---|
334 | ><%=index%></tbl:header> |
---|
335 | <tbl:header |
---|
336 | clazz="check" |
---|
337 | visible="<%=mode.hasCheck()%>" |
---|
338 | ><input |
---|
339 | type="checkbox" |
---|
340 | name="<%=itemId%>" |
---|
341 | value="<%=itemId%>" |
---|
342 | title="<%=name%>" |
---|
343 | <%=cc.getSelected().contains(itemId) ? "checked" : ""%> |
---|
344 | ></tbl:header> |
---|
345 | <tbl:header |
---|
346 | clazz="check" |
---|
347 | visible="<%=mode.hasRadio()%>" |
---|
348 | ><input |
---|
349 | type="radio" |
---|
350 | name="item_id" |
---|
351 | value="<%=itemId%>" |
---|
352 | title="<%=name%>" |
---|
353 | <%=selectedItemId == itemId ? "checked" : ""%> |
---|
354 | ></tbl:header> |
---|
355 | <tbl:header |
---|
356 | clazz="icons" |
---|
357 | visible="<%=mode.hasIcons()%>" |
---|
358 | > </tbl:header> |
---|
359 | <tbl:cell column="id"><%=item.getId()%></tbl:cell> |
---|
360 | <tbl:cell column="loginTime"><div |
---|
361 | class="link table-item" |
---|
362 | data-item-id="<%=itemId%>" |
---|
363 | data-no-edit="1" |
---|
364 | tabindex="0" |
---|
365 | title="<%=tooltip%>"><%=dateTimeFormatter.format(item.getLoginTime())%></div></tbl:cell> |
---|
366 | <tbl:cell column="logoutTime" value="<%=item.getLogoutTime()%>" /> |
---|
367 | <tbl:cell column="impersonated"><%=item.getImpersonated()%></tbl:cell> |
---|
368 | <tbl:cell column="remoteId"><%=HTML.encodeTags(item.getRemoteId())%></tbl:cell> |
---|
369 | <tbl:cell column="comment"><%=HTML.encodeTags(item.getLoginComment())%></tbl:cell> |
---|
370 | <tbl:cell column="user" |
---|
371 | ><base:propertyvalue |
---|
372 | item="<%=item%>" |
---|
373 | property="user" |
---|
374 | enableEditLink="<%=mode.hasEditLink()%>" |
---|
375 | enablePropertyLink="<%=mode.hasPropertyLink()%>" |
---|
376 | /></tbl:cell> |
---|
377 | <tbl:cell column="client" |
---|
378 | ><base:propertyvalue |
---|
379 | item="<%=item%>" |
---|
380 | property="client" |
---|
381 | enableEditLink="<%=mode.hasEditLink()%>" |
---|
382 | enablePropertyLink="<%=mode.hasPropertyLink()%>" |
---|
383 | /></tbl:cell> |
---|
384 | <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell> |
---|
385 | <tbl:xt-cells dc="<%=dc%>" item="<%=item%>"> |
---|
386 | <tbl:cell column="xt-columns" /> |
---|
387 | </tbl:xt-cells> |
---|
388 | </tbl:row> |
---|
389 | <% |
---|
390 | } |
---|
391 | } |
---|
392 | if (numListed == 0) |
---|
393 | { |
---|
394 | %> |
---|
395 | <tbl:panel subclass="bg-filled-50"> |
---|
396 | <div class="messagecontainer note"> |
---|
397 | <%=sessions == null || sessions.getTotalCount() == 0 ? "No sessions were found" : "No sessions on this page. Please select another page!" %> |
---|
398 | </div> |
---|
399 | </tbl:panel> |
---|
400 | <% |
---|
401 | } |
---|
402 | %> |
---|
403 | </tbl:rows> |
---|
404 | </tbl:data> |
---|
405 | </tbl:table> |
---|
406 | </div> |
---|
407 | |
---|
408 | <base:buttongroup subclass="dialogbuttons"> |
---|
409 | <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" /> |
---|
410 | <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" /> |
---|
411 | <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" /> |
---|
412 | </base:buttongroup> |
---|
413 | |
---|
414 | </base:body> |
---|
415 | </base:page> |
---|
416 | <% |
---|
417 | } |
---|
418 | finally |
---|
419 | { |
---|
420 | if (sessions != null) sessions.close(); |
---|
421 | if (dc != null) dc.close(); |
---|
422 | } |
---|
423 | %> |
---|