Skip to content

Commit

Permalink
Added fixed parameter restcommBaseUrl to UI
Browse files Browse the repository at this point in the history
Refers #137
  • Loading branch information
otsakir committed May 11, 2017
2 parents 4befdbb + 6560310 commit e0bfd4e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Expand Up @@ -80,7 +80,7 @@ public class RvdConfiguration {
private RvdConfig rvdConfig; // the configuration settings from rvd.xml
private RestcommConfig restcommConfig;

private String contextRootPath;
private String contextRootPath; // e.g. a/path/ending/in/slash/
private URI restcommBaseUri;
private Integer externalServiceTimeout;
private Boolean videoSupport;
Expand All @@ -93,13 +93,14 @@ public class RvdConfiguration {
}

public RvdConfiguration(ServletContext servletContext) {
contextRootPath = servletContext.getRealPath("/");
logger.info("context root path is " + contextRootPath);
load();
this(servletContext.getRealPath("/"));
}

public RvdConfiguration(String contextRootPath) {
this.contextRootPath = contextRootPath;
// append trailing slash if not already there
if (this.contextRootPath != null && !this.contextRootPath.endsWith("/"))
this.contextRootPath += "/";
logger.info("context root path is " + contextRootPath);
load();
}
Expand Down
3 changes: 2 additions & 1 deletion designer/src/main/webapp/app.js
Expand Up @@ -154,7 +154,8 @@ angular.element(document).ready(['$http',function ($http) {
angular.module('Rvd').factory('RvdConfiguration', function () {
return {
projectsRootPath: '/restcomm-rvd/services/projects',
videoSupport: clientConfig.videoSupport
videoSupport: clientConfig.videoSupport,
restcommBaseUrl = 'http://192.168.2.2'
}
});
configPromise.resolve(clientConfig);
Expand Down
4 changes: 2 additions & 2 deletions designer/src/main/webapp/js/app/controllers/projectManager.js
@@ -1,4 +1,4 @@
App.controller('projectManagerCtrl', function ( $scope, $http, $location, $stateParams, $timeout, $upload, notifications, authentication, fileRetriever ) {
App.controller('projectManagerCtrl', function ( $scope, $http, $location, $stateParams, $timeout, $upload, notifications, authentication, fileRetriever, RvdConfiguration ) {

var account = authentication.getAccount();

Expand All @@ -17,7 +17,7 @@ App.controller('projectManagerCtrl', function ( $scope, $http, $location, $state
$scope.appItems = [];
$scope.retrievingApps = true;
$http({
url: '/restcomm/2012-04-24/Accounts/' + account.sid + '/Applications.json',
url: RvdConfiguration.restcommBaseUrl + '/restcomm/2012-04-24/Accounts/' + account.sid + '/Applications.json',
method: 'GET',
headers: {Authorization: authentication.getAuthHeader()}
}).success(function (data, status, headers, config) {
Expand Down
4 changes: 2 additions & 2 deletions designer/src/main/webapp/js/app/interceptors.js
Expand Up @@ -38,7 +38,7 @@ angular.module('Rvd').config(['$httpProvider', function($httpProvider) {
// injects authentication credentials when Restcomm authentication is used
angular.module('Rvd').factory('RestcommAuthenticationInterceptor', function ($injector) {
function request(config) {
return $injector.invoke(function ($state, authentication) {
return $injector.invoke(function ($state, authentication, RvdConfiguration) {
if (config.url.startsWith('services/') || config.url.startsWith('/restcomm-rvd/services/')) {
if (authentication.getAuthHeader()) {
// if the request is targeted towards RVD add authorization header and there is no authorization header already
Expand All @@ -47,7 +47,7 @@ angular.module('Rvd').factory('RestcommAuthenticationInterceptor', function ($in
config.headers.Authorization = authentication.getAuthHeader();
}
} else
if (config.url.startsWith('/restcomm/2012-04-24/')) {
if (config.url.startsWith(RvdConfiguration.restcommBaseUrl + '/restcomm/2012-04-24/')) {
if (authentication.getAuthHeader()) {
delete config.headers.authorization; // mind the case insensitivity of headers
delete config.headers.Authorization;
Expand Down
5 changes: 3 additions & 2 deletions designer/src/main/webapp/js/app/services.js
Expand Up @@ -90,7 +90,7 @@ angular.module('Rvd').service('initializer',function (authentication, storage,
};
});

angular.module('Rvd').service('authentication', function ($http, $q, storage, $state, md5, $rootScope) {
angular.module('Rvd').service('authentication', function ($http, $q, storage, $state, md5, $rootScope, RvdConfiguration) {
var authInfo = {};
var account = null; // if this is set it means that user logged in: authentication succeeded and account was retrieved

Expand Down Expand Up @@ -138,7 +138,7 @@ angular.module('Rvd').service('authentication', function ($http, $q, storage, $s
function restcommLogin(username,password) {
var deferredLogin = $q.defer();
var authHeader = basicAuthHeader(username, password);
$http({method:'GET', url:'/restcomm/2012-04-24/Accounts.json/' + encodeURIComponent(username), headers: {Authorization: authHeader}}).then(function (response) {
$http({method:'GET', url: RvdConfiguration.restcommBaseUrl + '/restcomm/2012-04-24/Accounts.json/' + encodeURIComponent(username), headers: {Authorization: authHeader}}).then(function (response) {
var acc = response.data; // store temporarily the account returned
$http({method:'GET', url:'services/auth/keepalive', headers: {Authorization: "Basic " + btoa(acc.email_address + ":" +acc.auth_token)}}).then(function (response) {
// ok, access to both restcomm and RVD is verified
Expand Down Expand Up @@ -830,3 +830,4 @@ angular.module('Rvd').factory('fileRetriever', function (Blob, FileSaver, $http)
download: download
}
});

0 comments on commit e0bfd4e

Please sign in to comment.