mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
Merge branch 'AD-499-custom-api-url-mapping' into AD-499-whitelabel-prize-with-sluice-as-k
This commit is contained in:
commit
6405d08673
@ -8,6 +8,7 @@ import Router from 'react-router';
|
||||
import fetch from 'isomorphic-fetch';
|
||||
|
||||
import ApiUrls from './constants/api_urls';
|
||||
import { updateApiUrls } from './constants/api_urls';
|
||||
import appConstants from './constants/application_constants';
|
||||
import getRoutes from './routes';
|
||||
import requests from './utils/requests';
|
||||
@ -41,6 +42,7 @@ class AppGateway {
|
||||
try {
|
||||
settings = getSubdomainSettings(subdomain);
|
||||
appConstants.whitelabel = settings;
|
||||
updateApiUrls(settings.type, subdomain);
|
||||
this.load(settings.type);
|
||||
} catch(err) {
|
||||
// if there are no matching subdomains, we're routing
|
||||
|
11
js/components/whitelabel/prize/constants/api_urls.js
Normal file
11
js/components/whitelabel/prize/constants/api_urls.js
Normal file
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
import AppConstants from '../../../../constants/application_constants';
|
||||
|
||||
function getApiUrls(subdomain) {
|
||||
return {
|
||||
'pieces_list': AppConstants.apiEndpoint + 'prize/' + subdomain + '/pieces/'
|
||||
};
|
||||
}
|
||||
|
||||
export default getApiUrls;
|
@ -1,6 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
import AppConstants from './application_constants';
|
||||
import getPrizeApiUrls from '../components/whitelabel/prize/constants/api_urls';
|
||||
import { update } from '../utils/general_utils';
|
||||
|
||||
|
||||
let apiUrls = {
|
||||
'applications': AppConstants.apiEndpoint + 'applications/',
|
||||
@ -50,4 +53,14 @@ let apiUrls = {
|
||||
'delete_s3_file': AppConstants.serverUrl + 's3/delete/'
|
||||
};
|
||||
|
||||
|
||||
export function updateApiUrls(type, subdomain) {
|
||||
let newUrls = {};
|
||||
|
||||
if (type === 'prize') {
|
||||
newUrls = getPrizeApiUrls(subdomain);
|
||||
}
|
||||
update(apiUrls, newUrls);
|
||||
}
|
||||
|
||||
export default apiUrls;
|
||||
|
0
js/utils/api_urls_utils.js
Normal file
0
js/utils/api_urls_utils.js
Normal file
@ -131,6 +131,19 @@ export function mergeOptionsWithDuplicates(...l) {
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* In place update of a dictionary
|
||||
*/
|
||||
export function update(a, ...l) {
|
||||
for(let i = 0; i < l.length; i++) {
|
||||
for (let attrname in l[i]) {
|
||||
a[attrname] = l[i][attrname];
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
|
||||
* @param obj1
|
||||
@ -148,4 +161,4 @@ function _mergeOptions(obj1, obj2) {
|
||||
obj3[attrname] = obj2[attrname];
|
||||
}
|
||||
return obj3;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user