You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2018/03/15 10:57:45 UTC
svn commit: r1826793 -
/ofbiz/ofbiz-framework/trunk/themes/common-theme/webapp/common/js/util/OfbizUtil.js
Author: jleroux
Date: Thu Mar 15 10:57:45 2018
New Revision: 1826793
URL: http://svn.apache.org/viewvc?rev=1826793&view=rev
Log:
Fixed: The getJSONuiLabel javascript function is no longer working
(OFBIZ-10277)
The data were well retrieve, but the syntax used to extract them was not working
Modified:
ofbiz/ofbiz-framework/trunk/themes/common-theme/webapp/common/js/util/OfbizUtil.js
Modified: ofbiz/ofbiz-framework/trunk/themes/common-theme/webapp/common/js/util/OfbizUtil.js
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common-theme/webapp/common/js/util/OfbizUtil.js?rev=1826793&r1=1826792&r2=1826793&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/themes/common-theme/webapp/common/js/util/OfbizUtil.js (original)
+++ ofbiz/ofbiz-framework/trunk/themes/common-theme/webapp/common/js/util/OfbizUtil.js Thu Mar 15 10:57:45 2018
@@ -1057,11 +1057,11 @@ function getJSONuiLabel(uiResource, errU
type: "POST",
data: {"requiredLabel" : requiredLabelStr},
success: function(data) {
- returnVal = data[0];
+ returnVal = data;
}
});
}
- return returnVal;
+ return returnVal[arguments[0]];
}
/**
@@ -1196,3 +1196,67 @@ function submitPagination(obj, url) {
}
}
}
+
+function getJwtToken(webAppName) {
+ var JwtToken = "";
+ var userLoginId = getAutoUserLoginId(webAppName);
+
+ if (userLoginId != null && userLoginId != "") {
+ jQuery.ajax({
+ url: "getJwtToken",
+ type: "POST",
+ async: false,
+ dataType: "text",
+ data: {"userLoginId" : userLoginId},
+ success: function(data) {
+ JwtToken = data;
+ },
+ error: function(textStatus, errorThrown){
+ alert('Failure, errorThrown: ' + errorThrown);
+ }
+ });
+ }
+ return JwtToken;
+}
+
+function getAutoUserLoginId(webAppName) {
+ var userLoginId = ""
+ jQuery.ajax({
+ url: "getAutoUserLoginId",
+ type: "POST",
+ async: false,
+ dataType: "text",
+ data: {"webAppName" : webAppName},
+ success: function(data) {
+ userLoginId = data;
+ },
+ error: function(textStatus, errorThrown){
+ alert('Failure, errorThrown: ' + errorThrown);
+ }
+ });
+ return userLoginId;
+}
+
+//POST, or GET necessary ?
+function sendJwtToken(webAppName, targetUrl) {
+ var redirectUrl = targetUrl;
+ var jwtToken = getJwtToken(webAppName);
+ if (jwtToken != null && jwtToken != "") {
+ jQuery.ajax({
+ url: targetUrl,
+ async: false,
+ type: 'POST',
+// ContentType: 'text/plain',
+// xhrFields: {withCredentials: true},
+// beforeSend: function (request) {
+// request.setRequestHeader("Access-Control-Allow-Origin", "https://localhost"); // TODO check this is OK (it allows all)
+// request.setRequestHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, X-Requested-By, Content-Type, Accept, Authorization");
+// request.setRequestHeader("Access-Control-Allow-Credentials", "true");
+// },
+ headers: { 'Content-Type': 'text/plain', "Authorization" : jwtToken},
+ success: function(data, textStatus, XMLHttpRequest){
+ window.location.href = redirectUrl;
+ }
+ });
+ }
+}