FELIX-1217: First step: remove start and start level input fields from list header, add new panel for install/update and add new refresh button

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@783772 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
index 1a9b31e..c1b815e 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
@@ -102,7 +102,13 @@
         IOException
     {
         final RequestInfo reqInfo = new RequestInfo(request);
-        if ( reqInfo.bundle == null && reqInfo.bundleRequested ) {
+        if ( "upload".equals(reqInfo.pathInfo) )
+        {
+            super.doGet(request, response);
+            return;
+        }
+        if ( reqInfo.bundle == null && reqInfo.bundleRequested )
+        {
             response.sendError(404);
             return;
         }
@@ -286,12 +292,31 @@
 
         Util.script(pw, appRoot, "bundles.js");
 
-        pw.println( "<div id='plugin_content'/>");
-        Util.startScript( pw );
-        pw.print( "renderBundles(");
-        writeJSON(pw, reqInfo.bundle);
-        pw.println(");" );
-        Util.endScript( pw );
+        if ( "upload".equals(reqInfo.pathInfo) )
+        {
+            renderUploadForm(pw);
+        }
+        else
+        {
+            pw.println( "<div id='plugin_content'/>");
+            Util.startScript( pw );
+            pw.print( "renderBundles(");
+            writeJSON(pw, reqInfo.bundle);
+            pw.println(");" );
+            Util.endScript( pw );
+        }
+    }
+
+    private void renderUploadForm( final PrintWriter pw ) throws IOException
+    {
+        pw.println(" <div id='plugin_content'><div class='contentheader'>Upload / Install Bundles</div>");
+        pw.println( "<form method='post' enctype='multipart/form-data' action='../'>");
+        pw.println( "<input type='hidden' name='action' value='install'/>");
+        pw.println( "<div class='contentline'><input class='fileinput' type='file' name='bundlefile'/></div>");
+        pw.println( "<div class='contentline'><div class='contentleft'>Start Bundle</div><div class='contentright'><input class='checkradio' type='checkbox' name='bundlestart' value='start'/></div></div>");
+        pw.println( "<div class='contentline'><div class='contentleft'>Start Level</div><div class='contentright'><input class='input' type='input' name='bundlestartlevel' value='" + getStartLevel().getInitialBundleStartLevel() + "' size='4'/></div></div>");
+        pw.println( "<div class='contentline'><input type='submit' value='Install or Update'/></div>");
+        pw.println( "</form></div");
     }
 
     private void renderJSON( final HttpServletResponse response, final Bundle bundle ) throws IOException
@@ -552,7 +577,7 @@
         }
 
         listServices( jw, bundle );
-        
+
         listHeaders( jw, bundle );
 
         jw.endArray();
@@ -799,13 +824,13 @@
         {
             return;
         }
-        
+
         for ( int i = 0; i < refs.length; i++ )
         {
             String key = "Service ID " + refs[i].getProperty( Constants.SERVICE_ID );
-            
+
             JSONArray val = new JSONArray();
-            
+
             appendProperty( val, refs[i], Constants.OBJECTCLASS, "Types" );
             appendProperty( val, refs[i], Constants.SERVICE_PID, "PID" );
             appendProperty( val, refs[i], ConfigurationAdmin.SERVICE_FACTORYPID, "Factory PID" );
@@ -814,12 +839,12 @@
             appendProperty( val, refs[i], ComponentConstants.COMPONENT_FACTORY, "Component Factory" );
             appendProperty( val, refs[i], Constants.SERVICE_DESCRIPTION, "Description" );
             appendProperty( val, refs[i], Constants.SERVICE_VENDOR, "Vendor" );
-            
+
             keyVal( jw, key, val);
         }
     }
-    
-    
+
+
     private void listHeaders( JSONWriter jw, Bundle bundle ) throws JSONException
     {
         JSONArray val = new JSONArray();
@@ -1030,6 +1055,7 @@
         public final String extension;
         public final Bundle bundle;
         public final boolean bundleRequested;
+        public final String pathInfo;
 
         protected RequestInfo( final HttpServletRequest request )
         {
@@ -1058,11 +1084,13 @@
             {
                 bundle = null;
                 bundleRequested = false;
+                pathInfo = null;
             }
             else
             {
                 bundle = getBundle(bundleInfo);
                 bundleRequested = true;
+                pathInfo = bundleInfo;
             }
             request.setAttribute(BundlesServlet.class.getName(), this);
         }
diff --git a/webconsole/src/main/resources/res/ui/admin.css b/webconsole/src/main/resources/res/ui/admin.css
index d41c8f0..3b10581 100644
--- a/webconsole/src/main/resources/res/ui/admin.css
+++ b/webconsole/src/main/resources/res/ui/admin.css
@@ -628,4 +628,32 @@
 }
 .col_Actions {
     width: 95px;
-}
\ No newline at end of file
+}
+#plugin_content {
+    margin-top: 26px;
+    margin-bottom: 26px;
+}
+.contentheader {
+    border: 0px solid #66dd44;
+    border-bottom: 1px solid #cccccc;
+    text-align: left;
+    padding: 5px;
+    padding-left: 10px;
+    color: #6181A9;
+    background-color: #f0f0f0;
+}
+.contentline {
+	padding-top: 15px;
+	padding-left:10px;
+    clear: both;
+    width: 100%;
+}
+.contentleft {
+    padding-left: 9px;
+    float: left;
+    width:110px;
+}
+.contentright {
+    display: inline;
+    width: 225px;
+}
diff --git a/webconsole/src/main/resources/res/ui/bundles.js b/webconsole/src/main/resources/res/ui/bundles.js
index c4e7298..028d8b4 100644
--- a/webconsole/src/main/resources/res/ui/bundles.js
+++ b/webconsole/src/main/resources/res/ui/bundles.js
@@ -214,13 +214,19 @@
 	$(document).ready(function(){
     	renderView( ["Id", "Name", "Version", "Symbolic Name", "Status", "Actions"],
         		"<input type='hidden' name='action' value='install'/>" +
+        		"<input type='hidden' name='bundlestart' value='start'/>" +
+        		"<input type='hidden' name='bundlestartlevel' value='" + startLevel + "'/>" +
                 "<input class='fileinput' type='file' name='bundlefile' style='margin-left:10px'/>" +
-         		" - Start <input class='checkradio' type='checkbox' name='bundlestart' value='start' style='vertical-align:middle;'/>" +
-        		" - Start Level <input class='input' type='input' name='bundlestartlevel' value='" + startLevel + "' size='4'/>" +
-         		"<input type='submit' value='Install or Update' style='margin-left:60px'/>" +
-        		"<button id='refreshPackages' type='button' name='refresh' style='margin-left:10px'>Refresh Packages</button>"
+         		"<input type='submit' value='Install or Update' style='margin-left:10px'/>" +
+         		"<button class='reloadButton' type='button' name='reload' style='margin-left:60px'>Reload</button>" +
+         		"<button class='installButton' type='button' name='install'>Install/Update...</button>" +
+         		"<button class='refreshPackages' type='button' name='refresh'>Refresh Packages</button>"
         		 );
-        $("#refreshPackages").click(refreshPackages);
+        $(".refreshPackages").click(refreshPackages);
+	    $(".reloadButton").click(loadData);
+	    $(".installButton").click(function() {
+	    	document.location = pluginRoot + "/upload";
+	    });
         renderData(data);
         
         var extractMethod = function(node) {