You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by vv...@apache.org on 2015/09/16 14:45:22 UTC
svn commit: r1703394 - in /felix/trunk/webconsole/src/main:
java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
resources/res/ui/config.js resources/templates/config.html
Author: vvalchev
Date: Wed Sep 16 12:45:21 2015
New Revision: 1703394
URL: http://svn.apache.org/r1703394
Log:
Implemented FELIX-5019 : [webconsole] "referer" parameter for configuration open/create link
https://issues.apache.org/jira/browse/FELIX-5019
Applied the patch from Balazs Zsoldos. Thank you!
Modified:
felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
felix/trunk/webconsole/src/main/resources/res/ui/config.js
felix/trunk/webconsole/src/main/resources/templates/config.html
Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java?rev=1703394&r1=1703393&r2=1703394&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java Wed Sep 16 12:45:21 2015
@@ -53,6 +53,7 @@ public class ConfigManager extends Simpl
static final String PID = "pid"; //$NON-NLS-1$
static final String FACTORY_PID = "factoryPid"; //$NON-NLS-1$
static final String PLACEHOLDER_PID = "[Temporary PID replaced by real PID upon save]"; //$NON-NLS-1$
+ static final String REFERER = "referer"; //$NON-NLS-1$
static final String FACTORY_CREATE = "factoryCreate"; //$NON-NLS-1$
static final String ACTION_CREATE = "create"; //$NON-NLS-1$
@@ -65,7 +66,7 @@ public class ConfigManager extends Simpl
static final String CONFIGURATION_ADMIN_NAME = "org.osgi.service.cm.ConfigurationAdmin"; //$NON-NLS-1$
static final String META_TYPE_NAME = "org.osgi.service.metatype.MetaTypeService"; //$NON-NLS-1$
- public static final String UNBOUND_LOCATION = "??unbound:bundle/location";
+ public static final String UNBOUND_LOCATION = "??unbound:bundle/location"; //$NON-NLS-1$
// templates
private final String TEMPLATE;
@@ -149,12 +150,12 @@ public class ConfigManager extends Simpl
Configuration config = null;
// should actually apply the configuration before redirecting
- if ( request.getParameter( ACTION_CREATE ) != null ) //$NON-NLS-1$
+ if ( request.getParameter( ACTION_CREATE ) != null )
{
config = cas.getPlaceholderConfiguration( pid ); // ca.createFactoryConfiguration( pid, null );
pid = config.getPid();
}
- else if ( request.getParameter( ACTION_APPLY ) != null ) //$NON-NLS-1$
+ else if ( request.getParameter( ACTION_APPLY ) != null )
{
String redirect = cas.applyConfiguration( request, pid );
if ( redirect != null )
@@ -181,11 +182,11 @@ public class ConfigManager extends Simpl
}
// check for configuration unbinding
- if ( request.getParameter( ACTION_UNBIND ) != null ) //$NON-NLS-1$
+ if ( request.getParameter( ACTION_UNBIND ) != null )
{
if ( config != null && config.getBundleLocation() != null )
{
- config.setBundleLocation( UNBOUND_LOCATION ); //$NON-NLS-1$
+ config.setBundleLocation( UNBOUND_LOCATION );
}
response.setContentType( "application/json" ); //$NON-NLS-1$
@@ -210,7 +211,7 @@ public class ConfigManager extends Simpl
throws ServletException, IOException
{
// check for "post" requests from previous versions
- if ( "true".equals(request.getParameter("post")) ) {
+ if ( "true".equals(request.getParameter("post")) ) { //$NON-NLS-1$ //$NON-NLS-2$
this.doPost(request, response);
return;
}
@@ -271,7 +272,7 @@ public class ConfigManager extends Simpl
final StringBuffer sb = new StringBuffer();
if ( pid != null && pidFilter != null)
{
- sb.append("(&");
+ sb.append("(&"); //$NON-NLS-1$
}
if ( pid != null )
{
@@ -402,18 +403,20 @@ public class ConfigManager extends Simpl
}
// if a configuration is addressed, display it immediately
- if ( request.getParameter( ACTION_CREATE ) != null && pid != null ) //$NON-NLS-1$
+ if ( request.getParameter( ACTION_CREATE ) != null && pid != null )
{
pid = PLACEHOLDER_PID; // new PlaceholderConfiguration( pid ).getPid();
}
// prepare variables
+ final String referer = request.getParameter( REFERER );
+ final boolean factoryCreate = "true".equals( request.getParameter(FACTORY_CREATE) ); //$NON-NLS-1$
DefaultVariableResolver vars = ( ( DefaultVariableResolver ) WebConsoleUtil.getVariableResolver( request ) );
vars.put( "__data__", json.toString() ); //$NON-NLS-1$
- vars.put( "selectedPid", pid != null ? pid : ""); //$NON-NLS-1$ //$NON-NLS-2$
- boolean factoryCreate = "true".equals(request.getParameter(FACTORY_CREATE)); //$NON-NLS-1$
- vars.put( "factoryCreate", Boolean.valueOf(factoryCreate)); //$NON-NLS-1$
+ vars.put( "selectedPid", pid != null ? pid : "" ); //$NON-NLS-1$ //$NON-NLS-2$
+ vars.put( "configurationReferer", referer != null ? referer : "" ); //$NON-NLS-1$ //$NON-NLS-2$
+ vars.put( "factoryCreate", Boolean.valueOf(factoryCreate) ); //$NON-NLS-1$
vars.put( "param.apply", ACTION_APPLY ); //$NON-NLS-1$
vars.put( "param.create", ACTION_CREATE ); //$NON-NLS-1$
vars.put( "param.unbind", ACTION_UNBIND ); //$NON-NLS-1$
Modified: felix/trunk/webconsole/src/main/resources/res/ui/config.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/config.js?rev=1703394&r1=1703393&r2=1703394&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/config.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/config.js Wed Sep 16 12:45:21 2015
@@ -493,9 +493,16 @@ function configConfirm(/* String */ mess
function deleteConfig(/* String */ configId, /* String */ bundleLocation)
{
if ( configConfirm(i18n.del_ask, configId, bundleLocation) ) {
- $.post(pluginRoot + '/' + configId, param.apply + '=1&' + param.dele + '=1', function() {
- document.location.href = pluginRoot;
- }, 'json');
+ $.ajax({
+ type : 'POST',
+ url : pluginRoot + '/' + configId,
+ data : param.apply + '=1&' + param.dele + '=1',
+ success : function () {
+ if(!navigateAfterConfigurationClose()) document.location.href = pluginRoot;
+ },
+ dataType : 'json',
+ async : false
+ });
return true;
}
return false;
@@ -582,6 +589,13 @@ function treetableExtraction(node) {
return mixedLinksExtraction(node);
};
+function navigateAfterConfigurationClose() {
+ if(configurationReferer) {
+ window.location = configurationReferer;
+ return true;
+ }
+ return false;
+}
$(document).ready(function() {
configContent = $('#configContent');
@@ -629,11 +643,19 @@ $(document).ready(function() {
});
propListElement.val(propListArray.join(','));
- $.post(pluginRoot + '/' + $(this).attr('__pid'), $(this).find('form').serialize(), function() {
- // reload on success - prevents AJAX errors - see FELIX-3116
- document.location.href = pluginRoot;
+ $.ajax({
+ type : 'POST',
+ url : pluginRoot + '/' + $(this).attr('__pid'),
+ data : $(this).find('form').serialize(),
+ success : function () {
+ // reload on success - prevents AJAX errors - see FELIX-3116
+ if(!navigateAfterConfigurationClose()) document.location.href = pluginRoot;
+ },
+ async : false
+ })
+ .fail(function () {
+ $(this).dialog('close');
});
- $(this).dialog('close');
}
// prepare editor, but don't open yet!
editor = $('#editor').dialog({
@@ -641,7 +663,8 @@ $(document).ready(function() {
modal : true,
width : '90%',
closeText: i18n.abort,
- buttons : _buttons
+ buttons : _buttons,
+ close : function( event, ui ) { navigateAfterConfigurationClose(); }
});
editorMessage = editor.find('p');
Modified: felix/trunk/webconsole/src/main/resources/templates/config.html
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/templates/config.html?rev=1703394&r1=1703393&r2=1703394&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/templates/config.html [UTF-8] (original)
+++ felix/trunk/webconsole/src/main/resources/templates/config.html [UTF-8] Wed Sep 16 12:45:21 2015
@@ -4,6 +4,7 @@
// data
var configData = ${__data__};
var selectedPid = '${selectedPid}';
+var configurationReferer = '${configurationReferer}';
var factoryCreate = ${factoryCreate};
var i18n = { // i18n
stat_ok : '${config.status.ok}', // "Configuration Admin Service is running.";