Ignore:
Timestamp:
Jun 2, 2009, 9:34:10 AM (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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>
Note: See TracChangeset for help on using the changeset viewer.