You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2010/03/12 14:25:09 UTC

svn commit: r922248 - in /felix/trunk/webconsole/src/main: java/org/apache/felix/webconsole/internal/misc/ShellServlet.java resources/res/ui/shell.js resources/templates/shell.html

Author: fmeschbe
Date: Fri Mar 12 13:25:09 2010
New Revision: 922248

URL: http://svn.apache.org/viewvc?rev=922248&view=rev
Log:
FELIX-2189 Hide the shell form if the ShellService is not available. Also rename the "console"
script variable to "konsole" to prevent a naming conflict with Firebug ....

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ShellServlet.java
    felix/trunk/webconsole/src/main/resources/res/ui/shell.js
    felix/trunk/webconsole/src/main/resources/templates/shell.html

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ShellServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ShellServlet.java?rev=922248&r1=922247&r2=922248&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ShellServlet.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/ShellServlet.java Fri Mar 12 13:25:09 2010
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.felix.shell.ShellService;
+import org.apache.felix.webconsole.DefaultVariableResolver;
 import org.apache.felix.webconsole.SimpleWebConsolePlugin;
 import org.apache.felix.webconsole.WebConsoleUtil;
 import org.apache.felix.webconsole.internal.OsgiManagerPlugin;
@@ -125,6 +126,14 @@ public class ShellServlet extends Simple
      */
     protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws IOException
     {
+        DefaultVariableResolver vr = ( DefaultVariableResolver ) WebConsoleUtil.getVariableResolver( request );
+        if ( getShellService() == null )
+        {
+            vr.put( "shell.status", "Shell Service not available" );
+            vr.put( "shell.disabled", "true" );
+        } else {
+            vr.put( "shell.disabled", "false" );
+        }
         response.getWriter().print(TEMPLATE);
     }
 

Modified: felix/trunk/webconsole/src/main/resources/res/ui/shell.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/shell.js?rev=922248&r1=922247&r2=922248&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/shell.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/shell.js Fri Mar 12 13:25:09 2010
@@ -17,14 +17,14 @@
 
 // elements cache
 var consoleframe = false;
-var console = false;
+var konsole = false;
 var command = false;
 
 function executeCommand(cmd) {
 	$.post(document.location.href, { 'command' : encodeURIComponent(cmd) },
 		function(result) {
-			console.removeClass('ui-helper-hidden').append(result);
-			consoleframe.attr('scrollTop', console.attr('scrollHeight'));
+			konsole.removeClass('ui-helper-hidden').append(result);
+			consoleframe.attr('scrollTop', konsole.attr('scrollHeight'));
 			command.val('');
 			shellCommandFocus();
 		}, 'html');
@@ -34,22 +34,32 @@ function shellCommandFocus() { command.f
 
 // automatically executed on load
 $(document).ready(function(){
-	// init cache
-	consoleframe = $('#consoleframe').click(shellCommandFocus);
-	console      = $('#console');
-	command      = $('#command').focus();
-
-	// attach action handlers
-	$('#clear').click(function() {
-		console.addClass('ui-helper-hidden').html('');
-		consoleframe.attr('scrollTop', 0);
-		shellCommandFocus();
-	});
-	$('#help').click(function() {
-		executeCommand('help');
-	});
-	$('form').submit(function() {
-		executeCommand(command.val());
-		return false;
-	});
+    
+    // disable the shell form if the shell service is not available
+    if (shellDisabled) {
+    
+        $('#shell_form').hide();
+    
+    } else {
+    
+    	// init cache
+    	consoleframe = $('#consoleframe').click(shellCommandFocus);
+    	konsole      = $('#console');
+    	command      = $('#command').focus();
+    
+    	// attach action handlers
+    	$('#clear').click(function() {
+    		konsole.addClass('ui-helper-hidden').html('');
+    		consoleframe.attr('scrollTop', 0);
+    		shellCommandFocus();
+    	});
+    	$('#help').click(function() {
+    		executeCommand('help');
+    	});
+    	$('form').submit(function() {
+    		executeCommand(command.val());
+    		return false;
+    	});
+    	
+	}
 });

Modified: felix/trunk/webconsole/src/main/resources/templates/shell.html
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/templates/shell.html?rev=922248&r1=922247&r2=922248&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/templates/shell.html [UTF-8] (original)
+++ felix/trunk/webconsole/src/main/resources/templates/shell.html [UTF-8] Fri Mar 12 13:25:09 2010
@@ -1,8 +1,12 @@
 <script type="text/javascript" src="res/ui/shell.js"></script>
-
+<script type="text/javascript">
+// <![CDATA[
+var shellDisabled = ${shell.disabled};
+// ]]>
+</script>
 <p class="statline">${shell.status}</p>
 
-<form method="post" action="${pluginRoot}">
+<form id="shell_form" method="post" action="${pluginRoot}">
 	<!-- top header -->
 	<div class="ui-widget-header ui-corner-top buttonGroup">
 		<input id="help" value="${help}" type="button" />