source: extensions/net.sf.basedb.genepattern/trunk/resources/run_visualizer.jsp @ 1134

Last change on this file since 1134 was 1134, checked in by Nicklas Nordborg, 12 years ago

References #234: Proof-of-concept: run a selected GenePattern? visualization module from BASE

The process is now a bit more generic. In theory it should be possible to run any visualizer module. Got rid of hard-coded urls to servers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.5 KB
Line 
1<%-- $Id: run_visualizer.jsp 1134 2009-06-22 12:00:26Z 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.SessionControl"
30  import="net.sf.basedb.core.Presets"
31  import="net.sf.basedb.core.Presets.Preset"
32  import="net.sf.basedb.clients.web.Base"
33  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
34  import="net.sf.basedb.clients.web.util.HTML"
35%>
36<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
37<%
38final SessionControl sc = Base.getExistingSessionControl(request, true);
39final String ID = sc.getId();
40
41String presetsXml = sc.getUserDefaultSetting("net.sf.basedb.genepattern.options");
42Presets presets = new Presets();
43if (presetsXml != null) presets.loadFrom(presetsXml);
44final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.genepattern.options");
45%>
46<base:page type="popup" title="">
47<base:head scripts="ajax.js">
48  <script language="JavaScript">
49  function doVisualize()
50  {
51    var frm = document.forms['visualizer'];
52    frm.submit();
53  }
54  function getModuleList()
55  {
56    var frm = document.forms['visualizer'];
57    var url = '<%=homeUrl%>/Ajax.servlet?ID=<%=ID%>&cmd=ListModules';
58    url += '&server=' + encodeURIComponent(frm['server'].value);
59    var request = Ajax.getXmlHttpRequest();
60    request.open("GET", url, true);
61    Ajax.setReadyStateHandler(request, getModulesListCallback);
62    request.send(null);
63    document.getElementById('ajaxStatus').innerHTML = 'Please wait. . .';
64    setTimeout('showProgress()', 250);
65  }
66  function showProgress()
67  {
68    var progress = document.getElementById('ajaxStatus');
69    if (progress.innerHTML.indexOf('Please wait') == 0)
70    {
71      progress.innerHTML += ' .';
72      setTimeout('showProgress()', 250);
73    }
74  }
75
76  function getModulesListCallback(request)
77  {
78    if (document.getElementById('ajaxStatus').innerHTML.indexOf('Please wait') != 0) return;
79    var frm = document.forms['visualizer'];
80    var responseText = request != null ?
81      request.responseText :
82      'status:error\nstacktrace:No response from server';
83    var response = Ajax.parseResponse(responseText);
84    if (response.isError())
85    {
86      var stacktrace = response.getElements()[0]['stacktrace'];
87      document.getElementById('ajaxStatus').innerHTML =
88        '<div class="error stacktrace" style="width: 420px; height: 15em; overflow: auto;">' + stacktrace + '</div>';
89    }
90    else
91    {
92      var modules = response.getElements();
93      modules.sort(compareGpModules);
94      var html = '<div style="width: 420px; height: 15em; overflow: auto;">';
95      for (var i = 0; i < modules.length; i++)
96      {
97        var type = modules[i]['taskType'];
98        if (type == 'Visualizer')
99        {
100          html += '<a id="module.' + i + '" href="javascript:setModule('+i+')" title="' + modules[i]['description'] + '">';
101          html += modules[i]['name'] + '</a><br>';
102        }
103      }
104      html += '</div>';
105      document.getElementById('ajaxStatus').innerHTML = html;
106    }
107  }
108  function compareGpModules(m1, m2)
109  {
110    var type1 = m1['taskType'];
111    var type2 = m2['taskType'];
112    if (type1 < type2) return -1;
113    if (type1 > type2) return 1;
114    var name1 = m1['name'];
115    var name2 = m2['name'];
116    if (name1 < name2) return -1;
117    if (name1 > name2) return 1;
118    return 0;
119  }
120  function setModule(index)
121  {
122    var frm = document.forms['visualizer'];
123    frm['module'].value = document.getElementById('module.'+index).innerHTML;
124  }
125  </script>
126</base:head>
127<base:body>
128 
129  <form action="Visualizer.servlet" method="post" name="visualizer">
130  <input type="hidden" name="ID" value="<%=ID%>">
131  <input type="hidden" name="cmd" value="SelectServerModule">
132 
133  <h3 class="docked">Run visualizer</h3>
134  <div class="boxedbottom">
135    <table class="form" cellspacing=0>
136    <tr>
137      <td></td>
138      <td>Select a GenePattern visualizer module.</td>
139    </tr>
140    <tr>
141      <td class="prompt">GenePattern server</td>
142      <td>
143      <select name="server" class="required">
144      <%
145      for (Presets.Preset server : presets)
146      {
147        %>
148        <option><%=HTML.encodeTags(server.getName())%>
149        <%
150      }
151      %>
152      </select>
153      </td>
154    </tr>
155    <tr>
156      <td class="prompt">Visualizer module</td>
157      <td>
158        <input class="text required" type="text" name="module" size="40" value="">
159      </td>
160    </tr>
161    <tr>
162      <td class="prompt">Available modules</td>
163      <td>
164      <table border=0 cellspacing=0><tr><td><base:button 
165          title="Get list" onclick="getModuleList()"
166          image="<%=homeUrl + "/images/genepattern.gif" %>"
167          /></td>
168        </tr></table>
169      </td>
170    </tr>
171    <tr>
172      <td class="prompt"></td>
173      <td id="ajaxStatus"></td>
174    </tr>
175    </table>
176    </div>
177
178
179    </form>
180    <table align="center">
181    <tr>
182      <td width="50%"><base:button onclick="doVisualize();" title="Next" /></td>
183      <td width="50%"><base:button onclick="window.close();" title="Cancel" /></td>
184    </tr>
185    </table>
186
187</base:body>
188</base:page>
Note: See TracBrowser for help on using the repository browser.