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 ....
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@922248 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/resources/res/ui/shell.js b/webconsole/src/main/resources/res/ui/shell.js
index 8a79c8e..7d34014 100644
--- a/webconsole/src/main/resources/res/ui/shell.js
+++ b/webconsole/src/main/resources/res/ui/shell.js
@@ -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 @@
// 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;
+ });
+
+ }
});
diff --git a/webconsole/src/main/resources/templates/shell.html b/webconsole/src/main/resources/templates/shell.html
index 9a648a4..f0ed65c 100644
--- a/webconsole/src/main/resources/templates/shell.html
+++ b/webconsole/src/main/resources/templates/shell.html
@@ -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" />