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!
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1703394 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/resources/res/ui/config.js b/webconsole/src/main/resources/res/ui/config.js
index 963ba00..d4dad3b 100644
--- a/webconsole/src/main/resources/res/ui/config.js
+++ b/webconsole/src/main/resources/res/ui/config.js
@@ -493,9 +493,16 @@
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 @@
return mixedLinksExtraction(node);
};
+function navigateAfterConfigurationClose() {
+ if(configurationReferer) {
+ window.location = configurationReferer;
+ return true;
+ }
+ return false;
+}
$(document).ready(function() {
configContent = $('#configContent');
@@ -629,11 +643,19 @@
});
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 @@
modal : true,
width : '90%',
closeText: i18n.abort,
- buttons : _buttons
+ buttons : _buttons,
+ close : function( event, ui ) { navigateAfterConfigurationClose(); }
});
editorMessage = editor.find('p');
diff --git a/webconsole/src/main/resources/templates/config.html b/webconsole/src/main/resources/templates/config.html
index bba09c0..b1d0cc4 100644
--- a/webconsole/src/main/resources/templates/config.html
+++ b/webconsole/src/main/resources/templates/config.html
@@ -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.";