You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2021/03/12 12:08:39 UTC

[felix-dev] branch master updated: FELIX-6392 : Webconsole configadmin javascript error: Uncaught TypeError: parsers is undefined

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 90eee74  FELIX-6392 : Webconsole configadmin javascript error: Uncaught TypeError: parsers is undefined
90eee74 is described below

commit 90eee7459c45994b7513c02f995438aa8f6430e8
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 12 13:07:41 2021 +0100

    FELIX-6392 : Webconsole configadmin javascript error: Uncaught TypeError: parsers is undefined
---
 webconsole/changelog.txt                           |  1 +
 .../internal/configuration/ConfigAdminSupport.java |  7 +++--
 .../internal/configuration/ConfigManager.java      | 11 ++++++-
 .../main/resources/OSGI-INF/l10n/bundle.properties |  3 ++
 webconsole/src/main/resources/res/ui/config.js     | 34 ++++++++++++++--------
 .../src/main/resources/templates/config.html       |  3 ++
 6 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/webconsole/changelog.txt b/webconsole/changelog.txt
index 9f0bcdb..9ccd352 100644
--- a/webconsole/changelog.txt
+++ b/webconsole/changelog.txt
@@ -2,6 +2,7 @@ Changes in 4.6.2
 ----------------
 ** Bug
     * [FELIX-6375] - Configuration Admin Service not available with org.apache.felix.webconsole_4.6.0.all
+    * [FELIX-6392] - Webconsole configadmin javascript error: Uncaught TypeError: parsers is undefined
 
 
 Changes in 4.6.0
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
index a6e096b..6eb0cad 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
@@ -99,7 +99,7 @@ class ConfigAdminSupport
         return bundleContext;
     }
 
-    private MetaTypeServiceSupport getMetaTypeSupport()
+    MetaTypeServiceSupport getMetaTypeSupport()
     {
         Object metaTypeService = configManager.getService( ConfigManager.META_TYPE_NAME );
         if ( metaTypeService != null )
@@ -556,8 +556,9 @@ class ConfigAdminSupport
     }
 
 
-    final void listConfigurations( JSONWriter jw, String pidFilter, String locale, Locale loc )
+    final boolean listConfigurations( JSONWriter jw, String pidFilter, String locale, Locale loc )
     {
+        boolean hasConfigurations = false;
         try
         {
             // start with ManagedService instances
@@ -613,6 +614,7 @@ class ConfigAdminSupport
             jw.array();
             for ( Iterator<String> ii = optionsPlain.keySet().iterator(); ii.hasNext(); )
             {
+                hasConfigurations = true;
                 String id = ii.next();
                 Object name = optionsPlain.get( id );
 
@@ -652,6 +654,7 @@ class ConfigAdminSupport
         {
             configManager.log("listConfigurations: Unexpected problem encountered", e);
         }
+        return hasConfigurations;
     }
 
     /**
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
index a4c1fbe..8a8284a 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
@@ -400,12 +400,21 @@ public class ConfigManager extends SimpleWebConsolePlugin implements OsgiManager
         @SuppressWarnings("unchecked")
         final Map<String, Object> labelMap = (Map<String, Object>) request.getAttribute(WebConsoleConstants.ATTR_LABEL_MAP);
         jw.key("jsonsupport").value( labelMap.containsKey("osgi-installer-config-printer") ); //$NON-NLS-1$
+        final boolean hasMetatype = ca.getMetaTypeSupport() != null;
         jw.key("status").value( ca != null ? Boolean.TRUE : Boolean.FALSE); //$NON-NLS-1$
+        jw.key("metatype").value( hasMetatype ? Boolean.TRUE : Boolean.FALSE); //$NON-NLS-1$
+        boolean hasConfigs = true;
         if ( ca != null )
         {
-            ca.listConfigurations( jw, pidFilter, locale, loc );
+            hasConfigs = ca.listConfigurations( jw, pidFilter, locale, loc );
             ca.listFactoryConfigurations( jw, pidFilter, locale );
         }
+        if ( !hasConfigs && !hasMetatype && ca != null ) {
+            jw.key("noconfigs").value(true); //$NON-NLS-1$
+        } else {
+            jw.key("noconfigs").value(false); //$NON-NLS-1$
+        }
+
         jw.endObject();
 
         // if a configuration is addressed, display it immediately
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
index 5dd397b..6fbc505 100644
--- a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -174,6 +174,9 @@ bundles.error.title=Error while executing bundle operation!
 configMgr.pluginTitle=Configuration
 config.status.ok=Configuration Admin Service is running.
 config.status.missing=Configuration Admin Service is not installed/running.
+config.metatype.ok=Metatype Service is available.
+config.metatype.missing=Metatype service is missing.
+config.noconfigs=No configurations available.
 config.properties=Properties
 config.properties.enter=Enter Name-Value pairs of configuration properties
 config.info.title=Configuration Information
diff --git a/webconsole/src/main/resources/res/ui/config.js b/webconsole/src/main/resources/res/ui/config.js
index ebe2b93..4634d62 100644
--- a/webconsole/src/main/resources/res/ui/config.js
+++ b/webconsole/src/main/resources/res/ui/config.js
@@ -698,12 +698,19 @@ $(document).ready(function() {
 	jsonSupport = configData.jsonsupport;
 
 	// display the configuration data
-	$(".statline").html(configData.status ? i18n.stat_ok : i18n.stat_missing);
+	var line = configData.status ? i18n.stat_ok : i18n.stat_missing;
+	line = line + " " + (configData.metatype ? i18n.metatype_ok : i18n.metatype_missing);
+	if ( configData.noconfigs ) {
+	    line = line + " " + i18n.noconfigs;
+	}
+	$(".statline").html(line);
 	if (configData.status) {
+	    var hasData = false;
 		configBody.empty();
 		var factories = {};
 
 		for(var i in configData.pids) {
+		    hasData = true;
 			var c = configData.pids[i];
 			if (c.fpid) {
 				if (!factories[c.fpid]) factories[c.fpid] = new Array();
@@ -713,6 +720,7 @@ $(document).ready(function() {
 			}
 		}
 		for(var i in configData.fpids) {
+            hasData = true;
 			addFactoryConfig(configData.fpids[i]);
 
 			var fpid = configData.fpids[i].id;
@@ -733,17 +741,19 @@ $(document).ready(function() {
 		}
 		initStaticWidgets(configTable);
 
-		// init tablesorte
-		configTable.tablesorter({
-			headers: {
-				0: { sorter: false },
-				3: { sorter: false }
-			},
-			sortList: [[1,1]],
-			textExtraction: treetableExtraction
-		}).bind('sortStart', function() { // clear cache, otherwise extraction will not work
-			var table = $(this).trigger('update'); 
-		}).find('th:eq(1)').click();
+		// init tablesorter
+		if ( hasData ) {
+		    configTable.tablesorter({
+			    headers: {
+				    0: { sorter: false },
+				    3: { sorter: false }
+			    },
+			    sortList: [[1,1]],
+			    textExtraction: treetableExtraction
+		    }).bind('sortStart', function() { // clear cache, otherwise extraction will not work
+			    var table = $(this).trigger('update'); 
+		    }).find('th:eq(1)').click();
+	 }
 	} else {
 		configContent.addClass('ui-helper-hidden');
 	}
diff --git a/webconsole/src/main/resources/templates/config.html b/webconsole/src/main/resources/templates/config.html
index d354f9a..fe87717 100644
--- a/webconsole/src/main/resources/templates/config.html
+++ b/webconsole/src/main/resources/templates/config.html
@@ -9,6 +9,9 @@ var factoryCreate = ${factoryCreate};
 var i18n = { // i18n
 	stat_ok      : '${config.status.ok}', // "Configuration Admin Service is running.";
 	stat_missing : '${config.status.missing}', //"Configuration Admin Service is not installed/running."
+    metatype_ok  : '${config.metatype.ok}',
+    metatype_missing  : '${config.metatype.missing}',
+    noconfigs    : '${config.noconfigs}',
 	save         : '${save}',
 	reset        : '${reset}',
 	del          : '${delete}',