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