Skip to content

Commit

Permalink
refactor: FORMS-1007 geo address env variables (bcgov#1421)
Browse files Browse the repository at this point in the history
* refactor: FORMS-1007 geo address env variables

* fix the launcher url
  • Loading branch information
WalterMoar authored Jul 3, 2024
1 parent bccaed7 commit 453c4b0
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 163 deletions.
8 changes: 1 addition & 7 deletions .github/actions/build-push-container/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,11 @@ inputs:
app_chefs_geo_address_apiurl:
description: Proxy URL to BC Geo Address API URL
required: true
default: "../api/v1/bcgeoaddress/address"
app_chefs_advance_geo_address_apiurl:
description: Proxy URL to BC Geo Address API URL for advance search
required: true
default: "../api/v1/bcgeoaddress/advance/address"
ref:
description: The checkout ref id
required: false
default: ''
default: ""
pr_number:
description: Pull request number
required: false
Expand Down Expand Up @@ -98,7 +94,6 @@ runs:
VITE_CHEFSTOURURL: ${{ inputs.app_chefstoururl }}
VITE_FRONTEND_BASEPATH: ${{ inputs.route_path }}
VITE_CHEFS_GEO_ADDRESS_APIURL: ${{ inputs.app_chefs_geo_address_apiurl }}
VITE_CHEFS_ADVANCE_GEO_ADDRESS_APIURL: ${{ inputs.app_chefs_advance_geo_address_apiurl }}
VITE_BC_GEO_ADDRESS_APIURL: ${{ inputs.app_bc_geo_address_apiurl }}
ENV_PATH: ./app/frontend/.env
shell: bash
Expand All @@ -109,7 +104,6 @@ runs:
echo VITE_HOWTOURL=$VITE_HOWTOURL >> $ENV_PATH
echo VITE_CHEFSTOURURL=$VITE_CHEFSTOURURL >> $ENV_PATH
echo VITE_CHEFS_GEO_ADDRESS_APIURL=$VITE_CHEFS_GEO_ADDRESS_APIURL >> $ENV_PATH
echo VITE_CHEFS_ADVANCE_GEO_ADDRESS_APIURL=$VITE_CHEFS_ADVANCE_GEO_ADDRESS_APIURL >> $ENV_PATH
echo VITE_BC_GEO_ADDRESS_APIURL=$VITE_BC_GEO_ADDRESS_APIURL >> $ENV_PATH
echo VITE_FRONTEND_BASEPATH=$VITE_FRONTEND_BASEPATH >> $ENV_PATH
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{
"cwd": "${workspaceFolder}/app/frontend",
"env": {
"VITE_CHEFS_ADVANCE_GEO_ADDRESS_APIURL": "http://localhost:8080/app/api/v1/bcgeoaddress/address",
"VITE_CHEFS_GEO_ADDRESS_APIURL": "http://localhost:8080/app/api/v1/bcgeoaddress/advance/address",
"VITE_CHEFSTOURURL": "https://www.youtube.com/embed/obOhyYusMjM",
"VITE_CONTACT": "[email protected]",
"VITE_FRONTEND_BASEPATH": "/app",
Expand Down
141 changes: 71 additions & 70 deletions components/src/components/BCAddress/Component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/* tslint:disable */
import {Components} from 'formiojs';
import { Components } from 'formiojs';
import { Constants } from '../Common/Constants';
import editForm from './Component.form';
import _ from 'lodash';
Expand All @@ -16,80 +15,82 @@ const ID = 'bcaddress';
const DISPLAY = 'BC Address';

export default class Component extends (ParentComponent as any) {
static schema(...extend) {

return ParentComponent.schema({
label: DISPLAY,
type: ID,
key: ID,
provider: 'custom',
providerOptions: {
queryProperty: 'addressString',

url: import.meta.env.VITE_CHEFS_ADVANCE_GEO_ADDRESS_APIURL},

queryParameters:{"echo": false,
"brief": true,
"minScore": 55,
"onlyCivic": true,
"maxResults": 15,
"autocomplete": true,
"matchAccuracy": 100,
"matchPrecision": "occupant, unit, site, civic_number, intersection, block, street, locality, province",
"precisionPoints": 100,}

}, ...extend);
}

static get builderInfo() {
return {
title: DISPLAY,
group: 'advanced',
icon: 'address-book',
weight: 90,
documentation: Constants.DEFAULT_HELP_LINK,
schema: Component.schema()
};
}

mergeSchema(component = {}) {

let components = component['components'];

if (components) {
return _.omit(component, 'components');
}

return component;
static schema(...extend) {
return ParentComponent.schema(
{
label: DISPLAY,
type: ID,
key: ID,
provider: 'custom',
providerOptions: {
queryProperty: 'addressString',
url: import.meta.env.VITE_CHEFS_GEO_ADDRESS_APIURL,
},

queryParameters: {
echo: false,
brief: true,
minScore: 55,
onlyCivic: true,
maxResults: 15,
autocomplete: true,
matchAccuracy: 100,
matchPrecision:
'occupant, unit, site, civic_number, intersection, block, street, locality, province',
precisionPoints: 100,
},
},
...extend
);
}

static get builderInfo() {
return {
title: DISPLAY,
group: 'advanced',
icon: 'address-book',
weight: 90,
documentation: Constants.DEFAULT_HELP_LINK,
schema: Component.schema(),
};
}

mergeSchema(component = {}) {
let components = component['components'];

if (components) {
return _.omit(component, 'components');
}

public static editForm = editForm;
return component;
}

async init(){
super.init();
}
public static editForm = editForm;

async attach(element) {
super.attach(element);
try {
async init() {
super.init();
}

let {
providerOptions,
queryParameters,
} = this.component;
if(providerOptions) {
if(!providerOptions.params) {
providerOptions["params"]={}
}
if(queryParameters) {
providerOptions.params ={...providerOptions.params,...queryParameters}
}
}

} catch (err) {
console.log(`This error is from Custom BC Address component in form.io: Failed to acquire configuration: ${err.message}`);
async attach(element) {
super.attach(element);
try {
let { providerOptions, queryParameters } = this.component;
if (providerOptions) {
if (!providerOptions.params) {
providerOptions['params'] = {};
}
if (queryParameters) {
providerOptions.params = {
...providerOptions.params,
...queryParameters,
};
}
}
} catch (err) {
console.log(
`This error is from Custom BC Address component in form.io: Failed to acquire configuration: ${err.message}`
);
}

}
}
export {};
147 changes: 73 additions & 74 deletions components/src/components/SimpleBCAddress/Component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/* tslint:disable */
import {Components} from 'formiojs';
import { Components } from 'formiojs';
import { Constants } from '../Common/Constants';
import editForm from './Component.form';
import _ from 'lodash';
Expand All @@ -16,83 +15,83 @@ const ID = 'simplebcaddress';
const DISPLAY = 'Simple BC Address';

export default class Component extends (ParentComponent as any) {
static schema(...extend) {

return ParentComponent.schema({
label: DISPLAY,
type: ID,
key: ID,
provider: 'custom',
providerOptions: {
queryProperty: 'addressString',
url:import.meta.env.VITE_CHEFS_ADVANCE_GEO_ADDRESS_APIURL},

queryParameters:{"echo": false,
"brief": true,
"minScore": 55,
"onlyCivic": true,
"maxResults": 15,
"autocomplete": true,
"matchAccuracy": 100,
"matchPrecision": "occupant, unit, site, civic_number, intersection, block, street, locality, province",
"precisionPoints": 100,}

}, ...extend);
}

static get builderInfo() {
return {
title: DISPLAY,
group: 'advanced',
icon: 'address-book',
weight: 90,
documentation: Constants.DEFAULT_HELP_LINK,
schema: Component.schema(),

};
}

public static editForm = editForm;

async init(){
super.init();
}

async attach(element) {
super.attach(element);
try {

let {
providerOptions,
queryParameters,

} = this.component;

if(providerOptions) {
if(!providerOptions.params) {
providerOptions["params"]={}
}
if(queryParameters) {
providerOptions.params ={...providerOptions.params,...queryParameters}
}
}

} catch (err) {
console.log(`This error is from Custom BC Address component in form.io: Failed to acquire configuration: ${err.message}`);
static schema(...extend) {
return ParentComponent.schema(
{
label: DISPLAY,
type: ID,
key: ID,
provider: 'custom',
providerOptions: {
queryProperty: 'addressString',
url: import.meta.env.VITE_CHEFS_GEO_ADDRESS_APIURL,
},

queryParameters: {
echo: false,
brief: true,
minScore: 55,
onlyCivic: true,
maxResults: 15,
autocomplete: true,
matchAccuracy: 100,
matchPrecision:
'occupant, unit, site, civic_number, intersection, block, street, locality, province',
precisionPoints: 100,
},
},
...extend
);
}

static get builderInfo() {
return {
title: DISPLAY,
group: 'advanced',
icon: 'address-book',
weight: 90,
documentation: Constants.DEFAULT_HELP_LINK,
schema: Component.schema(),
};
}

public static editForm = editForm;

async init() {
super.init();
}

async attach(element) {
super.attach(element);
try {
let { providerOptions, queryParameters } = this.component;

if (providerOptions) {
if (!providerOptions.params) {
providerOptions['params'] = {};
}
if (queryParameters) {
providerOptions.params = {
...providerOptions.params,
...queryParameters,
};
}
}
} catch (err) {
console.log(
`This error is from Custom BC Address component in form.io: Failed to acquire configuration: ${err.message}`
);
}
}

mergeSchema(component = {}) {

let components = component['components'];
mergeSchema(component = {}) {
let components = component['components'];

if (components) {
return _.omit(component, 'components');
}

return component;
if (components) {
return _.omit(component, 'components');
}


return component;
}
}
export {};
11 changes: 0 additions & 11 deletions openshift/app.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ objects:
secretKeyRef:
key: email
name: "${APP_NAME}-contact-secret"

- name: VITE_HOWTOURL
valueFrom:
secretKeyRef:
Expand All @@ -177,16 +176,6 @@ objects:
secretKeyRef:
key: chefstourvideourl
name: "${APP_NAME}-landingpagevideourls-secret"
- name: VITE_CHEFS_GEO_ADDRESS_APIURL
valueFrom:
secretKeyRef:
key: chefsgeoaddressapiurl
name: "${APP_NAME}-bcgeoaddress-secret"
- name: VITE_CHEFS_ADVANCE_GEO_ADDRESS_APIURL
valueFrom:
secretKeyRef:
key: chefsadvancegeoaddressapiurl
name: "${APP_NAME}-bcgeoaddress-secret"
- name: VITE_BC_GEO_ADDRESS_APIURL
valueFrom:
secretKeyRef:
Expand Down

0 comments on commit 453c4b0

Please sign in to comment.