source: extensions/net.sf.basedb.genepattern/trunk/resources/edit_server.jsp @ 1106

Last change on this file since 1106 was 1106, checked in by Nicklas Nordborg, 14 years ago

Fixes #224: Add a "Test" button on the GenePattern? 'edit server' page

Now using Ajax to do the test which means that we don't need to 'forward' from the servlet and we only need BASE 2.12.0.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.5 KB
Line 
1<%-- $Id: edit_server.jsp 1106 2009-06-02 07:34:10Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25--%>
26<%@ page
27  pageEncoding="UTF-8"
28  session="false"
29  import="net.sf.basedb.core.Application"
30  import="net.sf.basedb.core.BioAssaySet"
31  import="net.sf.basedb.core.Experiment"
32  import="net.sf.basedb.core.Directory"
33  import="net.sf.basedb.core.User"
34  import="net.sf.basedb.core.DbControl"
35  import="net.sf.basedb.core.SessionControl"
36  import="net.sf.basedb.core.Path"
37  import="net.sf.basedb.core.Presets"
38  import="net.sf.basedb.core.Presets.Preset"
39  import="net.sf.basedb.clients.web.Base"
40  import="net.sf.basedb.clients.web.util.HTML"
41  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
42  import="net.sf.basedb.util.Values"
43%>
44<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
45<%
46final SessionControl sc = Base.getExistingSessionControl(request, true);
47final String ID = sc.getId();
48final float scale = Base.getScale(sc);
49final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.genepattern.options");
50
51final String gpServer = Values.getStringOrNull(request.getParameter("gpServer"));
52String presetsXml = sc.getUserClientSetting("net.sf.basedb.genepattern.options");
53Presets presets = new Presets();
54if (presetsXml != null) presets.loadFrom(presetsXml);
55Preset server = gpServer == null ? presets.getDefault() : presets.getPreset(gpServer);
56String title = "Options for " + (gpServer == null ? "new" : gpServer);
57%>
58<base:page type="popup" title="<%=HTML.encodeTags(title)%>">
59<base:head scripts="ajax.js">
60  <script language="JavaScript">
61  function validate()
62  {
63    var frm = document.forms['options'];
64    if (frm.gpServer.value == '')
65    {
66      alert('A server URL must be specified');
67      frm.gpServer.focus();
68      return false;
69    }
70    else if (frm.gpLogin.value == '')
71    {
72      alert('A login must be specified');
73      frm.gpServer.focus();
74      return false;
75    }
76    return true;
77  }
78
79  function saveSettings()
80  {
81    if (validate()) document.forms['options'].submit();
82  }
83  function testServer()
84  {
85    if (!validate()) return;
86    var frm = document.forms['options'];
87    var url = '<%=homeUrl%>/TestServer.servlet';
88    url += '?server=' + encodeURIComponent(frm.gpServer.value);
89    url += '&login=' + encodeURIComponent(frm.gpLogin.value);
90    url += '&password=' + encodeURIComponent(frm.gpPassword.value);
91    var request = Ajax.getXmlHttpRequest();
92    request.open("GET", url, true);
93    Ajax.setReadyStateHandler(request, testResult);
94    request.send(null);
95    document.getElementById('testStatus').innerHTML = 'Testing';
96    document.getElementById('testReport').innerHTML = 'Please wait...';
97  }
98
99  function testResult(request)
100  {
101    var frm = document.forms['options'];
102    var response = request.responseText; //.split('\n');
103    var testStatus;
104    var testReport;
105    if (response == 'ok')
106    {
107      testStatus = 'Test result';
108      testReport = 'Test of <b>' + frm.gpServer.value + '</b> was successful';
109    }
110    else
111    {
112      testStatus = 'Test failed';
113      testReport = '<div class="error stacktrace" style="width: 420px; height: 15em; overflow: auto;">' + response + '</div>';
114    }
115    document.getElementById('testStatus').innerHTML = testStatus;
116    document.getElementById('testReport').innerHTML = testReport;
117  }
118 
119  </script>
120</base:head>
121<base:body>
122  <form action="submit.jsp?ID=<%=ID%>" method="post" name="options" onsubmit="return false;">
123  <input type="hidden" name="cmd" value="SaveServer">
124  <input type="hidden" name="originalGpServer" value="<%=HTML.encodeTags(server.getName())%>">
125
126  <h3 class="docked"><%=HTML.encodeTags(title)%></h3>
127  <div class="boxedbottom">
128    <table class="form" cellspacing=0>
129    <tr>
130      <td class="prompt">Server URL</td>
131      <td colspan="2"><input class="text required" type="text" name="gpServer" size="50"
132          value="<%=HTML.encodeTags(server.getName())%>"></td>
133    </tr>
134    <tr>
135      <td class="prompt">Login</td>
136      <td colspan="2"><input class="text required" type="text" name="gpLogin" size="50"
137          value="<%=HTML.encodeTags(server.getSetting("server.login"))%>"></td>
138    </tr>
139    <tr>
140      <td class="prompt">Password</td>
141      <td><input class="text" type="password" name="gpPassword" size="30"
142          value="<%=HTML.encodeTags(server.getSetting("server.password"))%>">
143      </td>
144      <td>
145        <table border=0 cellspacing=0 cellpadding=0 align="right"><tr><td>
146        <base:button onclick="testServer();" title="Test" 
147        image="<%=homeUrl + "/images/genepattern.gif" %>" 
148        onclick="testServer()" />
149        </td></tr></table>
150      </td>
151    </tr>
152    <tr>
153      <td class="prompt" id="testStatus"></td>
154      <td colspan="2" id="testReport">
155      </td>
156    </tr>
157    </table>
158  </div>
159  <p>
160  <table align="center">
161  <tr>
162    <td width="50%"><base:button onclick="saveSettings();" title="Save" /></td>
163    <td width="50%"><base:button onclick="window.close();" title="Cancel" /></td>
164  </tr>
165  </table>
166</base:body>
167</base:page>
Note: See TracBrowser for help on using the repository browser.