Changeset 1106


Ignore:
Timestamp:
Jun 2, 2009, 9:34:10 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

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.

Location:
extensions/net.sf.basedb.genepattern/trunk
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.genepattern/trunk/build.xml

    r1104 r1106  
    2323  <property name="javac.target" value="1.5" />
    2424  <property name="javac.encoding" value="UTF-8" />
    25   <property name="depend.jars" value="http://base2.thep.lu.se/base/jars/2.12.1" />
     25  <property name="depend.jars" value="http://base2.thep.lu.se/base/jars/2.12.0" />
    2626  <property name="genepattern.jars" value="http://genepattern.broad.mit.edu/gp/downloads" />
    2727
  • extensions/net.sf.basedb.genepattern/trunk/resources/edit_server.jsp

    r1104 r1106  
    5757%>
    5858<base:page type="popup" title="<%=HTML.encodeTags(title)%>">
    59 <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
     59<base:head scripts="ajax.js">
    6060  <script language="JavaScript">
    6161  function validate()
     
    8989    url += '&login=' + encodeURIComponent(frm.gpLogin.value);
    9090    url += '&password=' + encodeURIComponent(frm.gpPassword.value);
    91     Main.openPopup(url, 'TestGPServer', 700, 500);
     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...';
    9297  }
     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 
    93119  </script>
    94120</base:head>
    95121<base:body>
    96122  <form action="submit.jsp?ID=<%=ID%>" method="post" name="options" onsubmit="return false;">
    97   <input type=hidden name="cmd" value="SaveServer">
    98  
     123  <input type="hidden" name="cmd" value="SaveServer">
     124  <input type="hidden" name="originalGpServer" value="<%=HTML.encodeTags(server.getName())%>">
     125
    99126  <h3 class="docked"><%=HTML.encodeTags(title)%></h3>
    100127  <div class="boxedbottom">
     
    102129    <tr>
    103130      <td class="prompt">Server URL</td>
    104       <td><input class="text required" type="text" name="gpServer" size="40"
     131      <td colspan="2"><input class="text required" type="text" name="gpServer" size="50"
    105132          value="<%=HTML.encodeTags(server.getName())%>"></td>
    106133    </tr>
    107134    <tr>
    108135      <td class="prompt">Login</td>
    109       <td><input class="text required" type="text" name="gpLogin" size="40"
     136      <td colspan="2"><input class="text required" type="text" name="gpLogin" size="50"
    110137          value="<%=HTML.encodeTags(server.getSetting("server.login"))%>"></td>
    111138    </tr>
    112139    <tr>
    113140      <td class="prompt">Password</td>
    114       <td><input class="text" type="password" name="gpPassword" size="20"
    115           value="<%=HTML.encodeTags(server.getSetting("server.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>
    116156    </tr>
    117157    </table>
     
    120160  <table align="center">
    121161  <tr>
    122     <td width="33%"><base:button onclick="testServer();" title="Test"
    123       image="<%=homeUrl + "/images/genepattern.gif" %>"
    124       onclick="testServer()" /></td>
    125     <td width="33%"><base:button onclick="saveSettings();" title="Save" /></td>
    126     <td width="33%"><base:button onclick="window.close();" title="Cancel" /></td>
     162    <td width="50%"><base:button onclick="saveSettings();" title="Save" /></td>
     163    <td width="50%"><base:button onclick="window.close();" title="Cancel" /></td>
    127164  </tr>
    128165  </table>
  • extensions/net.sf.basedb.genepattern/trunk/resources/options.jsp

    r1102 r1106  
    6767  function addServer()
    6868  {
    69     Main.openPopup('edit_server.jsp?ID=<%=ID%>&gpServer=', 'EditGPServer', 500, 300);
     69    Main.openPopup('edit_server.jsp?ID=<%=ID%>&gpServer=', 'EditGPServer', 600, 400);
    7070  }
    7171  function editServer()
     
    7878    }
    7979    var gpServer = frm.servers[frm.servers.selectedIndex].text;
    80     Main.openPopup('edit_server.jsp?ID=<%=ID%>&gpServer=' + encodeURIComponent(gpServer), 'EditGPServer', 500, 300);
     80    Main.openPopup('edit_server.jsp?ID=<%=ID%>&gpServer=' + encodeURIComponent(gpServer), 'EditGPServer', 600, 400);
    8181  }
    8282  function removeServer()
     
    110110      <select name="servers" multiple="multiple" size="10" style="width: 25em;">
    111111      <%
     112      String selected = "selected";
    112113      for (Presets.Preset server : presets)
    113114      {
    114115        %>
    115         <option><%=HTML.encodeTags(server.getName())%>
     116        <option <%=selected%>><%=HTML.encodeTags(server.getName())%>
    116117        <%
     118        selected = "";
    117119      }
    118120      %>
  • extensions/net.sf.basedb.genepattern/trunk/resources/submit.jsp

    r1102 r1106  
    5353    Presets presets = new Presets();
    5454    if (presetsXml != null) presets.loadFrom(presetsXml);
     55    String originalGpServer = request.getParameter("originalGpServer");
    5556    String gpServer = request.getParameter("gpServer");
    5657    Preset server = presets.getPreset(gpServer);
     58    if ("".equals(originalGpServer))
     59    {
     60      // Adding a new server - check if one already exists
     61      if (server.getSetting("server.login") != null)
     62      {
     63        throw new WebException("popup", "Server exists", "The server {1} already exists", gpServer);
     64      }
     65    }
     66    else if (!gpServer.equals(originalGpServer))
     67    {
     68      // The URL of an existing server has been modified
     69      presets.deletePreset(originalGpServer);
     70    }
    5771    server.setSetting("server.login", request.getParameter("gpLogin"));
    5872    server.setSetting("server.password", request.getParameter("gpPassword"));
    5973    sc.setUserClientSetting("net.sf.basedb.genepattern.options", presets.asXml());
    60     message = gpServer + " stored ok";
     74    message = gpServer + " saved";
    6175  }
    6276  else if ("RemoveServer".equals(cmd))
  • extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/servlet/TestServer.java

    r1104 r1106  
    2424package net.sf.basedb.genepattern.servlet;
    2525
    26 import javax.servlet.RequestDispatcher;
    2726import javax.servlet.ServletConfig;
    2827import javax.servlet.ServletException;
     
    3231
    3332import net.sf.basedb.util.Values;
     33import net.sf.basedb.util.error.ThrowableUtil;
    3434
    3535import org.genepattern.client.GPClient;
     
    7979    String login = request.getParameter("login");
    8080    String password = Values.getStringOrNull(request.getParameter("password"));
     81    String result = "ok";
    8182    try
    8283    {
     
    9495    catch (WebServiceException ex)
    9596    {
    96       request.setAttribute("exception", ex);
     97      result = ThrowableUtil.stackTraceToString(ex);
    9798    }
    98     RequestDispatcher forward = request.getRequestDispatcher("server_test.jsp");
    99     forward.forward(request, response);
     99    response.getWriter().print(result);
    100100  }
    101101
Note: See TracChangeset for help on using the changeset viewer.