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

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

References #221: Configure GenePattern? server

Changed the AJAX calls to a new servlet. Now requires BASE 2.13 since that depends on new functionality in BASE.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.0 KB
Line 
1<%-- $Id: edit_server.jsp 1117 2009-06-10 11:13:21Z 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.getUserDefaultSetting("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%>/Ajax.servlet?cmd=TestLogin';
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    setTimeout('testResult(null)', 15000);
98    setTimeout('showProgress()', 250);
99  }
100  function showProgress()
101  {
102    var progress = document.getElementById('testReport');
103    if (progress.innerHTML.indexOf('Please wait') == 0)
104    {
105      progress.innerHTML += ' .';
106      setTimeout('showProgress()', 250);
107    }
108  }
109
110  function testResult(request)
111  {
112    if (document.getElementById('testReport').innerHTML.indexOf('Please wait') != 0) return;
113    var frm = document.forms['options'];
114    var responseText = request != null ? request.responseText : 'status:error\nstacktrace:No response from server';
115    var response = Ajax.parseResponse(responseText);
116    var testStatus;
117    var testReport;
118    if (response.isError())
119    {
120      testStatus = 'Test failed';
121      var stacktrace = response.getElements()[0]['stacktrace'];
122      testReport = '<div class="error stacktrace" style="width: 420px; height: 15em; overflow: auto;">' + stacktrace + '</div>';
123    }
124    else
125    {
126      testStatus = 'Test result';
127      testReport = 'Test of <b>' + frm.gpServer.value + '</b> was successful';
128    }
129    document.getElementById('testStatus').innerHTML = testStatus;
130    document.getElementById('testReport').innerHTML = testReport;
131  }
132  </script>
133</base:head>
134<base:body>
135  <form action="submit.jsp?ID=<%=ID%>" method="post" name="options" onsubmit="return false;">
136  <input type="hidden" name="cmd" value="SaveServer">
137  <input type="hidden" name="originalGpServer" value="<%=HTML.encodeTags(server.getName())%>">
138
139  <h3 class="docked"><%=HTML.encodeTags(title)%></h3>
140  <div class="boxedbottom">
141    <table class="form" cellspacing="0" width="100%">
142    <tr>
143      <td class="prompt">Server URL</td>
144      <td><input class="text required" type="text" name="gpServer" size="50"
145          value="<%=HTML.encodeTags(server.getName())%>"></td>
146    </tr>
147    <tr>
148      <td class="prompt">Login</td>
149      <td><input class="text required" type="text" name="gpLogin" size="50"
150          value="<%=HTML.encodeTags(server.getSetting("server.login"))%>"></td>
151    </tr>
152    <tr>
153      <td class="prompt">Password</td>
154      <td><input class="text" type="password" name="gpPassword" size="30"
155          value="<%=HTML.encodeTags(server.getSetting("server.password"))%>">
156      </td>
157    </tr>
158    <tr>
159      <td class="prompt" id="testStatus"></td>
160      <td id="testReport">
161      </td>
162    </tr>
163    </table>
164  </div>
165  </form>
166  <p>
167  <table align="center">
168  <tr>
169    <td width="33%"><base:button onclick="testServer();" title="Test" 
170      image="<%=homeUrl + "/images/genepattern.gif" %>" /></td>
171    <td width="33%"><base:button onclick="saveSettings();" title="Save" /></td>
172    <td width="33%"><base:button onclick="window.close();" title="Cancel" /></td>
173  </tr>
174  </table>
175</base:body>
176</base:page>
Note: See TracBrowser for help on using the repository browser.