1 | <%-- $Id $ |
---|
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 import="net.sf.basedb.util.HttpUtil"%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.SessionControl" |
---|
27 | import="net.sf.basedb.core.DbControl" |
---|
28 | import="net.sf.basedb.core.Item" |
---|
29 | import="net.sf.basedb.core.Type" |
---|
30 | import="net.sf.basedb.core.ItemContext" |
---|
31 | import="net.sf.basedb.core.Permission" |
---|
32 | import="net.sf.basedb.core.UserDevice" |
---|
33 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
34 | import="net.sf.basedb.util.Values" |
---|
35 | import="net.sf.basedb.clients.web.Base" |
---|
36 | import="net.sf.basedb.clients.web.util.HTML" |
---|
37 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
38 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
39 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
40 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
41 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
42 | import="java.util.List" |
---|
43 | %> |
---|
44 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
45 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
46 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
47 | <% |
---|
48 | final Item itemType = Item.USERDEVICE; |
---|
49 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
50 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
51 | final int itemId = cc.getId(); |
---|
52 | final String ID = sc.getId(); |
---|
53 | final float scale = Base.getScale(sc); |
---|
54 | final DbControl dc = sc.newDbControl(); |
---|
55 | try |
---|
56 | { |
---|
57 | if (itemId == 0) |
---|
58 | { |
---|
59 | throw new PermissionDeniedException(Permission.CREATE, "device"); |
---|
60 | } |
---|
61 | UserDevice device = UserDevice.getById(dc, itemId); |
---|
62 | device.checkPermission(Permission.WRITE); |
---|
63 | cc.setObject("item", device); |
---|
64 | String title = "Edit device -- " + HTML.encodeTags(device.getName()); |
---|
65 | String summary = HTML.encodeTags(HttpUtil.getSummaryOfUserAgent(device.getUserAgent())); |
---|
66 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), device); |
---|
67 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
68 | %> |
---|
69 | <base:page type="popup" title="<%=title%>" id="edit-page"> |
---|
70 | <base:head scripts="tabcontrol-2.js,~devices.js" styles="tabcontrol.css"> |
---|
71 | <ext:scripts context="<%=jspContext%>" /> |
---|
72 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
73 | </base:head> |
---|
74 | <base:body > |
---|
75 | <h1><%=title%> <base:help tabcontrol="settings" /></h1> |
---|
76 | <form action="index.jsp?ID=<%=ID%>" method="post" name="device"> |
---|
77 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
78 | |
---|
79 | <t:tabcontrol id="settings" |
---|
80 | subclass="content dialogtabcontrol" |
---|
81 | position="bottom" remember="<%=device != null%>" |
---|
82 | extensions="<%=invoker%>"> |
---|
83 | <t:tab id="info" title="Device" helpid="device.edit"> |
---|
84 | <table class="fullform input100"> |
---|
85 | <tr> |
---|
86 | <th>Name</th> |
---|
87 | <td><input class="text required auto-init" data-auto-init="focus" |
---|
88 | type="text" name="name" |
---|
89 | value="<%=HTML.encodeTags(device.getName())%>" |
---|
90 | maxlength="<%=UserDevice.MAX_NAME_LENGTH%>"></td> |
---|
91 | <td></td> |
---|
92 | </tr> |
---|
93 | <tr> |
---|
94 | <th class="subprompt">User-agent</th> |
---|
95 | <td> |
---|
96 | <span title="<%=HTML.encodeTags(device.getUserAgent())%>"><%=summary %></span> |
---|
97 | [<span id="use-user-agent" class="link" title="Use this as the name" data-summary="<%=summary%>">copy</span>] |
---|
98 | </td> |
---|
99 | <td></td> |
---|
100 | </tr> |
---|
101 | <tr class="dynamic"> |
---|
102 | <th>Description</th> |
---|
103 | <td> |
---|
104 | <textarea class="text" rows="4" name="description" id="description" |
---|
105 | ><%=HTML.encodeTags(device.getDescription())%></textarea> |
---|
106 | </td> |
---|
107 | <td style="width: 20px;"> |
---|
108 | <base:zoom textarea="description" title="Description" /> |
---|
109 | </td> |
---|
110 | </tr> |
---|
111 | </table> |
---|
112 | </t:tab> |
---|
113 | </t:tabcontrol> |
---|
114 | </form> |
---|
115 | |
---|
116 | <div class="legend"> |
---|
117 | <base:icon image="required.png" />= required information |
---|
118 | </div> |
---|
119 | |
---|
120 | <base:buttongroup subclass="dialogbuttons"> |
---|
121 | <base:button id="btnSave" title="Save" /> |
---|
122 | <base:button id="close" title="Cancel" /> |
---|
123 | </base:buttongroup> |
---|
124 | </base:body> |
---|
125 | </base:page> |
---|
126 | <% |
---|
127 | } |
---|
128 | finally |
---|
129 | { |
---|
130 | if (dc != null) dc.close(); |
---|
131 | } |
---|
132 | %> |
---|