FELIX-1988 Apply 16.license_plugin.patch by Valentin Valchev (thanks)
FELIX-1910 Refactor LicenseServlet to support on-demand loading of licenses (part of 16.license_plugin.patch)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@911770 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/resources/res/ui/license.css b/webconsole/src/main/resources/res/ui/license.css
index f371c35..b2bcba4 100644
--- a/webconsole/src/main/resources/res/ui/license.css
+++ b/webconsole/src/main/resources/res/ui/license.css
@@ -13,37 +13,28 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */ /* CSS Document */
+ */
+
#licenseContent {
- position: relative;
- margin-top: 25px; padding : 5px;
- width: 100%;
- padding: 5px;
+ width: 100%;
}
-
#licenseLeft {
- width: 300px;
- border-right: 1px black solid;
+ float: left;
+ width: 25%;
+ padding: 0;
+ margin-right: 1em;
}
-
+#licenseLeft a {
+ display: block;
+ width: 100%;
+ margin: 0;
+ text-decoration: none;
+}
#licenseRight {
- position: absolute;
- top: 5px;
- left: 305px;
- padding: 5px;
- width: 650px;
- border-left: 1px black solid;
+ float: left;
+ width: 70%;
}
-
-#licenseClear {
- clear: both;
- height: 1px;
+#licenseDetails {
+ width: 100%;
+ height: 100%;
}
-
-.licenseButtons {
- padding: 5px;
-}
-
-.licenseDetails {
- padding: 5px;
-}
\ No newline at end of file
diff --git a/webconsole/src/main/resources/res/ui/license.js b/webconsole/src/main/resources/res/ui/license.js
index a8cbb1f..35018d4 100644
--- a/webconsole/src/main/resources/res/ui/license.js
+++ b/webconsole/src/main/resources/res/ui/license.js
@@ -15,6 +15,9 @@
* limitations under the License.
*/
+var licenseButtons = false;
+var licenseDetails = false;
+
function displayBundle(/* String */ bundleId)
{
var theBundleData = bundleData[bundleId];
@@ -25,7 +28,6 @@
var title = theBundleData.title;
- var licenseButtons = document.getElementById('licenseButtons');
if (licenseButtons) {
var innerHTML = "";
@@ -36,47 +38,42 @@
for (var idx in entry)
{
var descr = entry[idx];
- buttons += "<a href='javascript:displayFile(\"" + bundleId + "\", \"" + name + "\", " + idx + ");'"
- + " >" + descr.url + "</a> ";
+ var jar = descr.jar ? '&jar=' + descr.jar : ''; // inner jar attribute
+ buttons += '<a href="' + pluginRoot + '?bid=' + bundleId + '&url=' + descr.path + jar + '" target="licenseDetails">' + descr.url + '</a> ';
}
if (buttons)
{
+ // apply i18n
+ name = '__res__' == name ? i18n.resources : i18n.resources_emb.msgFormat( name );
innerHTML += name + ": " + buttons + "<br />";
}
}
-
- if (!innerHTML)
- {
- innerHTML = "<em>The Bundle contains neither LICENSE nor NOTICE files</em>";
- }
-
- licenseButtons.innerHTML = "<h1>" + title + "</h1>" + innerHTML;
+
+ licenseButtons.html("<h1>" + title + "</h1>" + innerHTML);
}
- var licenseDetails = document.getElementById('licenseDetails');
- if (licenseDetails)
- {
- licenseDetails.innerHTML = "";
- }
+ licenseDetails.html("");
+ $("#licenseLeft a").removeClass('ui-state-default ui-corner-all');
+ $("#licenseLeft #" +bundleId).addClass('ui-state-default ui-corner-all');
}
-function displayFile ( /* String */ bundleId, /* String */ name, /* int */ idx )
-{
- var theBundleData = bundleData[bundleId];
- if (!theBundleData)
- {
- return;
- }
-
- var file = theBundleData.files[name][idx];
- if (!file)
- {
- return;
- }
-
- var licenseDetails = document.getElementById('licenseDetails');
- if (licenseDetails)
- {
- licenseDetails.innerHTML = "<h3>" + name + ": " + file.url + "</h3><pre>" + file.data + "</pre>";
- }
-}
+
+$(document).ready(function() {
+ // init elements cache
+ licenseButtons = $("#licenseButtons");
+ licenseDetails = $("#licenseDetails")
+
+ // render list of bundles
+ var txt = "";
+ for(id in bundleData) {
+ txt += '<a id="' + id + '" href="javascript:displayBundle(\'' + id + '\')">' + bundleData[id]['title'] + '</a>';
+ }
+ if (txt) {
+ $("#licenseLeft").html(txt);
+ } else {
+ $(".statline").html(i18n.status_none);
+ }
+
+ // display first element
+ for(i in bundleData) {displayBundle(i);break;}
+});
\ No newline at end of file