remove hard coded reference to localhost:8080 in areas.2

This commit is contained in:
Keith Woodlock
2012-05-18 13:57:47 +01:00
parent ac8c68a435
commit 965429e30e
17 changed files with 582 additions and 402 deletions
@@ -9,6 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement;
public class AuthenticatedUserData {
private String username;
private String base64EncodedAuthenticationKey;
private boolean authenticated = false;
private Collection<String> permissions = new ArrayList<String>();
@@ -43,4 +44,13 @@ public class AuthenticatedUserData {
public void setAuthenticated(boolean authenticated) {
this.authenticated = authenticated;
}
public String getBase64EncodedAuthenticationKey() {
return base64EncodedAuthenticationKey;
}
public void setBase64EncodedAuthenticationKey(
String base64EncodedAuthenticationKey) {
this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey;
}
}
@@ -0,0 +1,119 @@
package org.mifosng.ui;
import org.mifosng.configuration.ApplicationConfigurationService;
import org.mifosng.configuration.OAuthProviderDetails;
import org.mifosng.ui.infrastructure.BasicAuthUserDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
/**
* Controller responsible for routing requests on client application to correct jsp page.
*/
@Controller
public class ApplicationPagesRoutesController {
private final ApplicationConfigurationService applicationConfigurationService;
@Autowired
public ApplicationPagesRoutesController(ApplicationConfigurationService applicationConfigurationService) {
this.applicationConfigurationService = applicationConfigurationService;
}
@ExceptionHandler(AccessDeniedException.class)
public String accessDeniedException() {
return "unAuthorizedAction";
}
@RequestMapping(value="/", method = RequestMethod.GET)
public String redirectToIndexPage(final Model model, final Authentication authentication) {
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
return "redirect:/home";
}
@RequestMapping(value = "/home", method = RequestMethod.GET)
public ModelAndView showIndividualClientsOnHomePage(final Model model, final Authentication authentication) {
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
return new ModelAndView("/home");
}
@RequestMapping(value="/switchToClient", method = RequestMethod.POST)
public String switchToClientView(@RequestParam("client") final Long client) {
return "redirect:/portfolio/client/" + client;
}
@RequestMapping(value = "/portfolio/client/{clientId}", method = RequestMethod.GET)
public String viewClientAccount(final Model model, final Authentication authentication, @PathVariable("clientId") final Long clientId) {
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
model.addAttribute("clientId", clientId);
return "client/viewClientAccount";
}
@RequestMapping(value = "/org/admin", method = RequestMethod.GET)
public String organisationAdminScreen(final Model model, final Authentication authentication) {
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
return "admin/orghome";
}
@RequestMapping(value = "/org/admin/user", method = RequestMethod.GET)
public String userAdminScreen(final Model model, final Authentication authentication) {
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
return "admin/userhome";
}
@RequestMapping(value = "/org/admin/settings", method = RequestMethod.GET)
public String userSettingsScreen(final Model model, final Authentication authentication) {
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
return "admin/accountsettings";
}
@RequestMapping(value = "/portfolio/client/{clientId}/loan/new", method = RequestMethod.GET)
public String loadLoanCreationWorkflow(final Model model, final Authentication authentication, @PathVariable("clientId") final Long clientId) {
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
model.addAttribute("clientId", clientId);
return "newloanapplication";
}
@RequestMapping(value = "/reporting/flexireport", method = RequestMethod.GET)
public String viewFlexibleReportingPage(final Model model, final Authentication authentication) {
OAuthProviderDetails oauthDetails = this.applicationConfigurationService.retrieveOAuthProviderDetails();
BasicAuthUserDetails userDetails = (BasicAuthUserDetails) authentication.getPrincipal();
model.addAttribute("basicAuthKey", userDetails.getBasicAuthenticationKey());
model.addAttribute("baseApiUrl", userDetails.getFullApiUrl());
model.addAttribute("baseUrl", oauthDetails.getProviderBaseUrl());
return "reports/flexireport";
}
}
@@ -1,73 +0,0 @@
package org.mifosng.ui.admin;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
/**
* Controller responsible for routing requests on client application to correct jsp page.
*/
@Controller
public class ApplicationPagesRoutesController {
@ExceptionHandler(AccessDeniedException.class)
public String accessDeniedException() {
return "unAuthorizedAction";
}
@RequestMapping(value="/", method = RequestMethod.GET)
public String redirectToIndexPage() {
return "redirect:/home";
}
@RequestMapping(value = "/home", method = RequestMethod.GET)
public ModelAndView showIndividualClientsOnHomePage() {
return new ModelAndView("/home");
}
@RequestMapping(value="/switchToClient", method = RequestMethod.POST)
public String switchToClientView(@RequestParam("client") final Long client) {
return "redirect:/portfolio/client/" + client;
}
@RequestMapping(value = "/portfolio/client/{clientId}", method = RequestMethod.GET)
public String viewClientAccount(final Model model, @PathVariable("clientId") final Long clientId) {
model.addAttribute("clientId", clientId);
return "client/viewClientAccount";
}
@RequestMapping(value = "/org/admin", method = RequestMethod.GET)
public String organisationAdminScreen() {
return "admin/orghome";
}
@RequestMapping(value = "/org/admin/user", method = RequestMethod.GET)
public String userAdminScreen() {
return "admin/userhome";
}
@RequestMapping(value = "/org/admin/settings", method = RequestMethod.GET)
public String userSettingsScreen() {
return "admin/accountsettings";
}
@RequestMapping(value = "/portfolio/client/{clientId}/loan/new", method = RequestMethod.GET)
public String loadLoanCreationWorkflow(final Model model, @PathVariable("clientId") final Long clientId) {
// UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) principal;
// ConsumerUserDetails user = (ConsumerUserDetails) authenticationToken.getPrincipal();
// if (user.hasNoAuthorityToSumitLoanApplication()) {
// throw new AccessDeniedException("");
// }
model.addAttribute("clientId", clientId);
return "newloanapplication";
}
}
@@ -4,6 +4,8 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import org.mifosng.configuration.ApplicationConfigurationService;
import org.mifosng.configuration.OAuthProviderDetails;
import org.mifosng.data.AuthenticatedUserData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
@@ -13,20 +15,26 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.client.RestTemplate;
/**
* A {@link AbstractUserDetailsAuthenticationProvider} which is responsible for delegating authentication to the mifos platform API.
* A {@link AbstractUserDetailsAuthenticationProvider} which is responsible for delegating authentication to the mifos platform API.
*
* If successful, the permissions associated with the authenticated user are returned. As this class is used as a hook into spring security,
* a proper authentication object is persisted for this client applications {@link SecurityContext}.
*/
public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
private final RestTemplate restTemplate;
private final ApplicationConfigurationService applicationConfigurationService;
@Autowired
public ApiDelegatingAuthenticationProvider(final RestTemplate restTemplate) {
public ApiDelegatingAuthenticationProvider(final RestTemplate restTemplate, final ApplicationConfigurationService applicationConfigurationService) {
this.restTemplate = restTemplate;
this.applicationConfigurationService = applicationConfigurationService;
}
@Override
@@ -38,7 +46,12 @@ public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuth
String password = (String) authentication.getCredentials();
URI restUri = URI.create("http://localhost:8080/mifosng-provider/api/v1/authentication?username=" + username + "&password=" + password);
OAuthProviderDetails oauthDetails = this.applicationConfigurationService.retrieveOAuthProviderDetails();
String apiVersion = "api/v1/";
String authUrlExtension = "authentication?username=" + username + "&password=" + password;
StringBuilder authenticationApiUrl = new StringBuilder(oauthDetails.getProviderBaseUrl()).append(apiVersion).append(authUrlExtension);
URI restUri = URI.create(authenticationApiUrl.toString());
ResponseEntity<AuthenticatedUserData> s = this.restTemplate.postForEntity(restUri, authRequest(), AuthenticatedUserData.class);
UserDetails userDetails = null;
@@ -49,7 +62,8 @@ public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuth
for (String permission : authenticatedUserData.getPermissions()) {
authorities.add(new SimpleGrantedAuthority(permission));
}
userDetails = new User(authenticatedUserData.getUsername(), "[not needed]", authorities);
User user = new User(authenticatedUserData.getUsername(), "[not needed]", authorities);
userDetails = new BasicAuthUserDetails(user, authenticatedUserData.getBase64EncodedAuthenticationKey(), oauthDetails.getProviderBaseUrl(), apiVersion);
}
return userDetails;
@@ -63,4 +77,4 @@ public class ApiDelegatingAuthenticationProvider extends AbstractUserDetailsAuth
HttpEntity<Object> requestEntity = new HttpEntity<Object>(requestHeaders);
return requestEntity;
}
}
}
@@ -0,0 +1,73 @@
package org.mifosng.ui.infrastructure;
import java.util.Collection;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
public class BasicAuthUserDetails implements UserDetails {
private final User user;
private final String basicAuthenticationKey;
private final String apiBaseUrl;
private final String apiVersion;
public BasicAuthUserDetails(User user, String basicAuthenticationKey, String apiBaseUrl, String apiVersion) {
this.user = user;
this.basicAuthenticationKey = basicAuthenticationKey;
this.apiBaseUrl = apiBaseUrl;
this.apiVersion = apiVersion;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return this.user.getAuthorities();
}
@Override
public String getPassword() {
return this.getPassword();
}
@Override
public String getUsername() {
return this.user.getUsername();
}
@Override
public boolean isAccountNonExpired() {
return this.user.isAccountNonExpired();
}
@Override
public boolean isAccountNonLocked() {
return this.user.isAccountNonExpired();
}
@Override
public boolean isCredentialsNonExpired() {
return this.user.isCredentialsNonExpired();
}
@Override
public boolean isEnabled() {
return this.user.isEnabled();
}
public String getBasicAuthenticationKey() {
return basicAuthenticationKey;
}
public String getApiBaseUrl() {
return apiBaseUrl;
}
public String getApiVersion() {
return apiVersion;
}
public String getFullApiUrl() {
return this.apiBaseUrl + apiVersion;
}
}
@@ -1,48 +0,0 @@
package org.mifosng.ui.reporting;
import org.mifosng.configuration.ApplicationConfigurationService;
import org.mifosng.configuration.OAuthProviderDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/reporting")
public class ReportingController {
private final ApplicationConfigurationService applicationConfigurationService;
@Autowired
public ReportingController(
ApplicationConfigurationService applicationConfigurationService) {
this.applicationConfigurationService = applicationConfigurationService;
}
@RequestMapping(value = "/flexireport", method = RequestMethod.GET)
public String viewFlexibleReportingPage(final Model model) {
// UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) principal;
// ConsumerUserDetails user = (ConsumerUserDetails) authenticationToken.getPrincipal();
// if (user.hasNoReportingAuthority()) {
// throw new AccessDeniedException("");
// }
OAuthProviderDetails oauthDetails = this.applicationConfigurationService
.retrieveOAuthProviderDetails();
model.addAttribute("baseUrl", oauthDetails.getProviderBaseUrl());
// model.addAttribute("consumerKey", oauthDetails.getConsumerkey());
// model.addAttribute("consumerSecret", oauthDetails.getSharedSecret());
//
return "reports/flexireport";
}
@ExceptionHandler(AccessDeniedException.class)
public String accessDeniedException() {
return "unAuthorizedAction";
}
}
@@ -4,12 +4,14 @@
$.stretchyData.displayAllExtraData = function(params) {
username="mifos";
password="password";
if (!(params.url)) {
alert(doI18N("reportingInitError - url parameter"));
return;
}
if (!(params.basicAuthKey)) {
alert(doI18N("reportingInitError - basicAuthKey parameter"));
return;
}
if (!(params.datasetType)) {
alert(doI18N("reportingInitError - datasetType parameter"));
return;
@@ -35,15 +37,13 @@
var valueClass = "";
if (params.valueClass)
valueClass = params.valueClass;
displayAllExtraData(params.url, params.datasetType,
displayAllExtraData(params.url, params.basicAuthKey, params.datasetType,
params.datasetPKValue, params.datasetTypeDiv, headingPrefix,
headingClass, labelClass, valueClass);
};
$.stretchyData.popupEditDialog = function(url, datasetType, datasetName,
datasetPKValue, dsnDivName, title, width, height) {
popupEditDialog(url, datasetType, datasetName, datasetPKValue,
dsnDivName, title, width, height);
$.stretchyData.popupEditDialog = function(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName, title, width, height) {
popupEditDialog(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName, title, width, height);
};
displayAllSuccessFunction = function(data, textStatus, jqXHR) {
@@ -61,7 +61,7 @@
+ doI18N(data.additionalFieldsSets[i].name)
+ ' - </span></b> ';
extraDataNamesVar += editExtraDataLink(displayAllVars.url,
extraDataNamesVar += editExtraDataLink(displayAllVars.url, displayAllVars.basicAuthKey,
displayAllVars.datasetType,
data.additionalFieldsSets[i].name,
displayAllVars.datasetPKValue, dsnDivName);
@@ -73,7 +73,7 @@
for ( var i in data.additionalFieldsSets) {
var dsnDivName = generateDsnDivName(displayAllVars.datasetType, i,
displayAllVars.datasetTypeDiv);
viewExtraData(displayAllVars.url, displayAllVars.datasetType,
viewExtraData(displayAllVars.url, displayAllVars.basicAuthKey, displayAllVars.datasetType,
data.additionalFieldsSets[i].name,
displayAllVars.datasetPKValue, dsnDivName);
}
@@ -84,11 +84,12 @@
alert(jqXHR.responseText);
};
function displayAllExtraData(url, datasetType, datasetPKValue,
function displayAllExtraData(url, basicAuthKey, datasetType, datasetPKValue,
datasetTypeDiv, headingPrefix, headingClass, labelClass, valueClass) {
displayAllVars = {
url : url,
basicAuthKey : basicAuthKey,
datasetType : datasetType,
datasetPKValue : datasetPKValue,
datasetTypeDiv : datasetTypeDiv,
@@ -98,16 +99,14 @@
valueClass : valueClass
};
displayAllUrl = url + "api/v1/additionalfields?type="
+ encodeURIComponent(datasetType);
getData(displayAllUrl, displayAllSuccessFunction,
displayAllErrorFunction);
displayAllUrl = url + "additionalfields?type=" + encodeURIComponent(datasetType);
getData(displayAllUrl, basicAuthKey, displayAllSuccessFunction, displayAllErrorFunction);
}
function editExtraDataLink(url, datasetType, datasetName, datasetPKValue,
function editExtraDataLink(url, basicAuthKey, datasetType, datasetName, datasetPKValue,
dsnDivName) {
var popupVar = "jQuery.stretchyData.popupEditDialog('" + url + "', '"
var popupVar = "jQuery.stretchyData.popupEditDialog('" + url + "', '" + basicAuthKey + "', '"
+ datasetType + "', '" + datasetName + "', " + datasetPKValue
+ ", '" + dsnDivName + "', '" + doI18N("Edit") + " "
+ doI18N(datasetName) + "', 900, 500)";
@@ -162,9 +161,8 @@
alert(jqXHR.responseText);
};
function viewExtraData(url, datasetType, datasetName, datasetPKValue,
dsnDivName) {
var viewExtraDataUrl = url + "api/v1/additionalfields/"
function viewExtraData(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName) {
var viewExtraDataUrl = url + "additionalfields/"
+ encodeURIComponent(datasetType) + "/"
+ encodeURIComponent(datasetName) + "/"
+ encodeURIComponent(datasetPKValue);
@@ -172,22 +170,20 @@
var evalViewExtraDataSuccessFunction = "var viewExtraDataSuccessFunction = function(data, textStatus, jqXHR){ viewExtraDataset(data, '"
+ dsnDivName + "'); };"
eval(evalViewExtraDataSuccessFunction);
getData(viewExtraDataUrl, viewExtraDataSuccessFunction,
viewExtraDataErrorFunction);
getData(viewExtraDataUrl, basicAuthKey, viewExtraDataSuccessFunction, viewExtraDataErrorFunction);
}
popupEditErrorFunction = function(jqXHR, textStatus, errorThrown) {
alert("error");
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate",
"#formerrors");
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
};
popupEditSuccessFunction = function(data, textStatus, jqXHR) {
currentEditPopup.dialogDiv.append(extraDataBuildTemplate(data));
extraDataOpenDialog(currentEditPopup.url);
extraDataOpenDialog(currentEditPopup.url, currentEditPopup.basicAuthKey);
extraDataFormatDates(data.columnHeaders);
};
function popupEditDialog(url, datasetType, datasetName, datasetPKValue,
dsnDivName, title, width, height) {
function popupEditDialog(url, basicAuthKey, datasetType, datasetName, datasetPKValue, dsnDivName, title, width, height) {
currentEditPopup = {
dialogDiv : $("<div id='dialog-form'></div>"),
@@ -199,13 +195,13 @@
datasetName : datasetName,
datasetPKValue : datasetPKValue,
baseUrl : url,
url : url + "api/v1/additionalfields/"
basicAuthKey : basicAuthKey,
url : url + "additionalfields/"
+ encodeURIComponent(datasetType) + "/"
+ encodeURIComponent(datasetName) + "/"
+ encodeURIComponent(datasetPKValue)
};
getData(currentEditPopup.url, popupEditSuccessFunction,
popupEditErrorFunction);
getData(currentEditPopup.url, currentEditPopup.basicAuthKey, popupEditSuccessFunction, popupEditErrorFunction);
}
function generateDsnDivName(datasetType, i, uniqueDivid) {
@@ -368,7 +364,7 @@
return o;
};
function extraDataOpenDialog(url) {
function extraDataOpenDialog(url, basicAuthKey) {
// var saveButton = jQuery.i18n.prop('dialog.button.save');
// var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
@@ -382,20 +378,17 @@
});
var form_data = JSON.stringify($('#entityform').serializeObject());
// console.log(form_data);
var jqxhr = $.ajax({
url : url,
type : 'POST',
contentType : "application/json; charset=utf-8",
// dataType : 'jsonp',
// crossDomain : true,
dataType : 'json',
data : form_data,
cache : false,
beforeSend : function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
console.log("base64: " + basicAuthKey);
xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey);
},
success : function(data, textStatus, jqXHR) {
currentEditPopup.dialogDiv.dialog("close");
@@ -406,8 +399,7 @@
currentEditPopup.dsnDivName)
},
error : function(jqXHR, textStatus, errorThrown) {
handleXhrError(jqXHR, textStatus, errorThrown,
"#formErrorsTemplate", "#formerrors");
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}
});
};
@@ -457,23 +449,18 @@
/* end of code to fill data in edit form and display it */
function getData(url, successFunction, errorFunction) {
function getData(url, basicAuthKey, successFunction, errorFunction) {
$.ajax({
url : url,
cache : false,
type : 'GET',
contentType : "application/json; charset=utf-8",
dataType : 'json',
cache : false,
beforeSend : function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
console.log("base64: " + basicAuthKey);
xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey);
},
// dataType : 'jsonp',
// crossDomain : true,
dataType : 'json',
// crossDomain : false,
success : successFunction,
error : errorFunction
});
@@ -20,6 +20,9 @@
<script>
$(document).ready(function() {
// basic auth details
var base64 = "${basicAuthKey}";
// these helpers are registered for the jsViews and jsRender functionality to fix bug with display zero!
$.views.registerHelpers({
@@ -210,71 +213,80 @@ $(document).ready(function() {
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
console.log(data);
var formHtml = $(templateSelector).render(data);
dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[saveButton] = function() {
console.log(data);
var formHtml = $(templateSelector).render(data);
$('#notSelectedItems option').each(function(i) {
dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[saveButton] = function() {
$('#notSelectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#selectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#selectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
var jqxhr = $.ajax({
url: postUrl,
type: submitType,
contentType: 'application/json',
dataType: 'json',
data: newFormData,
success: saveSuccessFunction,
error: function(jqXHR, textStatus, errorThrown) {
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}
});
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {
$('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('#remove').click(function() {
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
$('#entityform input').first().focus();
}
}).dialog('open');
}
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
var jqxhr = $.ajax({
url: postUrl,
type: submitType,
contentType: 'application/json',
dataType: 'json',
data: newFormData,
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: saveSuccessFunction,
error: function(jqXHR, textStatus, errorThrown) {
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}
});
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {
$('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('#remove').click(function() {
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
$('#entityform input').first().focus();
}
}).dialog('open');
}
});
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
@@ -288,6 +300,10 @@ $(document).ready(function() {
dataType: 'json',
contentType: 'application/json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
error: function( xhr, status, index, anchor) {
$(anchor.hash).html("error occured while ajax loading.");
},
@@ -15,6 +15,9 @@
<script>
$(document).ready(function() {
// basic auth details
var base64 = "${basicAuthKey}";
// these helpers are registered for the jsViews and jsRender functionality to fix bug with display zero!
$.views.registerHelpers({
@@ -208,71 +211,80 @@
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
console.log(data);
var formHtml = $(templateSelector).render(data);
dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[saveButton] = function() {
$('#notSelectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#selectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
var jqxhr = $.ajax({
url: postUrl,
type: submitType,
contentType: 'application/json',
dataType: 'json',
data: newFormData,
success: saveSuccessFunction,
error: function(jqXHR, textStatus, errorThrown) {
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}
});
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {
$('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('#remove').click(function() {
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
$('#entityform input').first().focus();
}
}).dialog('open');
}
console.log(data);
var formHtml = $(templateSelector).render(data);
dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[saveButton] = function() {
$('#notSelectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#selectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
var jqxhr = $.ajax({
url: postUrl,
type: submitType,
contentType: 'application/json',
dataType: 'json',
data: newFormData,
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: saveSuccessFunction,
error: function(jqXHR, textStatus, errorThrown) {
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}
});
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {
$('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('#remove').click(function() {
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
$('#entityform input').first().focus();
}
}).dialog('open');
}
});
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
@@ -308,6 +320,10 @@
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
var productlistParent = new Object();
@@ -399,6 +415,11 @@
type: 'GET',
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
$.each(data.offices, function(i, item) {
@@ -16,7 +16,11 @@
<c:url value="/" var="rootContext" />
<script>
$(document).ready(function() {
// basic auth details
var base64 = "${basicAuthKey}";
//
$.views.registerHelpers({
money: function(monetaryObj) {
@@ -183,71 +187,80 @@ $(document).ready(function() {
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
console.log(data);
var formHtml = $(templateSelector).render(data);
dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[saveButton] = function() {
console.log(data);
var formHtml = $(templateSelector).render(data);
$('#notSelectedItems option').each(function(i) {
dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[saveButton] = function() {
$('#notSelectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#selectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#selectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
var jqxhr = $.ajax({
url: postUrl,
type: submitType,
contentType: 'application/json',
dataType: 'json',
data: newFormData,
success: saveSuccessFunction,
error: function(jqXHR, textStatus, errorThrown) {
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}
});
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {
$('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('#remove').click(function() {
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
$('#entityform input').first().focus();
}
}).dialog('open');
}
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
var jqxhr = $.ajax({
url: postUrl,
type: submitType,
contentType: 'application/json',
dataType: 'json',
data: newFormData,
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: saveSuccessFunction,
error: function(jqXHR, textStatus, errorThrown) {
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
}
});
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {
$('#add').click(function() {
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('#remove').click(function() {
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
$('#entityform input').first().focus();
}
}).dialog('open');
}
});
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
@@ -263,6 +276,10 @@ $(document).ready(function() {
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
console.log(data);
var tableHtml = $(templateSelector).render(data);
@@ -292,6 +309,11 @@ $(document).ready(function() {
type: 'DELETE',
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
$('#listusers').click();
}
@@ -384,6 +406,11 @@ $(document).ready(function() {
type: 'GET',
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
console.log(data);
var officeListHtml = $(templateSelector).render(data);
@@ -446,6 +473,11 @@ $(document).ready(function() {
type: 'GET',
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
console.log(data);
var listHtml = $(templateSelector).render(data);
@@ -508,6 +540,11 @@ $(document).ready(function() {
type: 'GET',
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
console.log(data);
var listHtml = $(templateSelector).render(data);
@@ -21,8 +21,10 @@ div.notespacer {margin-top: 5px; margin-bottom: 5px;}
<script>
$(document).ready(function() {
var username="mifos";
var password="password";
// 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({
@@ -222,7 +224,6 @@ $(document).ready(function() {
contentType: 'application/json',
dataType: 'json',
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -286,7 +287,6 @@ $(document).ready(function() {
cache: false,
data: newFormData,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -340,7 +340,6 @@ $(document).ready(function() {
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -374,7 +373,6 @@ $(document).ready(function() {
dataType: 'json',
data: newFormData,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -435,7 +433,6 @@ $(document).ready(function() {
contentType: 'application/json',
cache: false,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -491,7 +488,7 @@ $(document).ready(function() {
$('.addnotebtn').button().click(function(e) {
var linkId = this.id;
var clientId = linkId.replace("addnotebtn", "");
var getAndPostUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/' + clientId + '/notes';
var getAndPostUrl = baseApiUrl + 'clients/' + clientId + '/notes';
var templateSelector = "#noteFormTemplate";
var width = 600;
@@ -511,7 +508,8 @@ $(document).ready(function() {
// retrieve additional info
var additionalFieldsParams = {
url: "http://localhost:8080/mifosng-provider/",
url: baseApiUrl,
basicAuthKey: base64,
datasetType: "portfolio_client",
datasetPKValue: data.id,
datasetTypeDiv: "clientadditionaldata",
@@ -546,7 +544,7 @@ $(document).ready(function() {
$('.rejectloan').button().click(function(e) {
var linkId = this.id;
var loanId = linkId.replace("rejectbtn", "");
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '?command=reject';
var postUrl = baseApiUrl + 'loans/' + loanId + '?command=reject';
var templateSelector = "#stateTransitionLoanFormTemplate";
var width = 500;
var height = 350;
@@ -559,7 +557,7 @@ $(document).ready(function() {
$('.withdrawnbyapplicantloan').button().click(function(e) {
var linkId = this.id;
var loanId = linkId.replace("withdrawnbyapplicantloanbtn", "");
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '?command=withdrewbyclient';
var postUrl = baseApiUrl + 'loans/' + loanId + '?command=withdrewbyclient';
var templateSelector = "#stateTransitionLoanFormTemplate";
var width = 500;
var height = 350;
@@ -573,7 +571,7 @@ $(document).ready(function() {
var linkId = this.id;
var loanId = linkId.replace("approvebtn", "");
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '?command=approve';
var postUrl = baseApiUrl + 'loans/' + loanId + '?command=approve';
var templateSelector = "#stateTransitionLoanFormTemplate";
var width = 500;
var height = 350;
@@ -587,7 +585,7 @@ $(document).ready(function() {
var linkId = this.id;
var loanId = linkId.replace("deletebtn", "");
var url = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId;
var url = baseApiUrl + 'loans/' + loanId;
var width = 400;
var height = 225;
@@ -602,7 +600,7 @@ $(document).ready(function() {
var linkId = this.id;
var loanId = linkId.replace("undoapprovebtn", "");
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '/undo?command=undoapproval';
var postUrl = baseApiUrl + 'loans/' + loanId + '/undo?command=undoapproval';
var width = 400;
var height = 225;
popupConfirmationDialogAndPost(postUrl, 'POST', 'dialog.title.undo.loan.approval', width, height, currentTabIndex);
@@ -614,7 +612,7 @@ $(document).ready(function() {
var linkId = this.id;
var loanId = linkId.replace("undodisbursalbtn", "");
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '/undo?command=undodisbursal';
var postUrl = baseApiUrl + 'loans/' + loanId + '/undo?command=undodisbursal';
var width = 400;
var height = 150;
popupConfirmationDialogAndPost(postUrl, 'POST', 'dialog.title.undo.loan.disbursal', width, height, currentTabIndex);
@@ -626,7 +624,7 @@ $(document).ready(function() {
var linkId = this.id;
var loanId = linkId.replace("disbursebtn", "");
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '?command=disburse';
var postUrl = baseApiUrl + 'loans/' + loanId + '?command=disburse';
var templateSelector = "#stateTransitionLoanFormTemplate";
var width = 500;
var height = 350;
@@ -640,8 +638,8 @@ $(document).ready(function() {
var linkId = this.id;
var loanId = linkId.replace("repaymentbtn", "");
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '/transactions/template?transactionType=repayment';
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '/transactions?transactionType=repayment';
var getUrl = baseApiUrl + 'loans/' + loanId + '/transactions/template?transactionType=repayment';
var postUrl = baseApiUrl + 'loans/' + loanId + '/transactions?transactionType=repayment';
var templateSelector = "#transactionLoanFormTemplate";
var width = 500;
@@ -663,8 +661,8 @@ $(document).ready(function() {
var linkId = this.id;
var loanId = linkId.replace("waivebtn", "");
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '/transactions/template?transactionType=waiver';
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '/transactions?transactionType=waiver';
var getUrl = baseApiUrl + 'loans/' + loanId + '/transactions/template?transactionType=waiver';
var postUrl = baseApiUrl + 'loans/' + loanId + '/transactions?transactionType=waiver';
var templateSelector = "#transactionLoanFormTemplate";
var width = 500;
@@ -689,7 +687,7 @@ $(document).ready(function() {
var ids = loanAndRepaymentId.split("_");
var loanId = ids[0];
var transactionId = ids[1];
var getAndPutUrl = 'http://localhost:8080/mifosng-provider/api/v1/loans/' + loanId + '/transactions/' + transactionId;
var getAndPutUrl = baseApiUrl + 'loans/' + loanId + '/transactions/' + transactionId;
var templateSelector = "#transactionLoanFormTemplate";
var width = 500;
@@ -709,7 +707,8 @@ $(document).ready(function() {
// additional data
var additionalFieldsParams = {
url: "http://localhost:8080/mifosng-provider/",
url: baseApiUrl,
basicAuthKey: base64,
datasetType: "portfolio_loan",
datasetPKValue: data.id,
datasetTypeDiv: "loanadditionaldata" + data.id,
@@ -728,13 +727,12 @@ $(document).ready(function() {
function refreshLoanSummaryInfo() {
var jqxhr = $.ajax({
url: 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/loans',
url: baseApiUrl + 'clients/${clientId}/loans',
type: 'GET',
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -764,13 +762,12 @@ $(document).ready(function() {
var arrayIndex = 0;
var jqxhr = $.ajax({
url: 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/notes',
url: baseApiUrl + 'clients/${clientId}/notes',
type: 'GET',
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -787,7 +784,7 @@ $(document).ready(function() {
$('.editclientnote').click(function(e) {
var linkId = this.id;
var noteId = linkId.replace("editclientnotelink", "");
var getAndPutUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/notes/' + noteId;
var getAndPutUrl = baseApiUrl + 'clients/${clientId}/notes/' + noteId;
var templateSelector = "#noteFormTemplate";
var width = 600;
var height = 400;
@@ -16,6 +16,5 @@
<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}/libs/jquery.base64.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -34,8 +34,7 @@
<script type="text/javascript" src="${resValue}/libs/jquery.views.js"></script>
<script type="text/javascript" src="${resValue}/libs/jquery.observable.min.js"></script>
<script type="text/javascript" src="${resValue}/libs/globalize/globalize.js"></script>
<script type="text/javascript" src="${resValue}/stretchydata-0.945.js"></script>
<script type="text/javascript" src="${resValue}/libs/jquery.base64.js"></script>
<script type="text/javascript" src="${resValue}/stretchydata-0.947.js"></script>
<c:choose>
<c:when test="${not empty language}">
@@ -13,6 +13,10 @@
<script>
$(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({
@@ -207,7 +211,6 @@ $(document).ready(function() {
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -283,9 +286,6 @@ $(document).ready(function() {
});
}
var username = "mifos";
var password = "password";
$("#tabs").tabs({
"ajaxOptions": {
type: 'GET',
@@ -293,7 +293,6 @@ $(document).ready(function() {
contentType: 'application/json',
cache: false,
beforeSend: function(xhr) {
var base64 = $.base64Encode(username + ":" + password);
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
@@ -317,8 +316,8 @@ $(document).ready(function() {
}
$("#addclient").button().click(function(e) {
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/template';
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients';
var getUrl = baseApiUrl + 'clients/template';
var postUrl = baseApiUrl + 'clients';
var templateSelector = "#clientFormTemplate";
var width = 600;
var height = 350;
@@ -13,7 +13,10 @@
<script>
$(document).ready(function() {
$.views.registerHelpers({
// basic auth details
var base64 = "${basicAuthKey}";
$.views.registerHelpers({
money: function(monetaryObj) {
@@ -202,6 +205,10 @@ $.views.registerHelpers({
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
var formHtml = $("#newLoanFormTemplate").render(data);
@@ -302,6 +309,11 @@ $.views.registerHelpers({
contentType: 'application/json',
dataType: 'json',
data: newFormData,
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
removeErrors("#formerrors");
var loanScheduleHtml = $("#newLoanScheduleTemplate").render(data);
@@ -327,6 +339,15 @@ $.views.registerHelpers({
contentType: 'application/json',
dataType: 'json',
data: newFormData,
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
var localAppUrlToSwitchToClientPage = '${rootContext}portfolio/client/${clientId}';
window.location.href = localAppUrlToSwitchToClientPage;
@@ -345,6 +366,10 @@ $.views.registerHelpers({
contentType: 'application/json',
dataType: 'json',
cache: false,
beforeSend: function(xhr) {
console.log("base64: " + base64);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, textStatus, jqXHR) {
var formHtml = $("#newLoanFormTemplateMin").render(data);
@@ -32,7 +32,7 @@
<td valign="top"><div id=myClearReportButton></div></td>
<td valign="bottom">
<select id=decimalsChoice onChange="selectNewDecimals(options[selectedIndex].value)" >
<option value="" SELECTED>Decimals</option>
<option value="" selected="selected">Decimals</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
@@ -45,7 +45,7 @@
</td>
<td valign="bottom">
<select id=decimalsThousandsSep onChange="selectNewThousandsSep(options[selectedIndex].value)" >
<option value="" SELECTED>Format</option>
<option value="" selected="selected">Format</option>
<option value=",.">1,234,567.89</option>
<option value=".,">1.234.567,89</option>
<option value=" ,">1 234 567,89</option>
@@ -21,6 +21,8 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component;
import com.sun.jersey.core.util.Base64;
@Path("/v1/authentication")
@Component
@Scope("singleton")
@@ -49,6 +51,9 @@ public class AuthenticationApiResource {
}
authenticatedUserData.setPermissions(permissions);
authenticatedUserData.setAuthenticated(true);
byte[] base64EncodedAuthenticationKey = Base64.encode(username + ":" + password);
authenticatedUserData.setBase64EncodedAuthenticationKey(new String(base64EncodedAuthenticationKey));
}
return Response.ok().entity(authenticatedUserData).build();