mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Add custom url mapping
This commit is contained in:
parent
5ced62c496
commit
c5fd8aa28f
@ -8,6 +8,7 @@ import Router from 'react-router';
|
|||||||
import fetch from 'isomorphic-fetch';
|
import fetch from 'isomorphic-fetch';
|
||||||
|
|
||||||
import ApiUrls from './constants/api_urls';
|
import ApiUrls from './constants/api_urls';
|
||||||
|
import { updateApiUrls } from './constants/api_urls';
|
||||||
import appConstants from './constants/application_constants';
|
import appConstants from './constants/application_constants';
|
||||||
import getRoutes from './routes';
|
import getRoutes from './routes';
|
||||||
import requests from './utils/requests';
|
import requests from './utils/requests';
|
||||||
@ -41,6 +42,7 @@ class AppGateway {
|
|||||||
try {
|
try {
|
||||||
settings = getSubdomainSettings(subdomain);
|
settings = getSubdomainSettings(subdomain);
|
||||||
appConstants.whitelabel = settings;
|
appConstants.whitelabel = settings;
|
||||||
|
updateApiUrls(settings.type, subdomain);
|
||||||
this.load(settings.type);
|
this.load(settings.type);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
// if there are no matching subdomains, we're routing
|
// 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';
|
'use strict';
|
||||||
|
|
||||||
import AppConstants from './application_constants';
|
import AppConstants from './application_constants';
|
||||||
|
import getPrizeApiUrls from '../components/whitelabel/prize/constants/api_urls';
|
||||||
|
import { update } from '../utils/general_utils';
|
||||||
|
|
||||||
|
|
||||||
let apiUrls = {
|
let apiUrls = {
|
||||||
'applications': AppConstants.apiEndpoint + 'applications/',
|
'applications': AppConstants.apiEndpoint + 'applications/',
|
||||||
@ -50,4 +53,14 @@ let apiUrls = {
|
|||||||
'delete_s3_file': AppConstants.serverUrl + 's3/delete/'
|
'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;
|
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;
|
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
|
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
|
||||||
* @param obj1
|
* @param obj1
|
||||||
|
Loading…
Reference in New Issue
Block a user