diff --git a/apps/wrapper/src/api/index.js b/apps/wrapper/src/api/index.js index 3bf433a8acc56b80988329d4c05a2c54a957d1f4..ea756ca87b5d0185b34b46bbf5071f2f752db2e2 100644 --- a/apps/wrapper/src/api/index.js +++ b/apps/wrapper/src/api/index.js @@ -1,8 +1,9 @@ -const GITPOD_URL = process.env.REACT_APP_GITPOD_WORKSPACE_URL +const HASURA_URL = process.env.REACT_APP_HASURA_URL_URL +const FORM_MANAGER_URL = process.env.REACT_APP_FORM_MANAGER_URL const makeHasuraCalls = async (query) => { // const userData = getCookie("userData"); - return fetch(`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "8080-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/v1/graphql`, { + return fetch(`${HASURA_URL}/v1/graphql`, { method: "POST", headers: { Accept: "application/json", @@ -43,7 +44,7 @@ export const saveFormSubmission = (data) => { export const getPrefillXML = async (form, onFormSuccessData, prefillXML, imageUrls) => { try { - 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( + let res = await fetch(`${FORM_MANAGER_URL}/prefillXML?form=${form}&onFormSuccessData=${encodeURI( JSON.stringify(onFormSuccessData) )}`, { method: 'POST', diff --git a/apps/wrapper/src/components/GenericForm/index.js b/apps/wrapper/src/components/GenericForm/index.js index 4645d3882ac8d01014bf8b93aef3cb029687dd9e..0bb84e502dc30ebb0b611b136c884fba926bc6c1 100644 --- a/apps/wrapper/src/components/GenericForm/index.js +++ b/apps/wrapper/src/components/GenericForm/index.js @@ -3,7 +3,9 @@ import styles from './index.module.css'; import beautify from "xml-beautifier"; import { getPrefillXML, saveFormSubmission } from '../../api'; -const GITPOD_URL = process.env.REACT_APP_GITPOD_WORKSPACE_URL +const EKETO_URL = process.env.REACT_APP_EKETO_URL +const FORM_MANAGER_URL = process.env.REACT_APP_FORM_MANAGER_URL +const HASURA_URL = process.env.REACT_APP_HASURA_URL const GenericForm = (props) => { const { selectedFlow, setSelectedFlow } = props; @@ -77,7 +79,7 @@ const GenericForm = (props) => { } const parseFormData = async (formData) => { - let jsonRes = await fetch(`${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "3006-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/parse`, { + let jsonRes = await fetch(`${FORM_MANAGER_URL}/parse`, { method: 'POST', body: JSON.stringify({ xml: formData, @@ -114,13 +116,13 @@ const GenericForm = (props) => { selectedFlow.offline && <p className='animate__animated animate__fadeIn' style={{ color: '#fff', fontSize: '1.5rem' }}>Disable internet and try submitting the form</p> } { - 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> + 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> } <div className={styles.formContainer}> <iframe title='current-form' className={styles.odkForm} src={ - `${GITPOD_URL.slice(0, GITPOD_URL.indexOf('/') + 2) + "8065-" + GITPOD_URL.slice(GITPOD_URL.indexOf('/') + 2)}/preview?formSpec=${encodedFormSpec}&xform=${encodedFormURI}` + `${EKETO_URL}/preview?formSpec=${encodedFormSpec}&xform=${encodedFormURI}` } /> <div className={styles.jsonResponse}> diff --git a/packages/form-manager/src/app.controller.ts b/packages/form-manager/src/app.controller.ts index 681df74cf7048eef744e32bd2bfe3a7ce42f1c24..d60b2c3613f64307f6cfe82014809b5e5a92f446 100644 --- a/packages/form-manager/src/app.controller.ts +++ b/packages/form-manager/src/app.controller.ts @@ -47,7 +47,9 @@ export class AppController { private configService: ConfigService, ) { } - GITPOD_URL = this.configService.get('GITPOD_WORKSPACE_URL'); + MINIO_ENDPOINT = this.configService.get('MINIO_ENDPOINT'); + MINIO_URL = this.configService.get('MINIO_URL'); + FORM_MANAGER_URL = this.configService.get('FORM_MANAGER_URL'); getLoginToken = () => { try { @@ -190,7 +192,7 @@ export class AppController { ); const instanceId = uuidv4(); await this.cacheManager.set(instanceId, prefilledForm, 86400 * 10); - return `${this.GITPOD_URL.slice(0, this.GITPOD_URL.indexOf('/') + 2) + "3006-" + this.GITPOD_URL.slice(this.GITPOD_URL.indexOf('/') + 2)}/form/instance/${instanceId}`; + return `${this.FORM_MANAGER_URL}/form/instance/${instanceId}`; } else { return 'OK'; } @@ -269,7 +271,7 @@ export class AppController { // console.log('sessionRes', sessionRes); const minioClient: Client = new Minio.Client({ - endPoint: "9000-"+this.GITPOD_URL.slice(8), + endPoint: this.MINIO_ENDPOINT, useSSL: true, accessKey: this.configService.get('MINIO_USERNAME'), secretKey: this.configService.get('MINIO_PASSWORD') @@ -296,7 +298,7 @@ export class AppController { }, ); - 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}`; + const fileURL = `${this.MINIO_URL}/${this.configService.get('MINIO_BUCKETNAME')}/${fileName}`; console.log('Uploaded File:', fileURL);