Commit 855da481 authored by amit-s19's avatar amit-s19
Browse files

Removed hard coded urls

Showing with 16 additions and 11 deletions
+16 -11
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',
......
......@@ -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}>
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment