remove hardcoded references to localhost or any part of the platform api url from jsp and javascript libs.

This commit is contained in:
Keith Woodlock
2012-05-20 15:48:33 +01:00
parent 965429e30e
commit 52de332e5e
17 changed files with 90 additions and 188 deletions
@@ -3,8 +3,6 @@
$.stretchyReporting = {};
$.stretchyReporting.initialise = function(params) {
username="mifos";
password="password";
initialiseReporting(params)
};
@@ -81,6 +79,9 @@ function initialiseReporting(params) {
if (params.RESTUrl) RESTUrl = params.RESTUrl
else RESTUrl = "";
if (params.basicAuthKey) basicAuthKey = params.basicAuthKey
else basicAuthKey = "";
if (params.pentahoUrl) pentahoUrl = params.pentahoUrl
else pentahoUrl = "";
@@ -984,21 +985,21 @@ return
for (var i in inParams ) inQueryParameters["R_" + i] = inParams[i];
if (rptDB > "") inQueryParameters["R_rptDB"] = rptDB;
OAuthSimple().reset();
var OAuthProcess = (new OAuthSimple()).sign({
path : RESTUrl,
parameters : inQueryParameters,
signatures : {
'consumer_key' : apiKey,
'shared_secret' : sharedSecret,
'access_token' : accessToken,
'access_secret' : tokenSecret
}
});
// OAuthSimple().reset();
// var OAuthProcess = (new OAuthSimple()).sign({
// path : RESTUrl,
// parameters : inQueryParameters,
// signatures : {
// 'consumer_key' : apiKey,
// 'shared_secret' : sharedSecret,
// 'access_token' : accessToken,
// 'access_secret' : tokenSecret
// }
// });
showMsgE("getReportData IS Auth: " + inQueryParameters);
$.ajax({
url: OAuthProcess.signed_url,
url: RESTUrl,
type:'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
@@ -1006,6 +1007,8 @@ return
cache: false,
beforeSend: function( xhr ) {
xhr.setRequestHeader("Accept", "application/json");
console.log("base64: " + basicAuthKey);
xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey);
},
success: successFunction,
error:function(jqXHR, textStatus, errorThrown){
@@ -1058,9 +1061,8 @@ function getReportDataNoAuth(rptName, inParams, successFunction, isParameterType
cache: false,
beforeSend : function(xhr) {
xhr.setRequestHeader("Accept", "application/json");
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
console.log("base64: " + basicAuthKey);
xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey);
},
success: successFunction,
error:function(jqXHR, textStatus, errorThrown){
@@ -22,6 +22,7 @@ $(document).ready(function() {
// basic auth details
var base64 = "${basicAuthKey}";
var baseApiUrl = "${baseApiUrl}";
// these helpers are registered for the jsViews and jsRender functionality to fix bug with display zero!
$.views.registerHelpers({
@@ -312,8 +313,8 @@ $(document).ready(function() {
$("#settings").html(tableHtml);
$('#changepassword').click(function(e) {
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/useraccounts/current/password/template';
var putUrl = 'http://localhost:8080/mifosng-provider/api/v1/useraccounts/current/password';
var getUrl = baseApiUrl + 'useraccounts/current/password/template';
var putUrl = baseApiUrl + 'useraccounts/current/password';
var templateSelector = "#changePasswordFormTemplate";
var width = 600;
var height = 350;
@@ -329,7 +330,7 @@ $(document).ready(function() {
});
$('#changedetails').click(function(e) {
var getAndPutUrl = 'http://localhost:8080/mifosng-provider/api/v1/useraccounts/current';
var getAndPutUrl = baseApiUrl + 'useraccounts/current';
var templateSelector = "#userSettingsFormTemplate";
var width = 600;
var height = 350;
@@ -361,7 +362,7 @@ $(document).ready(function() {
<div id="content">
<div id="tabs">
<ul>
<li><a href="http://localhost:8080/mifosng-provider/api/v1/useraccounts/current" title="settings"><spring:message code="tab.settings"/></a></li>
<li><a href="${baseApiUrl}useraccounts/current" title="settings"><spring:message code="tab.settings"/></a></li>
</ul>
<div id="settings">
</div>
@@ -17,7 +17,8 @@
// basic auth details
var base64 = "${basicAuthKey}";
var baseApiUrl = "${baseApiUrl}";
// these helpers are registered for the jsViews and jsRender functionality to fix bug with display zero!
$.views.registerHelpers({
@@ -298,8 +299,8 @@
});
$('#addloanproduct').click(function(e) {
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/loanproducts/template';
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loanproducts';
var getUrl = baseApiUrl + 'loanproducts/template';
var postUrl = baseApiUrl + 'loanproducts';
var templateSelector = "#productFormTemplate";
var width = 800;
var height = 550;
@@ -315,7 +316,7 @@
function refreshLoanProductsView() {
var jqxhr = $.ajax({
url: 'http://localhost:8080/mifosng-provider/api/v1/loanproducts', //'${allLoanProductsUrl}',
url: baseApiUrl + 'loanproducts',
type: 'GET',
contentType: 'application/json',
dataType: 'json',
@@ -335,8 +336,8 @@
$("a.editproduct").click( function(e) {
var linkId = this.id;
var productId = linkId.replace("editproduct", "");
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/loanproducts/' + productId;
var putUrl = 'http://localhost:8080/mifosng-provider/api/v1/loanproducts/' + productId;
var getUrl = baseApiUrl + 'loanproducts/' + productId;
var putUrl = baseApiUrl + 'loanproducts/' + productId;
var templateSelector = "#productFormTemplate";
var width = 800;
@@ -394,8 +395,8 @@
});
$('#addoffice').click(function(e) {
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/offices/template';
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/offices';
var getUrl = baseApiUrl + 'offices/template';
var postUrl = baseApiUrl + 'offices';
var templateSelector = "#officeFormTemplate";
var width = 600;
var height = 400;
@@ -411,7 +412,7 @@
function refreshOfficesView() {
var jqxhr = $.ajax({
url: 'http://localhost:8080/mifosng-provider/api/v1/offices', // '${allOfficesUrl}',
url: baseApiUrl + 'offices',
type: 'GET',
contentType: 'application/json',
dataType: 'json',
@@ -435,8 +436,8 @@
$("a.edit").click( function(e) {
var linkId = this.id;
var entityId = linkId.replace("edit", "");
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/offices/' + entityId;
var putUrl = 'http://localhost:8080/mifosng-provider/api/v1/offices/' + entityId;
var getUrl = baseApiUrl + 'offices/' + entityId;
var putUrl = baseApiUrl + 'offices/' + entityId;
var templateSelector = "#officeFormTemplate";
var width = 600;
@@ -482,8 +483,8 @@
// currency configuration
$('#editconfiguration').click(function(e) {
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/configurations/currency';
var putUrl = 'http://localhost:8080/mifosng-provider/api/v1/configurations/currency';
var getUrl = baseApiUrl + 'configurations/currency';
var putUrl = baseApiUrl + 'configurations/currency';
var templateSelector = "#configurationFormTemplate";
var width = 900;
var height = 400;
@@ -19,6 +19,7 @@ $(document).ready(function() {
// basic auth details
var base64 = "${basicAuthKey}";
var baseApiUrl = "${baseApiUrl}";
//
$.views.registerHelpers({
@@ -346,14 +347,14 @@ $(document).ready(function() {
}
$('#listusers').click(function(e) {
var listUrl = "http://localhost:8080/mifosng-provider/api/v1/users";
var listUrl = baseApiUrl + "users";
refreshUsersView();
e.preventDefault();
});
$('#adduser').click(function(e) {
var url = 'http://localhost:8080/mifosng-provider/api/v1/users/template';
var postUrl = "http://localhost:8080/mifosng-provider/api/v1/users";
var url = baseApiUrl + 'template';
var postUrl = baseApiUrl + "users";
var templateSelector = "#userFormTemplate";
var width = 1000;
var height = 550;
@@ -368,14 +369,14 @@ $(document).ready(function() {
});
$('#listroles').click(function(e) {
var listUrl = "http://localhost:8080/mifosng-provider/api/v1/roles";
var listUrl = baseApiUrl + "roles";
refreshRolesView();
e.preventDefault();
});
$('#addrole').click(function(e) {
var url = 'http://localhost:8080/mifosng-provider/api/v1/roles/template';
var postUrl = "http://localhost:8080/mifosng-provider/api/v1/roles";
var url = baseApiUrl +'template';
var postUrl = baseApiUrl + "roles";
var templateSelector = "#roleFormTemplate";
var width = 1000;
var height = 550;
@@ -397,7 +398,7 @@ $(document).ready(function() {
function refreshUsersView() {
var listUrl = 'http://localhost:8080/mifosng-provider/api/v1/users';
var listUrl = baseApiUrl + 'users';
var templateSelector = "#usersListTemplate";
var displayAreaDivSelector = "#contentplaceholder";
@@ -419,8 +420,8 @@ $(document).ready(function() {
$("a.edit").click( function(e) {
var linkId = this.id;
var entityId = linkId.replace("edit", "");
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/users/' + entityId;
var putUrl = 'http://localhost:8080/mifosng-provider/api/v1/users/' + entityId;
var getUrl = baseApiUrl + 'users/' + entityId;
var putUrl = baseApiUrl + 'users/' + entityId;
var templateSelector = "#userFormTemplate";
var width = 1000;
@@ -438,7 +439,7 @@ $(document).ready(function() {
$("a.delete").click( function(e) {
var linkId = this.id;
var entityId = linkId.replace("delete", "");
var url = 'http://localhost:8080/mifosng-provider/api/v1/users/' + entityId;
var url = baseApiUrl + 'users/' + entityId;
showNotAvailableDialog('dialog.title.functionality.not.available');
e.preventDefault();
@@ -464,7 +465,7 @@ $(document).ready(function() {
}
function refreshRolesView() {
var listUrl = 'http://localhost:8080/mifosng-provider/api/v1/roles';
var listUrl = baseApiUrl + 'roles';
var templateSelector = "#roleListTemplate";
var displayAreaDivSelector = "#contentplaceholder";
@@ -486,8 +487,8 @@ $(document).ready(function() {
$("a.edit").click( function(e) {
var linkId = this.id;
var entityId = linkId.replace("edit", "");
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/roles/' + entityId;
var putUrl = 'http://localhost:8080/mifosng-provider/api/v1/roles/' + entityId;
var getUrl = baseApiUrl + 'roles/' + entityId;
var putUrl = baseApiUrl + 'roles/' + entityId;
var templateSelector = "#roleFormTemplate";
var width = 1000;
@@ -505,7 +506,7 @@ $(document).ready(function() {
$("a.delete").click( function(e) {
var linkId = this.id;
var entityId = linkId.replace("delete", "");
var url = 'http://localhost:8080/mifosng-provider/api/v1/roles/' + entityId;
var url = baseApiUrl + 'roles/' + entityId;
showNotAvailableDialog('dialog.title.functionality.not.available');
e.preventDefault();
@@ -531,7 +532,7 @@ $(document).ready(function() {
}
function refreshPermissionsView() {
var listUrl = 'http://localhost:8080/mifosng-provider/api/v1/permissions';
var listUrl = baseApiUrl + 'permissions';
var templateSelector = "#permissionListTemplate";
var displayAreaDivSelector = "#contentplaceholder";
@@ -840,7 +840,7 @@ $(document).ready(function() {
<div id="newtabs">
<ul>
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}" title="clienttab" class="topleveltab"><span id="clienttabname">Loading...</span></a></li>
<li><a href="${baseApiUrl}clients/${clientId}" title="clienttab" class="topleveltab"><span id="clienttabname">Loading...</span></a></li>
</ul>
<div id="clienttab">
</div>
@@ -15,6 +15,6 @@
<script type="text/javascript" src="${resValue}/libs/DataTables-1.8.2/extras/TableTools/media/js/ZeroClipboard.js"></script>
<script type="text/javascript" src="${resValue}/libs/DataTables-1.8.2/extras/TableTools/media/js/TableTools.min.js"></script>
<script type="text/javascript" src="${resValue}/libs/jquery.i18n.properties-min-1.0.9.js"></script>
<script type="text/javascript" src="${resValue}/stretchyreporting/stretchyreporting-0.985.js"></script>
<script type="text/javascript" src="${resValue}/stretchyreporting/stretchyreporting-0.987.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -343,7 +343,7 @@ $(document).ready(function() {
</sec:authorize>
<div id="tabs">
<ul>
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients" title="searchtab"><spring:message code="tab.search"/></a></li>
<li><a href="${baseApiUrl}clients" title="searchtab"><spring:message code="tab.search"/></a></li>
</ul>
<div id="searchtab"></div>
</div>
@@ -15,6 +15,7 @@ $(document).ready(function() {
// basic auth details
var base64 = "${basicAuthKey}";
var baseApiUrl = "${baseApiUrl}";
$.views.registerHelpers({
@@ -197,7 +198,7 @@ $(document).ready(function() {
function repopulateFullForm(clientId, productId) {
var url = 'http://localhost:8080/mifosng-provider/api/v1/loans/template?clientId=' + clientId + '&productId=' + productId;
var url = baseApiUrl + 'loans/template?clientId=' + clientId + '&productId=' + productId;
var jqxhr = $.ajax({
url: url,
@@ -298,7 +299,7 @@ $(document).ready(function() {
}
function calculateLoanSchedule() {
var calculateLoanScheduleurl = 'http://localhost:8080/mifosng-provider/api/v1/loans?command=calculateLoanSchedule';
var calculateLoanScheduleurl = baseApiUrl + 'loans?command=calculateLoanSchedule';
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
@@ -328,7 +329,7 @@ $(document).ready(function() {
}
function submitLoanApplication() {
var submitLoanApplicationUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans';
var submitLoanApplicationUrl = baseApiUrl + 'loans';
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
@@ -361,7 +362,7 @@ $(document).ready(function() {
// on page load
var jqxhr = $.ajax({
url: 'http://localhost:8080/mifosng-provider/api/v1/loans/template?clientId=${clientId}',
url: baseApiUrl + 'loans/template?clientId=${clientId}',
type: 'GET',
contentType: 'application/json',
dataType: 'json',
@@ -64,7 +64,7 @@
<div id=myOutput></div>
<script language="javascript" type="text/javascript">
<script type="text/javascript">
function selectNewDecimals(selectedVal) {
if (!(selectedVal == "")) jQuery.stretchyReporting.changeDecimals(selectedVal);
@@ -91,8 +91,9 @@ function selectNewThousandsSep(selectedVal) {
var reportingParams = {
//rptDB: "mifosngproviderJ",
RESTUrl: "${baseUrl}api/v1/reports",
pentahoUrl: "${baseUrl}pentahoreport",
RESTUrl: "${baseApiUrl}reports",
basicAuthKey: "${basicAuthKey}",
pentahoUrl: "${baseApiUrl}pentahoreport",
bundleDir: "${resValue}/stretchyreporting/mifosngbundle/",
reportsListDiv: "myListOfReports",
runReportDiv: "myRunReportButton",
@@ -370,7 +370,7 @@
<span class="longrowlabel"><spring:message code="label.client.account.pending.approval.loans"/> ({{=$ctx.number(pendingApprovalLoanCount)}}):</span>
<span class="rowvalue">
{{#each pendingApprovalLoans}}
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
<span class="loanaccount"><a href="${baseApiUrl}loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
{{/each}}
</span>
</div>
@@ -381,7 +381,7 @@
<span class="longrowlabel"><spring:message code="label.client.account.pending.disbursal.loans"/> ({{=$ctx.number(awaitingDisbursalLoanCount)}}):</span>
<span class="rowvalue">
{{#each awaitingDisbursalLoans}}
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
<span class="loanaccount"><a href="${baseApiUrl}loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
{{/each}}
</span>
</div>
@@ -392,7 +392,7 @@
<span class="longrowlabel"><spring:message code="label.client.account.active.loans"/> ({{=$ctx.number(activeLoanCount)}}):</span>
<span class="rowvalue">
{{#each openLoans}}
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
<span class="loanaccount"><a href="${baseApiUrl}loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
{{/each}}
</span>
</div>
@@ -403,7 +403,7 @@
<div class="longrowlabel"><spring:message code="label.client.account.closed.loans"/> ({{=$ctx.number(closedLoanCount)}}):</div>
<div class="rowvalue">
{{#each closedLoans}}
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
<span class="loanaccount"><a href="${baseApiUrl}loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span>
{{/each}}
</div>
</div>