Fixed FELIX-2896 Add support for bundle info providers
https://issues.apache.org/jira/browse/FELIX-2896
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1373379 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
index 696504c..f6b8218 100644
--- a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -78,6 +78,9 @@
services.statusline=Services information: {0} service(s) in total.
services.caption=Services
services.usingBundles=Using Bundles
+services.info.name=Used Services
+services.info.descr=This is a OSGi service that is used by the current bundle. Click to see more details in 'Services' plugin.
+services.info.key=Service #{0} of type(s) {1}
# Log plugin
logs.pluginTitle=Log Service
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle_bg.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
index 2910a8a..fbf4136 100644
--- a/webconsole/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
+++ b/webconsole/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
@@ -78,6 +78,10 @@
services.statusline=Информация за услугите: {0} услуги.
services.caption=Услуги
services.usingBundles=Използващи бъндъли
+services.info.name=Използвани услуги
+services.info.descr=Тази услуга се използва от избраният бъндъл. Кликнете за да видите повече детайли в плъгин "Услуги"
+services.info.key=Услуга #{0} от тип(ове) {1}
+
# Log plugin
logs.pluginTitle=Журнал
diff --git a/webconsole/src/main/resources/res/ui/bundles.js b/webconsole/src/main/resources/res/ui/bundles.js
index d316b38..703b961 100644
--- a/webconsole/src/main/resources/res/ui/bundles.js
+++ b/webconsole/src/main/resources/res/ui/bundles.js
@@ -175,39 +175,64 @@
var details = data.props;
for (var idx in details) {
var prop = details[idx];
- var key = i18n[prop.key] ? i18n[prop.key] : prop.key;
-
- var txt = "<tr><td class='aligntop' noWrap='true' style='border:0px none'>" + key + "</td><td class='aligntop' style='border:0px none'>";
- if (prop.value) {
- if ( prop.key == 'Bundle Documentation' ) {
- txt = txt + "<a href='" + prop.value + "' target='_blank'>" + prop.value + "</a>";
- } else {
- if ( $.isArray(prop.value) ) {
- var i = 0;
- for(var pi in prop.value) {
- var value = prop.value[pi];
- if (i > 0) { txt = txt + "<br/>"; }
- var span;
- if (value.substring(0, 6) == "INFO: ") {
- txt = txt + "<span class='ui-state-info-text'>" + value.substring(5) + "</span>";
- } else if (value.substring(0, 7) == "ERROR: ") {
- txt = txt + "<span class='ui-state-error-text'>" + value.substring(6) + "</span>";
- } else {
- txt = txt + value;
- }
- i++;
- }
- } else {
- txt = txt + prop.value;
- }
- }
- } else {
- txt = txt + "\u00a0";
- }
- txt = txt + "</td></tr>";
- $("#pluginInlineDetails" + data.id + " > table > tbody").append(txt);
+
+ if (prop.key == 'nfo') {
+ $.each(prop.value, function(name, bundleInfo) {
+ var txt = '';
+ $.each(bundleInfo, function(idx, ie) {
+ txt += '<div title="' + makeSafe(ie.description) + '">';
+ if (ie.type == 'link' || ie.type == 'resource') {
+ txt += '<a href="' + ie.value + '">' + ie.name + '</a>';
+ } else {
+ txt += ie.name + " = " + ie.value;
+ }
+ txt += '</div>';
+ });
+ $("#pluginInlineDetails" + data.id + " > table > tbody").append(
+ renderDetailsEntry(name, txt) );
+ });
+ } else
+ $("#pluginInlineDetails" + data.id + " > table > tbody").append(
+ renderDetailsEntry(prop.key, prop.value) );
}
}
+function makeSafe(text) {
+ return text.replace(/\W/g, function (chr) {
+ return '&#' + chr.charCodeAt(0) + ';';
+ });
+};
+
+function renderDetailsEntry(key, value) {
+ var key18 = i18n[key] ? i18n[key] : key;
+ var txt = "<tr><td class='aligntop' noWrap='true' style='border:0px none'>" + key18 + "</td><td class='aligntop' style='border:0px none'>";
+ if (value) {
+ if ( key == 'Bundle Documentation' ) {
+ txt += "<a href='" + value + "' target='_blank'>" + value + "</a>";
+ } else {
+ if ( $.isArray(value) ) {
+ var i = 0;
+ for(var pi in value) {
+ var xv = value[pi];
+ if (i > 0) { txt = txt + "<br/>"; }
+ var span;
+ if (xv.substring(0, 6) == "INFO: ") {
+ txt += "<span class='ui-state-info-text'>" + xv.substring(5) + "</span>";
+ } else if (xv.substring(0, 7) == "ERROR: ") {
+ txt += "<span class='ui-state-error-text'>" + xv.substring(6) + "</span>";
+ } else {
+ txt += xv;
+ }
+ i++;
+ }
+ } else {
+ txt += value;
+ }
+ }
+ } else {
+ txt += "\u00a0";
+ }
+ return txt + "</td></tr>";
+}
$(document).ready(function(){