Changeset 6325


Ignore:
Timestamp:
Sep 16, 2013, 9:47:48 AM (9 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1770: Download immediately dialog should display status message

Location:
branches/3.2-stable/www/common/plugin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2-stable/www/common/plugin/download_immediately.jsp

    r5975 r6325  
    6262    function updateProgressWithAjax(request)
    6363    {
    64       var percent = request.responseText;
    65       displayProgress(percent);
    66       if (percent < 100)
     64      var progress = JSON.parse(request.responseText);
     65      var needMoreUpdate = true;
     66      if (progress && progress.status == 'ok')
     67      {
     68        displayProgress(progress);
     69        if (progress.percent >= 100) needMoreUpdate = false;
     70      }
     71      if (needMoreUpdate)
    6772      {
    6873        setTimeout('sendProgressUpdateWithAjax()', 1500);
     
    8186      return request != null;
    8287    }
    83     function displayProgress(percentDone)
    84     {   
     88    function displayProgress(progress)
     89    {
     90      var percentDone = progress.percent;
    8591      document.getElementById('percentText').innerHTML = percentDone+'%';
    8692      var doneElement = document.getElementById('percentDone');
     
    8894      var remainElement = document.getElementById('percentRemain');
    8995      remainElement.style.width = (100-percentDone)+'%';
     96      if (progress.message)
     97      {
     98        document.getElementById('message').innerHTML = progress.message;
     99      }
    90100      if (percentDone == 100)
    91101      {
     
    137147          </tr>
    138148          </table>
     149          <div id="message" style="font-style: italic;">Working...</div>
    139150        </div>
    140151   
  • branches/3.2-stable/www/common/plugin/progress.jsp

    r5426 r6325  
    2626  @version 2.8
    2727--%>
    28 <%@ page pageEncoding="UTF-8" session="false"
     28<%@ page pageEncoding="UTF-8" session="false" contentType="application/json"
    2929  import="net.sf.basedb.core.SessionControl"
    3030  import="net.sf.basedb.clients.web.Base"
    3131  import="net.sf.basedb.clients.web.util.SimpleSignalProgressReporter"
    3232  import="net.sf.basedb.util.Values"
    33  
     33  import="net.sf.basedb.util.error.ThrowableUtil"
     34  import="org.json.simple.JSONObject"
    3435%>
    3536<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    3637<%
    3738final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
    38 final boolean ajax = Values.getBoolean(request.getParameter("ajax"));
    39 
    40 SimpleSignalProgressReporter progress = (SimpleSignalProgressReporter)sc.getSessionSetting("plugin.configure.progress.reporter");
    41 //Return the progress value
    42 if (ajax && progress != null)
     39JSONObject json = new JSONObject();
     40json.put("status", "ok");
     41try
    4342{
    44   %><%=progress.getPercent()%><%
    45   if (progress.getPercent() == 100)
     43  SimpleSignalProgressReporter progress = (SimpleSignalProgressReporter)sc.getSessionSetting("plugin.configure.progress.reporter");
     44  //Return the progress information
     45  if (progress != null)
    4646  {
    47     sc.setSessionSetting("plugin.configure.progress.reporter", null);
     47    json.put("percent", progress.getPercent());
     48    json.put("message", progress.getMessage());
     49    if (progress.getPercent() == 100)
     50    {
     51      sc.setSessionSetting("plugin.configure.progress.reporter", null);
     52    }
    4853  }
    4954}
     55catch (Throwable t)
     56{
     57  t.printStackTrace();
     58  json.clear();
     59  json.put("status", "error");
     60  json.put("message", t.getMessage());
     61  json.put("stacktrace", ThrowableUtil.stackTraceToString(t));
     62}
     63finally
     64{
     65  json.writeJSONString(out);
     66  out.flush();
     67}
    5068%>
Note: See TracChangeset for help on using the changeset viewer.