diff --git a/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java b/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java index 261cae5afa..dabe311883 100644 --- a/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java +++ b/apps/routerconsole/java/src/com/vuze/plugins/mlab/MLabRunner.java @@ -25,14 +25,10 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import com.vuze.plugins.mlab.tools.ndt.swingemu.Tcpbw100UIWrapper; -import com.vuze.plugins.mlab.tools.ndt.swingemu.Tcpbw100UIWrapperListener; - import edu.internet2.ndt.Tcpbw100; import net.minidev.json.JSONObject; @@ -102,41 +98,6 @@ public class MLabRunner { try{ _log.warn("Starting NDT Test"); - new Tcpbw100UIWrapper( - new Tcpbw100UIWrapperListener() - { - private LinkedList history = new LinkedList(); - - public void reportSummary(String str) { - str = str.trim(); - log(str); - if (listener != null){ - if (!str.startsWith("Click")) { - listener.reportSummary(str); - } - } - } - - public void reportDetail(String str) { - str = str.trim(); - log(str); - if (listener != null) { - listener.reportDetail(str); - } - } - - private void log(String str) { - synchronized( history ){ - if (history.size() > 0 && history.getLast().equals(str)) { - return; - } - history.add(str); - } - _log.warn(str); - } - - }); - // String host = "ndt.iupui.donar.measurement-lab.org"; // String host = "jlab4.jlab.org"; @@ -208,6 +169,10 @@ public class MLabRunner { public void cancelled() { test.killIt(); } + + public String getStatus() { + return test.getStatus(); + } }); test.runIt(); @@ -253,7 +218,7 @@ public class MLabRunner { results.put("server_city", server_city); if (server_country != null) results.put("server_country", server_country); - listener.complete( results ); + listener.complete(results); } if (_log.shouldWarn()) { long end = System.currentTimeMillis(); @@ -293,6 +258,7 @@ public class MLabRunner { public interface ToolRun { public void cancel(); public void addListener(ToolRunListener l); + public String getStatus(); } /** @@ -331,11 +297,18 @@ public class MLabRunner { } } } + + public String getStatus() { + synchronized(this) { + return listeners.isEmpty() ? "" : listeners.get(0).getStatus(); + } + } } /** The listener for ToolRun */ public interface ToolRunListener { public void cancelled(); + public String getStatus(); } /** The parameter for runNDT() */ diff --git a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/JTextArea.java b/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/JTextArea.java index dab6fb351d..98fd52c05c 100644 --- a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/JTextArea.java +++ b/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/JTextArea.java @@ -42,17 +42,6 @@ JTextArea append( String str ) { - Tcpbw100UIWrapperListener listener = Tcpbw100UIWrapper.current_adapter; - - if ( listener != null ){ - - listener.reportDetail( str ); - - }else{ - - //System.out.println( "text: " + str ); - } - text += str; } diff --git a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/StyledDocument.java b/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/StyledDocument.java index f1e69914c5..b16dd0cb49 100644 --- a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/StyledDocument.java +++ b/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/StyledDocument.java @@ -42,17 +42,6 @@ StyledDocument throws BadLocationException { - Tcpbw100UIWrapperListener listener = Tcpbw100UIWrapper.current_adapter; - - if ( listener != null ){ - - listener.reportSummary( s ); - - }else{ - - //System.out.println( "doc: " + s ); - } - str += s; } } diff --git a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/Tcpbw100UIWrapper.java b/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/Tcpbw100UIWrapper.java deleted file mode 100644 index 0127e667fc..0000000000 --- a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/Tcpbw100UIWrapper.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Created on May 20, 2010 - * Created by Paul Gardner - * - * Copyright 2010 Vuze, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details ( see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - - -package com.vuze.plugins.mlab.tools.ndt.swingemu; - -public class -Tcpbw100UIWrapper -{ - public static Tcpbw100UIWrapperListener current_adapter; - - public - Tcpbw100UIWrapper( - Tcpbw100UIWrapperListener adapter ) - { - current_adapter = adapter; - } -} diff --git a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/Tcpbw100UIWrapperListener.java b/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/Tcpbw100UIWrapperListener.java deleted file mode 100644 index 1888a59669..0000000000 --- a/apps/routerconsole/java/src/com/vuze/plugins/mlab/tools/ndt/swingemu/Tcpbw100UIWrapperListener.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Created on May 20, 2010 - * Created by Paul Gardner - * - * Copyright 2010 Vuze, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details ( see the LICENSE file ). - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - - -package com.vuze.plugins.mlab.tools.ndt.swingemu; - -public interface -Tcpbw100UIWrapperListener -{ - public void - reportSummary( - String str ); - - public void - reportDetail( - String str ); -} diff --git a/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java b/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java index f522eb7523..3a72930387 100644 --- a/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java +++ b/apps/routerconsole/java/src/edu/internet2/ndt/Tcpbw100.java @@ -293,6 +293,7 @@ public class Tcpbw100 extends JApplet implements ActionListener { private boolean retry = false; // I2P + private String _displayStatus = ""; private final Log _log = new Log(Tcpbw100.class); /** @@ -1279,7 +1280,18 @@ public class Tcpbw100 extends JApplet implements ActionListener { * @param msg String value of status * */ public void showStatus(String msg) { - _log.warn(msg); + synchronized(this) { + _displayStatus = msg; + } + _log.warn("NDT STATUS: " + msg); + } + + /** + * I2P + * Translated status, not HTML escaped. + */ + public synchronized String getStatus() { + return _displayStatus; } /** diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHandler.java index 0c4ae8de83..5ccc4ed3fd 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHandler.java @@ -136,7 +136,7 @@ public class WizardHandler extends FormHandler { if (_helper == null) { addFormError("Bad state for test"); } else if (_helper.cancelNDT()) { - addFormNotice(_t("Candelled bandwidth test")); + addFormNotice(_t("Cancelled bandwidth test")); } else { addFormError(_t("Bandwidth test was not running")); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHelper.java index b9ce0b25f2..833d75cfc5 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/WizardHelper.java @@ -55,6 +55,19 @@ public class WizardHelper extends HelperBase { return _listener != null && !_listener.isComplete(); } + /** + * @return HTML-escaped status string or "" + */ + public synchronized String getTestStatus() { + String rv = ""; + if (_runner != null) { + String s = _runner.getStatus(); + if (s != null) + rv = DataHelper.escapeHTML(s); + } + return rv; + } + /** * @return HTML-escaped status string or "" */ diff --git a/apps/routerconsole/jsp/index.jsp b/apps/routerconsole/jsp/index.jsp index bc2939e6cc..05a7640f32 100644 --- a/apps/routerconsole/jsp/index.jsp +++ b/apps/routerconsole/jsp/index.jsp @@ -27,7 +27,7 @@ boolean wizRun = ctx.getBooleanProperty(net.i2p.router.web.helpers.WizardHelper.PROP_COMPLETE); String firstVersion = ctx.getProperty("router.firstVersion"); String tgt; - final boolean ENABLE_WIZARD_ON_FIRST_RUN = false; + final boolean ENABLE_WIZARD_ON_FIRST_RUN = true; if (oldHome) { tgt = "console"; } else if (!ENABLE_WIZARD_ON_FIRST_RUN || wizRun || firstVersion == null) { diff --git a/apps/routerconsole/jsp/js/welcomeajax.js b/apps/routerconsole/jsp/js/welcomeajax.js new file mode 100644 index 0000000000..81ab74486a --- /dev/null +++ b/apps/routerconsole/jsp/js/welcomeajax.js @@ -0,0 +1,59 @@ +var fails = 0; + +function ajax(url, target, refresh) { + // native XMLHttpRequest object + if (window.XMLHttpRequest) { + req = new XMLHttpRequest(); + req.onreadystatechange = function() {ajaxDone(url, target, refresh);}; + req.open("GET", url, true); + req.send(null); + // IE/Windows ActiveX version + } else if (window.ActiveXObject) { + req = new ActiveXObject("Microsoft.XMLDOM"); + if (req) { + req.onreadystatechange = function() {ajaxDone(target);}; + req.open("GET", url, true); + req.send(null); + } + } +} + +function ajaxDone(url, target, refresh) { + // only if req is "loaded" + if (req.readyState == 4) { + var fail = false; + var running = true; + var done = false; + // only if "OK" + if (req.status == 200) { + // output 1 for complete, 0 + status string for in progress + fails = 0; + var status; + if (req.responseText.startsWith("1")) { + results = doneMessage; + running = false; + done = true; + status = ""; + } else { + results = progressMessage; + status = req.responseText.substring("1") + } + document.getElementById("xhr2").innerHTML = status; + document.getElementById(target).innerHTML = results; + } else if (fails == 0) { + // avoid spurious message if cancelled by user action + fails++; + } else { + document.getElementById(target).innerHTML = failMessage; + running = false; + fail = true; + } + var form = document.forms[0]; + form.prev.disabled = fail || !done; + form.skip.disabled = !done; + form.cancelbw.disabled = !running; + form.next.disabled = fail || !done; + + setTimeout(function() {ajax(url, target, refresh);}, refresh); + } +} diff --git a/apps/routerconsole/jsp/welcome.jsp b/apps/routerconsole/jsp/welcome.jsp index 14e04a1a22..fffdb5c995 100644 --- a/apps/routerconsole/jsp/welcome.jsp +++ b/apps/routerconsole/jsp/welcome.jsp @@ -66,11 +66,16 @@ wizhelper.setContextId(i2pcontextId); if (ipg == 4) { %> - + <% } @@ -148,6 +153,8 @@ <%=intl._t("Javascript is disabled - wait 60 seconds for the bandwidth test to complete and then click Next")%> +
+
<% } else if (ipg == 5) { diff --git a/apps/routerconsole/jsp/welcomexhr1.jsp b/apps/routerconsole/jsp/welcomexhr1.jsp index 737a786648..d1a91d3603 100644 --- a/apps/routerconsole/jsp/welcomexhr1.jsp +++ b/apps/routerconsole/jsp/welcomexhr1.jsp @@ -8,9 +8,10 @@ } } catch (IllegalStateException ise) {} wizhelper.setContextId(i2pcontextId); + // output 1 for complete, 0 + status string for in progress if (wizhelper.isNDTComplete()) { -%><%=wizhelper._t("Bandwidth test is complete, click Next")%><% +%>1<% } else { -%><%=wizhelper._t("Bandwidth test in progress...")%><% +%>0<%=wizhelper.getTestStatus()%><% } %>