Skip to content

Commit 855da48

Browse files
committed
Removed hard coded urls
1 parent 0643bae commit 855da48

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

apps/wrapper/src/api/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const GITPOD_URL = process.env.REACT_APP_GITPOD_WORKSPACE_URL
1+
const HASURA_URL = process.env.REACT_APP_HASURA_URL_URL
2+
const FORM_MANAGER_URL = process.env.REACT_APP_FORM_MANAGER_URL
23

34
const makeHasuraCalls = async (query) => {
45
// const userData = getCookie("userData");
5-
return fetch(`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "8080-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/v1/graphql`, {
6+
return fetch(`${HASURA_URL}/v1/graphql`, {
67
method: "POST",
78
headers: {
89
Accept: "application/json",
@@ -43,7 +44,7 @@ export const saveFormSubmission = (data) => {
4344

4445
export const getPrefillXML = async (form, onFormSuccessData, prefillXML, imageUrls) => {
4546
try {
46-
let res = await fetch(`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "3006-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/prefillXML?form=${form}&onFormSuccessData=${encodeURI(
47+
let res = await fetch(`${FORM_MANAGER_URL}/prefillXML?form=${form}&onFormSuccessData=${encodeURI(
4748
JSON.stringify(onFormSuccessData)
4849
)}`, {
4950
method: 'POST',

apps/wrapper/src/components/GenericForm/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import styles from './index.module.css';
33
import beautify from "xml-beautifier";
44
import { getPrefillXML, saveFormSubmission } from '../../api';
55

6-
const GITPOD_URL = process.env.REACT_APP_GITPOD_WORKSPACE_URL
6+
const EKETO_URL = process.env.REACT_APP_EKETO_URL
7+
const FORM_MANAGER_URL = process.env.REACT_APP_FORM_MANAGER_URL
8+
const HASURA_URL = process.env.REACT_APP_HASURA_URL
79

810
const GenericForm = (props) => {
911
const { selectedFlow, setSelectedFlow } = props;
@@ -77,7 +79,7 @@ const GenericForm = (props) => {
7779
}
7880

7981
const parseFormData = async (formData) => {
80-
let jsonRes = await fetch(`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "3006-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/parse`, {
82+
let jsonRes = await fetch(`${FORM_MANAGER_URL}/parse`, {
8183
method: 'POST',
8284
body: JSON.stringify({
8385
xml: formData,
@@ -114,13 +116,13 @@ const GenericForm = (props) => {
114116
selectedFlow.offline && <p className='animate__animated animate__fadeIn' style={{ color: '#fff', fontSize: '1.5rem' }}>Disable internet and try submitting the form</p>
115117
}
116118
{
117-
selectedFlow.submitToHasura && <p className='animate__animated animate__fadeIn' style={{ color: '#fff', fontSize: '1.5rem' }}>Submit the form and check <a style={{color: '#ffc119'}} target="_blank" href={`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "8080-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}`}>Hasura</a></p>
119+
selectedFlow.submitToHasura && <p className='animate__animated animate__fadeIn' style={{ color: '#fff', fontSize: '1.5rem' }}>Submit the form and check <a style={{ color: '#ffc119' }} target="_blank" href={`${HASURA_URL}`}>Hasura</a></p>
118120
}
119121
<div className={styles.formContainer}>
120122
<iframe title='current-form'
121123
className={styles.odkForm}
122124
src={
123-
`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "8065-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/preview?formSpec=${encodedFormSpec}&xform=${encodedFormURI}`
125+
`${EKETO_URL}/preview?formSpec=${encodedFormSpec}&xform=${encodedFormURI}`
124126
}
125127
/>
126128
<div className={styles.jsonResponse}>

packages/form-manager/src/app.controller.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export class AppController {
4747
private configService: ConfigService,
4848
) { }
4949

50-
GITPOD_URL = this.configService.get('GITPOD_WORKSPACE_URL');
50+
MINIO_ENDPOINT = this.configService.get('MINIO_ENDPOINT');
51+
MINIO_URL = this.configService.get('MINIO_URL');
52+
FORM_MANAGER_URL = this.configService.get('FORM_MANAGER_URL');
5153

5254
getLoginToken = () => {
5355
try {
@@ -190,7 +192,7 @@ export class AppController {
190192
);
191193
const instanceId = uuidv4();
192194
await this.cacheManager.set(instanceId, prefilledForm, 86400 * 10);
193-
return `${this.GITPOD_URL.slice(0, this.GITPOD_URL.indexOf('/') + 2) + "3006-" + this.GITPOD_URL.slice(this.GITPOD_URL.indexOf('/') + 2)}/form/instance/${instanceId}`;
195+
return `${this.FORM_MANAGER_URL}/form/instance/${instanceId}`;
194196
} else {
195197
return 'OK';
196198
}
@@ -269,7 +271,7 @@ export class AppController {
269271
// console.log('sessionRes', sessionRes);
270272

271273
const minioClient: Client = new Minio.Client({
272-
endPoint: "9000-"+this.GITPOD_URL.slice(8),
274+
endPoint: this.MINIO_ENDPOINT,
273275
useSSL: true,
274276
accessKey: this.configService.get('MINIO_USERNAME'),
275277
secretKey: this.configService.get('MINIO_PASSWORD')
@@ -296,7 +298,7 @@ export class AppController {
296298
},
297299
);
298300

299-
const fileURL = `${this.GITPOD_URL.slice(0, this.GITPOD_URL.indexOf('/') + 2) + "9000-" + this.GITPOD_URL.slice(this.GITPOD_URL.indexOf('/') + 2)}/${this.configService.get('MINIO_BUCKETNAME')}/${fileName}`;
301+
const fileURL = `${this.MINIO_URL}/${this.configService.get('MINIO_BUCKETNAME')}/${fileName}`;
300302

301303
console.log('Uploaded File:', fileURL);
302304

0 commit comments

Comments
 (0)