From d7bf29c383dd6bdb654d6ce874b7f44e80868834 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Fri, 17 Dec 2021 09:28:03 -0500 Subject: [PATCH 01/29] attempting first dev deployment --- src/components/NewRecord.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/NewRecord.vue b/src/components/NewRecord.vue index f9d4553..89c0670 100644 --- a/src/components/NewRecord.vue +++ b/src/components/NewRecord.vue @@ -86,7 +86,9 @@ export default defineComponent({ alert("ERROR in response: " + response); } }).catch((error) => { - alert("NETWORK ERROR: " + error) + // commenting the following alert out to test dev deployment without generate id + //alert("GENERATE ID microservice is not up: " + error) + resolve('resolved') }); }); }, From 22f477478addefc826a22ab229bc51c68e149f40 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Fri, 17 Dec 2021 09:29:58 -0500 Subject: [PATCH 02/29] changed commented out error message --- src/components/NewRecord.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/NewRecord.vue b/src/components/NewRecord.vue index 89c0670..04340af 100644 --- a/src/components/NewRecord.vue +++ b/src/components/NewRecord.vue @@ -87,7 +87,7 @@ export default defineComponent({ } }).catch((error) => { // commenting the following alert out to test dev deployment without generate id - //alert("GENERATE ID microservice is not up: " + error) + //alert("GENERATEID microservice is offline: " + error) resolve('resolved') }); }); From df4c252d242b7123c6ca2b5fde39825a05b63443 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Fri, 17 Dec 2021 09:43:39 -0500 Subject: [PATCH 03/29] added catch for if geonames is offline --- src/components/CustomRenderer.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index e577816..3fd209a 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -190,6 +190,8 @@ export const customRenderer = defineComponent({ alert("No geoname results found for id: " + id); } }); + }).catch((error) => { + alert("GEONAMES api service is offline: " + error) }); }, onChange(e: number) { From 64f321d3aecd5250f4dee079ce438b7f46a229bb Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Fri, 17 Dec 2021 15:24:48 -0500 Subject: [PATCH 04/29] first commit github actions --- .github/workflows/dev.yml | 26 ++++++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dev.yml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..fa6a204 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,26 @@ +name: Deploy Dev +on: + push: + branches: + - "dev" +jobs: + run: + runs-on: ubuntu-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + steps: + - uses: actions/checkout@v2 + - name: Install + run: npm ci + - name: Build + run: npm run build + - name: Deploy + uses: reggionick/s3-deploy@v3 + with: + folder: public + bucket: ${{ secrets.S3_BUCKET_CURATORFORM_DEV}} + bucket-region: ${{ secrets.S3_BUCKET_REGION }} + dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_CURATORFORM_DEV }} + invalidation: /* + delete-removed: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 77841e2..9113d9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /app COPY package*.json ./ # install and cache project dependencies -RUN npm install +RUN npm ci # copy project files and folders to the current working directory (i.e. 'app' folder) COPY . . From 4b8d0e8c251a4643fe6b3e65c611e4b561570427 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Fri, 17 Dec 2021 15:56:16 -0500 Subject: [PATCH 05/29] changed folder name --- .github/workflows/dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index fa6a204..01175ed 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -16,9 +16,9 @@ jobs: - name: Build run: npm run build - name: Deploy - uses: reggionick/s3-deploy@v3 + uses: reggionick/s3-deploy@v3.1.1 with: - folder: public + folder: dist bucket: ${{ secrets.S3_BUCKET_CURATORFORM_DEV}} bucket-region: ${{ secrets.S3_BUCKET_REGION }} dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_CURATORFORM_DEV }} From b727ec2344c311cfe514be829829aea2fc11f4fb Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Fri, 17 Dec 2021 16:40:11 -0500 Subject: [PATCH 06/29] updating file to point to microservice on dev --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 3fe941f..ff5ada9 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VUE_APP_GENERATE_ID="http://localhost:5000/generateid" +VUE_APP_GENERATE_ID="http://generateid.dev.ror.org/generateid?mode=dev" From bc163694b64e819a2b00314e45e1871f86804b44 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Sun, 19 Dec 2021 20:19:00 -0500 Subject: [PATCH 07/29] temporary check to test generate id --- src/jsonSchema/rorSchema/schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsonSchema/rorSchema/schema.json b/src/jsonSchema/rorSchema/schema.json index 444145b..72618aa 100644 --- a/src/jsonSchema/rorSchema/schema.json +++ b/src/jsonSchema/rorSchema/schema.json @@ -447,5 +447,5 @@ "minLength": 1 } }, - "required": ["name", "types", "addresses"] + "required": ["name", "types"] } From e3186ed52dec6cad2d4834218d0f7503a2a09690 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Mon, 20 Dec 2021 09:47:34 -0500 Subject: [PATCH 08/29] commiting new url --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index ff5ada9..92b1e23 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VUE_APP_GENERATE_ID="http://generateid.dev.ror.org/generateid?mode=dev" +VUE_APP_GENERATE_ID="https://generateid.dev.ror.org/generateid?mode=dev" From 1a03e4a08f02f789d8c3aae42d512752e5f92be4 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Mon, 20 Dec 2021 09:31:01 -0700 Subject: [PATCH 09/29] creating an alert if there is an errorneous response from generateid --- src/components/NewRecord.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/NewRecord.vue b/src/components/NewRecord.vue index 04340af..1760957 100644 --- a/src/components/NewRecord.vue +++ b/src/components/NewRecord.vue @@ -86,9 +86,7 @@ export default defineComponent({ alert("ERROR in response: " + response); } }).catch((error) => { - // commenting the following alert out to test dev deployment without generate id - //alert("GENERATEID microservice is offline: " + error) - resolve('resolved') + alert("ERROR accessing response from GENERATE ID microservice: " + error) }); }); }, From adcf6c03a197433db8344645c9a82b11d69916ac Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Tue, 21 Dec 2021 07:06:27 -0700 Subject: [PATCH 10/29] handing address query to generateid --- .env | 1 + src/components/CustomRenderer.vue | 5 +---- src/env.ts | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 92b1e23..89bfded 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ VUE_APP_GENERATE_ID="https://generateid.dev.ror.org/generateid?mode=dev" +VUE_APP_GEONAMES_URL="https://generateid.dev.ror.org/address" diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index 3fd209a..b9adc54 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -143,10 +143,7 @@ export const customRenderer = defineComponent({ return data; }, fetchAddress(id: string, path: string) { - const url = new URL(env().GEONAMES_URL); - const username = env().GEONAMES_USERNAME - const params = { geonameId: id, username: username }; // or: - url.search = new URLSearchParams(params).toString(); + const url = new URL(env().GEONAMES_URL+"/"+id); const rootData = this.jsonforms?.core?.data; fetch(url.toString()).then((response) => { response.json().then((data) => { diff --git a/src/env.ts b/src/env.ts index 5fe1e5d..a531c98 100644 --- a/src/env.ts +++ b/src/env.ts @@ -2,9 +2,8 @@ export const env = () => { const { VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', VUE_APP_GENERATE_ID: GENERATE_ID = 'http://localhost:5000/generateid?mode=dev', - VUE_APP_GEONAMES_URL: GEONAMES_URL = 'http://api.geonames.org/getJSON', - VUE_APP_GEONAMES_USERNAME: GEONAMES_USERNAME = 'roradmin', + VUE_APP_GEONAMES_URL: GEONAMES_URL = 'http://localhost:5000/address', NODE_ENV } = process.env; - return { BASE_ROUTE, GENERATE_ID, GEONAMES_URL, GEONAMES_USERNAME, NODE_ENV }; + return { BASE_ROUTE, GENERATE_ID, GEONAMES_URL, NODE_ENV }; }; \ No newline at end of file From aae831c694a6c6d6e72155aac515f1b0e52edde6 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Wed, 22 Dec 2021 08:43:17 -0700 Subject: [PATCH 11/29] debugging --- src/components/CustomRenderer.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index b9adc54..b1850bc 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -184,6 +184,8 @@ export const customRenderer = defineComponent({ } } else { + console.log("RESPONSE: ", response) + console.log("DATA: ", data) alert("No geoname results found for id: " + id); } }); From 9f4e2eaf9fb16a4205c1ddc1c0912df8108d05cc Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Wed, 22 Dec 2021 11:19:34 -0700 Subject: [PATCH 12/29] changing address route and removing extraneous function --- src/components/CustomRenderer.vue | 4 +++- src/components/Main.vue | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index b1850bc..e72efa0 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -143,7 +143,9 @@ export const customRenderer = defineComponent({ return data; }, fetchAddress(id: string, path: string) { - const url = new URL(env().GEONAMES_URL+"/"+id); + const url = new URL(env().GEONAMES_URL); + const param = { locationid: id }; + url.search = new URLSearchParams(param).toString(); const rootData = this.jsonforms?.core?.data; fetch(url.toString()).then((response) => { response.json().then((data) => { diff --git a/src/components/Main.vue b/src/components/Main.vue index 1fc93a6..451ebef 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -33,9 +33,6 @@ export default { methods: { showTypeAhead () { this.isExisting = true - }, - passRorId () { - return '/exist/1234' } } } From 39e5108274b07dab259d83c046e5835809d7e18a Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Wed, 22 Dec 2021 15:50:44 -0700 Subject: [PATCH 13/29] changed address url to check id generation --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 89bfded..a9d5c56 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -VUE_APP_GENERATE_ID="https://generateid.dev.ror.org/generateid?mode=dev" +VUE_APP_GENERATE_ID="https://generateid.dev.ror.org/generateid" VUE_APP_GEONAMES_URL="https://generateid.dev.ror.org/address" From 3e541ab58cf97bab963c5211ef7ce8e165a56028 Mon Sep 17 00:00:00 2001 From: eshadatta-crossref Date: Tue, 15 Feb 2022 13:12:33 -0500 Subject: [PATCH 14/29] added clear address functinality --- src/components/CustomRenderer.vue | 38 +++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index e72efa0..e39c59f 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -142,6 +142,38 @@ export const customRenderer = defineComponent({ data = set(path + 'code', fields.join('.'), data); return data; }, + ignoreFields() { + return ["line", "postcode", "primary", "state", "state_code"] + }, + clearAddress(path: string) { + if (this.dispatch) { + let address = this.jsonforms?.core?.data.addresses[0]; + let updatedData = this.jsonforms?.core?.data; + const ignoreFields = this.ignoreFields() + for (const i in address) { + let field = path + i + if (!(ignoreFields.includes(i))) + { + if (i == "geonames_city") { + for (const f in address[i]) { + let city_field = field + "." + f + const admin_fields = ["geonames_admin1", "geonames_admin2"] + if (admin_fields.includes(f)){ + for (const a in address[i][f]) { + let adminField = city_field + "." + a + updatedData = set(adminField,null,updatedData); + } + } + updatedData = set(field+'.city',null,updatedData); + } + } + } + } + this.dispatch( + Actions.updateCore(updatedData, this.s as JsonSchema, this.ui)); + } + + }, fetchAddress(id: string, path: string) { const url = new URL(env().GEONAMES_URL); const param = { locationid: id }; @@ -186,8 +218,6 @@ export const customRenderer = defineComponent({ } } else { - console.log("RESPONSE: ", response) - console.log("DATA: ", data) alert("No geoname results found for id: " + id); } }); @@ -200,6 +230,10 @@ export const customRenderer = defineComponent({ const path = regex.exec(this.control.path) let strPath = path ? path[0]: '' const id = e.toString(); + const lat = this.jsonforms?.core?.data.addresses[0].lat + if (lat) { + this.clearAddress(strPath) + } this.fetchAddress(id, strPath); }, }, From f6857560f58267ca5f4277457fa7bb6a98471316 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Fri, 15 Apr 2022 12:17:21 -0500 Subject: [PATCH 15/29] fetch formatted address from ror api instead of directly from geonames --- src/components/CustomRenderer.vue | 122 ++++++------------------------ src/env.ts | 5 +- 2 files changed, 25 insertions(+), 102 deletions(-) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index e577816..907eda1 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -20,7 +20,7 @@ :required="control.required" :error-messages="control.errors" :value="control.data" - @change="onChange" + @change="getAddress" @focus="isFocused = true" @blur="isFocused = false" /> @@ -75,112 +75,39 @@ export const customRenderer = defineComponent({ return { ...vControl, dispatch, jsonforms, s, ui }; }, methods: { - mapDict(path: string) { - return [ - { path: path+'lat', geoname: 'lat', type: 'float' }, - { path: path+'lng', geoname: 'lng', type: 'float' }, - { - path: path+'country_geonames_id', - geoname: 'countryId', - type: 'int', - }, - { - path: path+'geonames_city.city', - geoname: 'name', - type: 'string', - }, - { - path: path+'city', - geoname: 'name', - type: 'string', - }, - { - path: 'country.country_name', - geoname: 'countryName', - type: 'string', - }, - { - path: 'country.country_code', - geoname: 'countryCode', - type: 'string', - }, - ]; - }, - checkData(data: string, type: string) { - switch (type) { - case 'float': - return parseFloat(data); - case 'int': - return parseInt(data); - default: - return data; - } - }, - mapGeoNamesAdmin(level: string) { - return [ - { ror: 'name', geoname: 'adminName' + level, type: 'string' }, - { ror: 'ascii_name', geoname: 'adminName' + level, type: 'string' }, - { ror: 'id', geoname: 'adminId' + level, type: 'int' }, - ]; - }, - processGeoNamesAdmin( - p: string, - geonameResponse: any, - data: any, - level: string, - fields: string[] - ) { - let path = p + 'geonames_city.geonames_admin' + level + '.'; - let geonamesAdmin = this.mapGeoNamesAdmin(level); - for (const admin of geonamesAdmin) { - data = set( - path + admin.ror, - this.checkData(geonameResponse[admin.geoname], admin.type), - data - ); - } - data = set(path + 'code', fields.join('.'), data); - return data; - }, - fetchAddress(id: string, path: string) { - const url = new URL(env().GEONAMES_URL); - const username = env().GEONAMES_USERNAME - const params = { geonameId: id, username: username }; // or: + fetchAddress(id: string) { + const url = new URL(env().ADDRESS_URL); + const params = { locationid: id }; // or: url.search = new URLSearchParams(params).toString(); const rootData = this.jsonforms?.core?.data; fetch(url.toString()).then((response) => { response.json().then((data) => { - if (data.geonameId) { + console.log(data); + if (data.address.geonames_city.id) { + console.log("Address OK"); + console.log(rootData); if (this.dispatch) { - let mapping = this.mapDict(path); let updatedData = rootData; updatedData = set( - path+'geonames_city.id', + 'addresses.0', + data.address, + updatedData + ); + updatedData = set( + 'addresses.0.geonames_city.id', parseInt(id), updatedData + ) + updatedData = set( + 'country.country_name', + data.country.country_name, + updatedData ); - for (const entry of mapping) { updatedData = set( - entry.path, - this.checkData(data[entry.geoname], entry.type), + 'country.country_code', + data.country.country_code, updatedData ); - } - if (data.adminId1) { - updatedData = this.processGeoNamesAdmin(path, data, updatedData, '1', [ - data.countryCode, - data.adminCode1, - ]); - if (data.adminId2) { - updatedData = this.processGeoNamesAdmin( - path, - data, - updatedData, - '2', - [data.countryCode, data.adminCode1, data.adminCode2] - ); - } - } this.dispatch( Actions.updateCore(updatedData, this.s as JsonSchema, this.ui) ); @@ -192,12 +119,9 @@ export const customRenderer = defineComponent({ }); }); }, - onChange(e: number) { - const regex = /(.*?addr.*?\d\.)/ - const path = regex.exec(this.control.path) - let strPath = path ? path[0]: '' + getAddress(e: number) { const id = e.toString(); - this.fetchAddress(id, strPath); + this.fetchAddress(id); }, }, computed: { diff --git a/src/env.ts b/src/env.ts index 5fe1e5d..8f675c0 100644 --- a/src/env.ts +++ b/src/env.ts @@ -2,9 +2,8 @@ export const env = () => { const { VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', VUE_APP_GENERATE_ID: GENERATE_ID = 'http://localhost:5000/generateid?mode=dev', - VUE_APP_GEONAMES_URL: GEONAMES_URL = 'http://api.geonames.org/getJSON', - VUE_APP_GEONAMES_USERNAME: GEONAMES_USERNAME = 'roradmin', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'http://localhost:5000/address', NODE_ENV } = process.env; - return { BASE_ROUTE, GENERATE_ID, GEONAMES_URL, GEONAMES_USERNAME, NODE_ENV }; + return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV }; }; \ No newline at end of file From 55ba8f2357d6812a23004d4381d29d3327492ed9 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Fri, 15 Apr 2022 12:35:49 -0500 Subject: [PATCH 16/29] lint code --- src/App.vue | 1 - src/components/CustomRenderer.vue | 130 ++++++++++++------------ src/components/ExistingRecord.vue | 36 +++---- src/components/GenerateListRenderer.vue | 46 ++++----- src/components/NewRecord.vue | 62 ++++++----- src/components/Search.vue | 16 +-- src/components/ShowLanguageRenderer.vue | 61 ++++++----- src/components/ShowTypes.vue | 46 ++++----- src/env.ts | 16 +-- src/jsonSchema/rorSchema/index.ts | 11 +- src/router/index.ts | 14 +-- 11 files changed, 215 insertions(+), 224 deletions(-) diff --git a/src/App.vue b/src/App.vue index 95bdd50..0f356b9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -29,4 +29,3 @@ - diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index 907eda1..6687c76 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -40,107 +40,107 @@ import { and, Tester, optionIs, -} from '@jsonforms/core'; -import { defineComponent, inject} from '@vue/composition-api' + CoreActions +} from '@jsonforms/core' +import { defineComponent, inject } from '@vue/composition-api' import { rendererProps, useJsonFormsControl, - RendererProps, -} from '@jsonforms/vue2'; -import { ControlWrapper } from '@jsonforms/vue2-vuetify'; -import { useVuetifyControl } from '@jsonforms/vue2-vuetify'; -import { VTextField } from 'vuetify/lib'; -import { CoreActions } from '@jsonforms/core'; -import set from 'lodash/fp/set'; -import { env } from '../env'; + RendererProps +} from '@jsonforms/vue2' +import { ControlWrapper, useVuetifyControl } from '@jsonforms/vue2-vuetify' + +import { VTextField } from 'vuetify/lib' + +import set from 'lodash/fp/set' +import { env } from '../env' export const customRenderer = defineComponent({ name: 'custom-renderer', components: { ControlWrapper, - VTextField, + VTextField }, props: { - ...rendererProps(), + ...rendererProps() }, - setup(props: RendererProps) { - const dispatch = inject>('dispatch'); - const jsonforms = inject('jsonforms'); - const s = jsonforms?.core?.schema; - const ui = jsonforms?.core?.uischema; + setup (props: RendererProps) { + const dispatch = inject>('dispatch') + const jsonforms = inject('jsonforms') + const s = jsonforms?.core?.schema + const ui = jsonforms?.core?.uischema const vControl = useVuetifyControl( useJsonFormsControl(props), (value) => parseInt(value, 10) || undefined - ); - return { ...vControl, dispatch, jsonforms, s, ui }; + ) + return { ...vControl, dispatch, jsonforms, s, ui } }, methods: { - fetchAddress(id: string) { - const url = new URL(env().ADDRESS_URL); - const params = { locationid: id }; // or: - url.search = new URLSearchParams(params).toString(); - const rootData = this.jsonforms?.core?.data; + fetchAddress (id: string) { + const url = new URL(env().ADDRESS_URL) + const params = { locationid: id } // or: + url.search = new URLSearchParams(params).toString() + const rootData = this.jsonforms?.core?.data fetch(url.toString()).then((response) => { response.json().then((data) => { - console.log(data); + console.log(data) if (data.address.geonames_city.id) { - console.log("Address OK"); - console.log(rootData); + console.log('Address OK') + console.log(rootData) if (this.dispatch) { - let updatedData = rootData; - updatedData = set( - 'addresses.0', - data.address, - updatedData - ); - updatedData = set( + let updatedData = rootData + updatedData = set( + 'addresses.0', + data.address, + updatedData + ) + updatedData = set( 'addresses.0.geonames_city.id', parseInt(id), updatedData - ) - updatedData = set( - 'country.country_name', - data.country.country_name, - updatedData - ); - updatedData = set( - 'country.country_code', - data.country.country_code, - updatedData - ); - this.dispatch( + ) + updatedData = set( + 'country.country_name', + data.country.country_name, + updatedData + ) + updatedData = set( + 'country.country_code', + data.country.country_code, + updatedData + ) + this.dispatch( Actions.updateCore(updatedData, this.s as JsonSchema, this.ui) - ); + ) } + } else { + alert('No geoname results found for id: ' + id) } - else { - alert("No geoname results found for id: " + id); - } - }); - }); - }, - getAddress(e: number) { - const id = e.toString(); - this.fetchAddress(id); + }) + }) }, + getAddress (e: number) { + const id = e.toString() + this.fetchAddress(id) + } }, computed: { - step(): number { - const options: any = this.appliedOptions; - return options.step ?? 1; - }, - }, -}); + step (): number { + const options: any = this.appliedOptions + return options.step ?? 1 + } + } +}) export default customRenderer const locationIDTester: Tester = and( isIntegerControl, optionIs('locationId', true) -); +) export const entry: JsonFormsRendererRegistryEntry = { renderer: customRenderer, - tester: rankWith(10, locationIDTester), -}; + tester: rankWith(10, locationIDTester) +} diff --git a/src/components/ExistingRecord.vue b/src/components/ExistingRecord.vue index 50a71fb..6c0db8e 100644 --- a/src/components/ExistingRecord.vue +++ b/src/components/ExistingRecord.vue @@ -22,37 +22,37 @@ import router from '@/router' import { defineComponent, ref, Ref } from '@vue/composition-api' import { ErrorObject } from 'ajv' import { JsonForms, JsonFormsChangeEvent } from '@jsonforms/vue2' -import { createAjv,vuetifyRenderers } from '@jsonforms/vue2-vuetify' -import { entry } from './CustomRenderer.vue'; -import { langEntry } from './ShowLanguageRenderer.vue'; -import { typeEntry } from './ShowTypes.vue'; -import { genListEntry } from './GenerateListRenderer.vue'; -import { input as rorSchema } from "@/jsonSchema/rorSchema"; +import { createAjv, vuetifyRenderers } from '@jsonforms/vue2-vuetify' +import { entry } from './CustomRenderer.vue' +import { langEntry } from './ShowLanguageRenderer.vue' +import { typeEntry } from './ShowTypes.vue' +import { genListEntry } from './GenerateListRenderer.vue' +import { input as rorSchema } from '@/jsonSchema/rorSchema' const renderers = [ ...vuetifyRenderers, -entry, -langEntry, -typeEntry, -genListEntry -]; -const handleDefaultsAjv = createAjv({useDefaults: true}); + entry, + langEntry, + typeEntry, + genListEntry +] +const handleDefaultsAjv = createAjv({ useDefaults: true }) export default defineComponent({ name: 'ExistingRecord', components: { JsonForms }, - setup() { + setup () { // declare a reactive property within the composition API's setup method const ror = ref(rorSchema) // return properties - these get merged with data() below return { ror } }, data () { - //const data: Record = {}; + // const data: Record = {}; const errors: any = ref(undefined) - const validForm: boolean = errors?.value?.length == 0 ? true : false + const validForm: boolean = errors?.value?.length === 0 return { // freeze renderers for performance gains renderers: Object.freeze(renderers), @@ -63,7 +63,7 @@ export default defineComponent({ validForm } }, - mounted() { + mounted () { if (this.data === undefined) { router.push({ name: 'NewRecord' @@ -71,7 +71,7 @@ export default defineComponent({ } }, methods: { - download() { + download () { var dataStr = 'data:application/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(this.data, null, 2)) return dataStr }, @@ -82,7 +82,7 @@ export default defineComponent({ onChange (event: JsonFormsChangeEvent) { this.data = event.data this.errors.value = event.errors - this.validForm = this.errors.value?.length == 0 ? true : false + this.validForm = this.errors.value?.length === 0 } } }) diff --git a/src/components/GenerateListRenderer.vue b/src/components/GenerateListRenderer.vue index 254f6a3..d1fd0d8 100644 --- a/src/components/GenerateListRenderer.vue +++ b/src/components/GenerateListRenderer.vue @@ -42,18 +42,17 @@ import { optionIs, isPrimitiveArrayControl, and -} from '@jsonforms/core'; + , CoreActions +} from '@jsonforms/core' import { defineComponent, inject } from '@vue/composition-api' import { rendererProps, useJsonFormsControl, - RendererProps, -} from '@jsonforms/vue2'; -import { ControlWrapper } from '@jsonforms/vue2-vuetify'; -import { useVuetifyControl } from '@jsonforms/vue2-vuetify'; -import { VCombobox, VHover } from 'vuetify/lib'; -import { CoreActions } from '@jsonforms/core'; + RendererProps +} from '@jsonforms/vue2' +import { ControlWrapper, useVuetifyControl } from '@jsonforms/vue2-vuetify' +import { VCombobox, VHover } from 'vuetify/lib' export const genListRenderer = defineComponent({ name: 'list-renderer', @@ -64,39 +63,38 @@ export const genListRenderer = defineComponent({ VHover }, props: { - ...rendererProps(), + ...rendererProps() }, - setup(props: RendererProps) { - const dispatch = inject>('dispatch'); + setup (props: RendererProps) { + const dispatch = inject>('dispatch') const vControl = useVuetifyControl( useJsonFormsControl(props), (value) => parseInt(value, 10) || undefined - ); - return { ...vControl, dispatch }; + ) + return { ...vControl, dispatch } }, computed: { - step(): number { - const options: any = this.appliedOptions; + step (): number { + const options: any = this.appliedOptions console.log(this.appliedOptions) - return options.step ?? 1; - }, + return options.step ?? 1 + } }, methods: { - onChange(e: string) { - if (this.dispatch ) { - this.dispatch(Actions.update(this.control.path, () => e)); - } + onChange (e: string) { + if (this.dispatch) { + this.dispatch(Actions.update(this.control.path, () => e)) + } } } -}); +}) export default genListRenderer const genListTester: Tester = and(optionIs('genList', true), isPrimitiveArrayControl) - export const genListEntry: JsonFormsRendererRegistryEntry = { renderer: genListRenderer, - tester: rankWith(10, genListTester), -}; + tester: rankWith(10, genListTester) +} diff --git a/src/components/NewRecord.vue b/src/components/NewRecord.vue index 8f68739..2732c34 100644 --- a/src/components/NewRecord.vue +++ b/src/components/NewRecord.vue @@ -25,39 +25,38 @@ diff --git a/src/components/ShowTypes.vue b/src/components/ShowTypes.vue index 886cce1..f558e22 100644 --- a/src/components/ShowTypes.vue +++ b/src/components/ShowTypes.vue @@ -38,18 +38,17 @@ import { Actions, Tester, optionIs, -} from '@jsonforms/core'; + CoreActions +} from '@jsonforms/core' import { defineComponent, inject } from '@vue/composition-api' import { rendererProps, useJsonFormsControl, - RendererProps, -} from '@jsonforms/vue2'; -import { ControlWrapper } from '@jsonforms/vue2-vuetify'; -import { useVuetifyControl } from '@jsonforms/vue2-vuetify'; -import { VSelect, VHover } from 'vuetify/lib'; -import { CoreActions } from '@jsonforms/core'; + RendererProps +} from '@jsonforms/vue2' +import { ControlWrapper, useVuetifyControl } from '@jsonforms/vue2-vuetify' +import { VSelect, VHover } from 'vuetify/lib' export const showTypeRenderer = defineComponent({ name: 'type-renderer', @@ -60,38 +59,37 @@ export const showTypeRenderer = defineComponent({ VHover }, props: { - ...rendererProps(), + ...rendererProps() }, - setup(props: RendererProps) { - const dispatch = inject>('dispatch'); + setup (props: RendererProps) { + const dispatch = inject>('dispatch') const vControl = useVuetifyControl( useJsonFormsControl(props), (value) => parseInt(value, 10) || undefined - ); - return { ...vControl, dispatch }; + ) + return { ...vControl, dispatch } }, computed: { - step(): number { - const options: any = this.appliedOptions; - return options.step ?? 1; - }, + step (): number { + const options: any = this.appliedOptions + return options.step ?? 1 + } }, methods: { - onChange(e: string) { - if (this.dispatch) { - this.dispatch(Actions.update(this.control.path, () => e)); - } + onChange (e: string) { + if (this.dispatch) { + this.dispatch(Actions.update(this.control.path, () => e)) + } } } -}); +}) export default showTypeRenderer const typeTester: Tester = optionIs('type', true) - export const typeEntry: JsonFormsRendererRegistryEntry = { renderer: showTypeRenderer, - tester: rankWith(10, typeTester), -}; + tester: rankWith(10, typeTester) +} diff --git a/src/env.ts b/src/env.ts index 8f675c0..28ed972 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,9 +1,9 @@ export const env = () => { - const { - VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', - VUE_APP_GENERATE_ID: GENERATE_ID = 'http://localhost:5000/generateid?mode=dev', - VUE_APP_ADDRESS_URL: ADDRESS_URL = 'http://localhost:5000/address', - NODE_ENV - } = process.env; - return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV }; - }; \ No newline at end of file + const { + VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', + VUE_APP_GENERATE_ID: GENERATE_ID = 'http://localhost:5000/generateid?mode=dev', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'http://localhost:5000/address', + NODE_ENV + } = process.env + return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } +} diff --git a/src/jsonSchema/rorSchema/index.ts b/src/jsonSchema/rorSchema/index.ts index eec4d94..c743b56 100644 --- a/src/jsonSchema/rorSchema/index.ts +++ b/src/jsonSchema/rorSchema/index.ts @@ -1,11 +1,10 @@ -import schema from "./schema.json"; -import data from "./data.json"; -import uischema from "./uischema.json"; -import { UISchemaElement, JsonSchema } from "@jsonforms/core"; +import schema from './schema.json' +import data from './data.json' +import uischema from './uischema.json' +import { UISchemaElement, JsonSchema } from '@jsonforms/core' export const input: { schema: JsonSchema; uischema: UISchemaElement; data: any; - } = { schema, uischema, data }; - + } = { schema, uischema, data } diff --git a/src/router/index.ts b/src/router/index.ts index f952b54..80b1db9 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -10,9 +10,9 @@ export default new Router({ base: process.env.BASE_URL, routes: [ { - path: '/', - name: 'Main', - component: Main + path: '/', + name: 'Main', + component: Main }, { path: '/new', @@ -20,10 +20,10 @@ export default new Router({ component: NewRecord }, { - path: '/exist', - name: 'ExistingRecord', - component: ExistingRecord, - props: true + path: '/exist', + name: 'ExistingRecord', + component: ExistingRecord, + props: true } ] }) From daff17ca8db5a6bc6851244288454a44c12775dd Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Fri, 15 Apr 2022 13:58:31 -0500 Subject: [PATCH 17/29] clear address if geonames id deleted --- src/components/CustomRenderer.vue | 45 +++++++++++++------------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index a579e66..549d26e 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -80,33 +80,22 @@ export const customRenderer = defineComponent({ return ["line", "postcode", "primary", "state", "state_code"] }, clearAddress(path: string) { + const rootData = this.jsonforms?.core?.data if (this.dispatch) { - let address = this.jsonforms?.core?.data.addresses[0]; - let updatedData = this.jsonforms?.core?.data; - const ignoreFields = this.ignoreFields() - for (const i in address) { - let field = path + i - if (!(ignoreFields.includes(i))) - { - if (i == "geonames_city") { - for (const f in address[i]) { - let city_field = field + "." + f - const admin_fields = ["geonames_admin1", "geonames_admin2"] - if (admin_fields.includes(f)){ - for (const a in address[i][f]) { - let adminField = city_field + "." + a - updatedData = set(adminField,null,updatedData); - } - } - updatedData = set(field+'.city',null,updatedData); - } - } - } - } + let updatedData = rootData + updatedData = set( + 'addresses.0', + {}, + updatedData + ) + updatedData = set( + 'country', + {}, + updatedData + ) this.dispatch( Actions.updateCore(updatedData, this.s as JsonSchema, this.ui)); } - }, fetchAddress (id: string) { const url = new URL(env().ADDRESS_URL) @@ -115,10 +104,7 @@ export const customRenderer = defineComponent({ const rootData = this.jsonforms?.core?.data fetch(url.toString()).then((response) => { response.json().then((data) => { - console.log(data) if (data.address.geonames_city.id) { - console.log('Address OK') - console.log(rootData) if (this.dispatch) { let updatedData = rootData updatedData = set( @@ -153,10 +139,15 @@ export const customRenderer = defineComponent({ }, getAddress (e: number) { const id = e.toString() + const lat = this.jsonforms?.core?.data.addresses[0].lat if (lat) { + this.clearAddress(strPath) + } + if(id) + this.fetchAddress(id) + else { this.clearAddress('addresses.0') } - this.fetchAddress(id) } }, computed: { From 75a79b35ea219e46551144d09f945dadf53837ba Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Fri, 15 Apr 2022 14:04:36 -0500 Subject: [PATCH 18/29] add missing var --- src/components/CustomRenderer.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index 549d26e..66d66ce 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -140,13 +140,14 @@ export const customRenderer = defineComponent({ getAddress (e: number) { const id = e.toString() const lat = this.jsonforms?.core?.data.addresses[0].lat + const strPath = 'addresses.0' if (lat) { this.clearAddress(strPath) } if(id) this.fetchAddress(id) else { - this.clearAddress('addresses.0') + this.clearAddress(strPath) } } }, From c33e5083fd29a4b57ab40f68d962c99f29f283ae Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Fri, 15 Apr 2022 15:04:59 -0500 Subject: [PATCH 19/29] update env vars --- src/env.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/env.ts b/src/env.ts index 28ed972..47f8751 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,8 +1,8 @@ export const env = () => { const { VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', - VUE_APP_GENERATE_ID: GENERATE_ID = 'http://localhost:5000/generateid?mode=dev', - VUE_APP_ADDRESS_URL: ADDRESS_URL = 'http://localhost:5000/address', + VUE_APP_GENERATE_ID: GENERATE_ID = 'https://generateid.dev.ror.org/generateid', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'https://generateid.dev.ror.org/address', NODE_ENV } = process.env return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } From 24b20c08d2cc1e1bc176632fa1afdae1a6db9c83 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Tue, 19 Apr 2022 13:16:09 -0500 Subject: [PATCH 20/29] allow null values in admin1 fields --- src/jsonSchema/rorSchema/schema.json | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/jsonSchema/rorSchema/schema.json b/src/jsonSchema/rorSchema/schema.json index 72618aa..2bc5869 100644 --- a/src/jsonSchema/rorSchema/schema.json +++ b/src/jsonSchema/rorSchema/schema.json @@ -106,22 +106,22 @@ "properties": { "ascii_name": { "readOnly": true, - "type": "string", + "type": ["string","null"], "default": null }, "name": { "readOnly": true, - "type": "string", + "type": ["string","null"], "default": null }, "id": { - "type": "integer", "readOnly": true, + "type": ["integer","null"], "default": null }, "code": { "readOnly": true, - "type": "string", + "type": ["string","null"], "default": null } } @@ -132,19 +132,23 @@ "properties": { "ascii_name": { "readOnly": true, - "type": ["string","null"] + "type": ["string","null"], + "default": null }, "name": { "readOnly": true, - "type": ["string","null"] + "type": ["string","null"], + "default": null }, "id": { + "readOnly": true, "type": ["integer","null"], - "readOnly": true + "default": null }, "code": { "readOnly": true, - "type": ["string","null"] + "type": ["string","null"], + "default": null } } }, From 927f722f2787d6e59f9470e7456ae13ad20f8ed2 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Thu, 21 Apr 2022 17:02:23 -0500 Subject: [PATCH 21/29] update address on existing record automatically --- src/components/ExistingRecord.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/ExistingRecord.vue b/src/components/ExistingRecord.vue index 6c0db8e..9f55e75 100644 --- a/src/components/ExistingRecord.vue +++ b/src/components/ExistingRecord.vue @@ -23,7 +23,7 @@ import { defineComponent, ref, Ref } from '@vue/composition-api' import { ErrorObject } from 'ajv' import { JsonForms, JsonFormsChangeEvent } from '@jsonforms/vue2' import { createAjv, vuetifyRenderers } from '@jsonforms/vue2-vuetify' -import { entry } from './CustomRenderer.vue' +import { entry, customRenderer } from './CustomRenderer.vue' import { langEntry } from './ShowLanguageRenderer.vue' import { typeEntry } from './ShowTypes.vue' import { genListEntry } from './GenerateListRenderer.vue' @@ -68,6 +68,10 @@ export default defineComponent({ router.push({ name: 'NewRecord' }) + } else { + if(this.data.addresses[0].geonames_city.id){ + customRenderer.methods.getAddress(this.data.addresses[0].geonames_city.id) + } } }, methods: { From f0e2fa79a9351ae47b58f04a43d6dd976f90757d Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Thu, 21 Apr 2022 17:22:19 -0500 Subject: [PATCH 22/29] fix type errors --- src/components/ExistingRecord.vue | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/ExistingRecord.vue b/src/components/ExistingRecord.vue index 9f55e75..c845145 100644 --- a/src/components/ExistingRecord.vue +++ b/src/components/ExistingRecord.vue @@ -68,10 +68,6 @@ export default defineComponent({ router.push({ name: 'NewRecord' }) - } else { - if(this.data.addresses[0].geonames_city.id){ - customRenderer.methods.getAddress(this.data.addresses[0].geonames_city.id) - } } }, methods: { @@ -84,6 +80,9 @@ export default defineComponent({ return fname }, onChange (event: JsonFormsChangeEvent) { + if(event.data.addresses[0].geonames_city.id){ + customRenderer?.methods?.getAddress(event.data.addresses[0].geonames_city.id) + } this.data = event.data this.errors.value = event.errors this.validForm = this.errors.value?.length === 0 From 197f39b73c724679bd39c936c85642afdc9c4ec3 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Tue, 26 Apr 2022 12:14:01 -0500 Subject: [PATCH 23/29] force address component to render on load --- src/components/CustomRenderer.vue | 6 ++++++ src/components/ExistingRecord.vue | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/CustomRenderer.vue b/src/components/CustomRenderer.vue index 66d66ce..d3c61f1 100644 --- a/src/components/CustomRenderer.vue +++ b/src/components/CustomRenderer.vue @@ -75,6 +75,12 @@ export const customRenderer = defineComponent({ ) return { ...vControl, dispatch, jsonforms, s, ui } }, + mounted () { + // if it's an existing record update the address + if (this.jsonforms?.core?.data.addresses[0].geonames_city.id) { + this.getAddress(this.jsonforms?.core?.data.addresses[0].geonames_city.id) + } + }, methods: { ignoreFields() { return ["line", "postcode", "primary", "state", "state_code"] diff --git a/src/components/ExistingRecord.vue b/src/components/ExistingRecord.vue index c845145..a4022ff 100644 --- a/src/components/ExistingRecord.vue +++ b/src/components/ExistingRecord.vue @@ -60,7 +60,7 @@ export default defineComponent({ id: this.$route.query.id, data: this.$route.params.item, errors: errors, - validForm + validForm, } }, mounted () { @@ -68,6 +68,12 @@ export default defineComponent({ router.push({ name: 'NewRecord' }) + } else { + //hack to force CustomRenderer component to render so that address can be updated on existing record + const listEl = document.querySelector(".v-list-item.v-list-item--dense.v-list-item--link.theme--light.list-with-detail-item") + if(listEl){ + listEl.dispatchEvent(new Event("click")) + } } }, methods: { @@ -80,9 +86,6 @@ export default defineComponent({ return fname }, onChange (event: JsonFormsChangeEvent) { - if(event.data.addresses[0].geonames_city.id){ - customRenderer?.methods?.getAddress(event.data.addresses[0].geonames_city.id) - } this.data = event.data this.errors.value = event.errors this.validForm = this.errors.value?.length === 0 From f087b2bbb3fb318046f3ad82ef3d9426c9b9e490 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Mon, 29 Aug 2022 11:06:43 -0500 Subject: [PATCH 24/29] copy env file during dev deploy --- .github/workflows/dev.yml | 9 +++++++-- src/env.dev.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/env.dev.ts diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 01175ed..ede1c9a 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -3,6 +3,9 @@ on: push: branches: - "dev" + paths-ignore: + - '**/README.md' + - '**/workflows/**' jobs: run: runs-on: ubuntu-latest @@ -14,8 +17,10 @@ jobs: - name: Install run: npm ci - name: Build - run: npm run build - - name: Deploy + run: | + cp src/env.dev.ts src/env.ts; + npm run build + - name: Deploy uses: reggionick/s3-deploy@v3.1.1 with: folder: dist diff --git a/src/env.dev.ts b/src/env.dev.ts new file mode 100644 index 0000000..47f8751 --- /dev/null +++ b/src/env.dev.ts @@ -0,0 +1,9 @@ +export const env = () => { + const { + VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', + VUE_APP_GENERATE_ID: GENERATE_ID = 'https://generateid.dev.ror.org/generateid', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'https://generateid.dev.ror.org/address', + NODE_ENV + } = process.env + return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } +} From 141d6c7ed40547a0d7d1810960342cbe216e463e Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Mon, 29 Aug 2022 11:18:28 -0500 Subject: [PATCH 25/29] add slack notification to dev workflow --- .github/workflows/dev.yml | 16 +++++++++++++++- src/env.ts | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index ede1c9a..fb7f2fe 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -12,6 +12,7 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} steps: - uses: actions/checkout@v2 - name: Install @@ -28,4 +29,17 @@ jobs: bucket-region: ${{ secrets.S3_BUCKET_REGION }} dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_CURATORFORM_DEV }} invalidation: /* - delete-removed: true \ No newline at end of file + delete-removed: true + - name: Notify Slack + if: always() + uses: edge/simple-slack-notify@master + with: + channel: "#deployment-updates" + color: 'good' + text: "A new version of the is deployed to dev." + failure_text: '${env.GITHUB_WORKFLOW} (${env.GITHUB_RUN_NUMBER}) build failed' + fields: | + [{ "title": "Committed by", "value": "", "short": true }, + { "title": "Commit SHA", "value": "", "short": true }, + { "title": "Repository", "value": "", "short": true }, + { "title": "Branch", "value": "", "short": true }] diff --git a/src/env.ts b/src/env.ts index 47f8751..dffb8a7 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,8 +1,8 @@ export const env = () => { const { VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', - VUE_APP_GENERATE_ID: GENERATE_ID = 'https://generateid.dev.ror.org/generateid', - VUE_APP_ADDRESS_URL: ADDRESS_URL = 'https://generateid.dev.ror.org/address', + VUE_APP_GENERATE_ID: GENERATE_ID = 'http://localhost:5000/generateid', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'http://localhost:5000/address', NODE_ENV } = process.env return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } From 0a3ecfa663deba259b2910d07f86001d975b1120 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Mon, 29 Aug 2022 11:20:02 -0500 Subject: [PATCH 26/29] fix slack msg --- .github/workflows/dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index fb7f2fe..c8e489b 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -39,7 +39,7 @@ jobs: text: "A new version of the is deployed to dev." failure_text: '${env.GITHUB_WORKFLOW} (${env.GITHUB_RUN_NUMBER}) build failed' fields: | - [{ "title": "Committed by", "value": "", "short": true }, - { "title": "Commit SHA", "value": "", "short": true }, + [{ "title": "Committed by", "value": "", "short": true }, + { "title": "Commit SHA", "value": "", "short": true }, { "title": "Repository", "value": "", "short": true }, - { "title": "Branch", "value": "", "short": true }] + { "title": "Branch", "value": "", "short": true }] From 2c2d05ec2b9ecc389840b5e48859e6791f2ed9be Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Mon, 29 Aug 2022 11:41:04 -0500 Subject: [PATCH 27/29] add staging and prod deployment actions --- .github/workflows/release.yml | 44 ++++++++++++++++++++++++++++++++++ .github/workflows/staging.yml | 45 +++++++++++++++++++++++++++++++++++ src/env.prod.ts | 9 +++++++ src/env.staging.ts | 9 +++++++ 4 files changed, 107 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/staging.yml create mode 100644 src/env.prod.ts create mode 100644 src/env.staging.ts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..93079fe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: Release +on: + release: + types: [published] + paths-ignore: + - '**/README.md' + - '**/workflows/**' +jobs: + run: + runs-on: ubuntu-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + steps: + - uses: actions/checkout@v2 + - name: Install + run: npm ci + - name: Build + run: | + cp src/env.prod.ts src/env.ts; + npm run build + - name: Deploy + uses: reggionick/s3-deploy@v3.1.1 + with: + folder: dist + bucket: ${{ secrets.S3_BUCKET_CURATORFORM_PROD}} + bucket-region: ${{ secrets.S3_BUCKET_REGION }} + dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_CURATORFORM_PROD }} + invalidation: /* + delete-removed: true + - name: Notify Slack + if: always() + uses: edge/simple-slack-notify@master + with: + channel: "#deployment-updates" + color: 'good' + text: "A new version of the is deployed to production." + failure_text: '${env.GITHUB_WORKFLOW} (${env.GITHUB_RUN_NUMBER}) build failed' + fields: | + [{ "title": "Commit message", "value": "${{ steps.extract_variables.outputs.MESSAGE }}" }, + { "title": "Committed by", "value": "", "short": true }, + { "title": "Commit SHA", "value": "", "short": true }, + { "title": "Repository", "value": "", "short": true }, + { "title": "Branch", "value": "", "short": true }] \ No newline at end of file diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 0000000..7face52 --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,45 @@ +name: Deploy Staging +on: + push: + branches: + - "staging" + paths-ignore: + - '**/README.md' + - '**/workflows/**' +jobs: + run: + runs-on: ubuntu-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + steps: + - uses: actions/checkout@v2 + - name: Install + run: npm ci + - name: Build + run: | + cp src/env.staging.ts src/env.ts; + npm run build + - name: Deploy + uses: reggionick/s3-deploy@v3.1.1 + with: + folder: dist + bucket: ${{ secrets.S3_BUCKET_CURATORFORM_STAGING}} + bucket-region: ${{ secrets.S3_BUCKET_REGION }} + dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_CURATORFORM_STAGING }} + invalidation: /* + delete-removed: true + - name: Notify Slack + if: always() + uses: edge/simple-slack-notify@master + with: + channel: "#deployment-updates" + color: 'good' + text: "A new version of the is deployed to staging." + failure_text: '${env.GITHUB_WORKFLOW} (${env.GITHUB_RUN_NUMBER}) build failed' + fields: | + [{ "title": "Commit message", "value": "${{ steps.extract_variables.outputs.MESSAGE }}" }, + { "title": "Committed by", "value": "", "short": true }, + { "title": "Commit SHA", "value": "", "short": true }, + { "title": "Repository", "value": "", "short": true }, + { "title": "Branch", "value": "", "short": true }] diff --git a/src/env.prod.ts b/src/env.prod.ts new file mode 100644 index 0000000..731ca3c --- /dev/null +++ b/src/env.prod.ts @@ -0,0 +1,9 @@ +export const env = () => { + const { + VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', + VUE_APP_GENERATE_ID: GENERATE_ID = 'https://generateid.ror.org/generateid', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'https://generateid.ror.org/address', + NODE_ENV + } = process.env + return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } +} diff --git a/src/env.staging.ts b/src/env.staging.ts new file mode 100644 index 0000000..31663af --- /dev/null +++ b/src/env.staging.ts @@ -0,0 +1,9 @@ +export const env = () => { + const { + VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', + VUE_APP_GENERATE_ID: GENERATE_ID = 'https://generateid.staging.ror.org/generateid', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'https://generateid.staging.ror.org/address', + NODE_ENV + } = process.env + return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } +} From 5db64f2858fdcc8cdcb3a75c5ea2310833f3978b Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Mon, 29 Aug 2022 11:46:02 -0500 Subject: [PATCH 28/29] fix typos --- .github/workflows/release.yml | 3 --- .github/workflows/staging.yml | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93079fe..69f0477 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,9 +2,6 @@ name: Release on: release: types: [published] - paths-ignore: - - '**/README.md' - - '**/workflows/**' jobs: run: runs-on: ubuntu-latest diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 7face52..aa504ec 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -3,9 +3,9 @@ on: push: branches: - "staging" - paths-ignore: - - '**/README.md' - - '**/workflows/**' + paths-ignore: + - '**/README.md' + - '**/workflows/**' jobs: run: runs-on: ubuntu-latest From f08ad0b64f698cf0ea8d8519f3990519804335f3 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Mon, 29 Aug 2022 11:52:21 -0500 Subject: [PATCH 29/29] add slack webhook url --- .github/workflows/release.yml | 1 + .github/workflows/staging.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69f0477..7f5e9d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} steps: - uses: actions/checkout@v2 - name: Install diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index aa504ec..e872aba 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -12,6 +12,7 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} steps: - uses: actions/checkout@v2 - name: Install