From ffc05893ef0c14d82ffe12874f00c8426f803b68 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Thu, 28 Nov 2024 13:45:05 +1000 Subject: [PATCH 01/18] Removed release trigger & artifact uploading --- .github/workflows/upload-pwa-builds.yml | 18 +++++------------- cicd/build.sh | 4 ++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/upload-pwa-builds.yml b/.github/workflows/upload-pwa-builds.yml index b466205..2ceac71 100644 --- a/.github/workflows/upload-pwa-builds.yml +++ b/.github/workflows/upload-pwa-builds.yml @@ -1,11 +1,11 @@ name: Build BioCollect PWA Artifacts on: - release: - types: [created] push: branches: - 'feature/**' + - 'main' + - 'testing' jobs: build-and-attach: @@ -26,34 +26,26 @@ jobs: - name: Build app for CICD run: npm run build:cicd - - name: Upload build assets - if: github.event_name == 'release' - run: gh release upload "${{ github.event.release.tag_name }}" ./dist/app-production.zip ./dist/app-staging.zip ./dist/app-testing.zip ./dist/app-development.zip --clobber - - name: Upload production artifact - if: github.event_name == 'push' uses: actions/upload-artifact@v4 with: name: app-production - path: dist/app-production.zip + path: dist/app-prod.zip - name: Upload staging artifact - if: github.event_name == 'push' uses: actions/upload-artifact@v4 with: name: app-staging path: dist/app-staging.zip - name: Upload testing artifact - if: github.event_name == 'push' uses: actions/upload-artifact@v4 with: name: app-testing - path: dist/app-testing.zip + path: dist/app-test.zip - name: Upload development artifact - if: github.event_name == 'push' uses: actions/upload-artifact@v4 with: name: app-development - path: dist/app-development.zip + path: dist/app-dev.zip diff --git a/cicd/build.sh b/cicd/build.sh index a8189f2..66ee724 100755 --- a/cicd/build.sh +++ b/cicd/build.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash -tsc && for mode in production staging testing development; do +tsc && for mode in prod staging test dev; do outDir="./dist/app-$mode" zipFile="./dist/app-$mode.zip" # If the mode is production, you may not need to specify the --mode flag - if [ "$mode" = "production" ]; then + if [ "$mode" = "prod" ]; then vite build --outDir "$outDir" else vite build --mode "$mode" --outDir "$outDir" From 7d6426c00661950207bf58a11a822df1ec5979bc Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Thu, 28 Nov 2024 13:57:04 +1000 Subject: [PATCH 02/18] Update upload-pwa-builds.yml --- .github/workflows/upload-pwa-builds.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload-pwa-builds.yml b/.github/workflows/upload-pwa-builds.yml index 2ceac71..559f758 100644 --- a/.github/workflows/upload-pwa-builds.yml +++ b/.github/workflows/upload-pwa-builds.yml @@ -29,7 +29,7 @@ jobs: - name: Upload production artifact uses: actions/upload-artifact@v4 with: - name: app-production + name: app-prod path: dist/app-prod.zip - name: Upload staging artifact @@ -41,11 +41,11 @@ jobs: - name: Upload testing artifact uses: actions/upload-artifact@v4 with: - name: app-testing + name: app-test path: dist/app-test.zip - name: Upload development artifact uses: actions/upload-artifact@v4 with: - name: app-development + name: app-dev path: dist/app-dev.zip From ddaa60db3d75c0a79d834215ac7ceaf0ff9afd14 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Mon, 2 Dec 2024 11:45:51 +1000 Subject: [PATCH 03/18] Update build.sh --- cicd/build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cicd/build.sh b/cicd/build.sh index 66ee724..886c03a 100755 --- a/cicd/build.sh +++ b/cicd/build.sh @@ -2,8 +2,7 @@ tsc && for mode in prod staging test dev; do outDir="./dist/app-$mode" - zipFile="./dist/app-$mode.zip" - + # If the mode is production, you may not need to specify the --mode flag if [ "$mode" = "prod" ]; then vite build --outDir "$outDir" @@ -11,5 +10,7 @@ tsc && for mode in prod staging test dev; do vite build --mode "$mode" --outDir "$outDir" fi - zip -r "$zipFile" "$outDir" + cd "./dist/app-$mode" + zip -r "../app-$mode.zip" . * + cd ../.. done \ No newline at end of file From 2312f2e807d39a5a5eb173c263c47d400844aa5c Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Mon, 2 Dec 2024 16:29:54 +1000 Subject: [PATCH 04/18] Authentication configuration fixes --- config/.env.production | 4 ++-- config/.env.staging | 10 +++++----- config/.env.testing | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/.env.production b/config/.env.production index c39a9e0..6ff591d 100644 --- a/config/.env.production +++ b/config/.env.production @@ -1,12 +1,12 @@ # Authentication VITE_AUTH_AUTHORITY=https://auth.ala.org.au/cas/oidc/.well-known VITE_AUTH_CLIENT_ID=biocollect-pwa-prod -VITE_AUTH_REDIRECT_URI=https://biocollect-dev.ala.org.au/pwa-mobile +VITE_AUTH_REDIRECT_URI=https://biocollect.ala.org.au/pwa-mobile # VITE_AUTH_END_SESSION_URI=ENTER-HERE VITE_AUTH_SCOPE="openid profile ala roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API VITE_API_TIMEOUT=0 -VITE_API_BIOCOLLECT=https://biocollect-dev.ala.org.au +VITE_API_BIOCOLLECT=https://biocollect.ala.org.au VITE_API_BIOCOLLECT_HUB=acsa \ No newline at end of file diff --git a/config/.env.staging b/config/.env.staging index 4500184..f1ac3cb 100644 --- a/config/.env.staging +++ b/config/.env.staging @@ -1,9 +1,9 @@ # Authentication -VITE_AUTH_AUTHORITY=ENTER-HERE -VITE_AUTH_CLIENT_ID=ENTER-HERE -VITE_AUTH_REDIRECT_URI=ENTER-HERE -VITE_AUTH_END_SESSION_URI=ENTER-HERE -VITE_AUTH_SCOPE=ENTER-HERE +VITE_AUTH_AUTHORITY=https://auth.ala.org.au/cas/oidc/.well-known +VITE_AUTH_CLIENT_ID=biocollect-pwa-prod +VITE_AUTH_REDIRECT_URI=https://biocollect-staging.ala.org.au/pwa-mobile +# VITE_AUTH_END_SESSION_URI=ENTER-HERE +VITE_AUTH_SCOPE="openid profile ala roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API diff --git a/config/.env.testing b/config/.env.testing index d96da63..5275865 100644 --- a/config/.env.testing +++ b/config/.env.testing @@ -3,9 +3,9 @@ # VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob VITE_AUTH_AUTHORITY=https://auth-test.ala.org.au/cas/oidc/.well-known VITE_AUTH_CLIENT_ID=biocollect-pwa-test -VITE_AUTH_REDIRECT_URI=https://biocollect-pwa.test.ala.org.au +VITE_AUTH_REDIRECT_URI=https://biocollect-test.ala.org.au/pwa-mobile # VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout -VITE_AUTH_SCOPE=ENTER-HERE +#VITE_AUTH_SCOPE=ENTER-HERE VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API From ec96f2835cd1b8c66ea0f414a0b66a3b0d50399b Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Mon, 2 Dec 2024 16:40:53 +1000 Subject: [PATCH 05/18] Log auth config for development applications --- src/main.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index d156fbb..1965f61 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -16,13 +16,21 @@ import App from './App'; // Use localStorage for user persistence const userStore = new WebStorageStateStore({ store: localStorage }); +const authConfig = { + client_id: import.meta.env.VITE_AUTH_CLIENT_ID, + redirect_uri: import.meta.env.VITE_AUTH_REDIRECT_URI, + authority: import.meta.env.VITE_AUTH_AUTHORITY, + scope: import.meta.env.VITE_AUTH_SCOPE, +} + +if (import.meta.env.DEV) { + console.log('Auth Config', authConfig); +} + function Main() { return ( { const params = new URLSearchParams(window.location.search); From 810377465680ceee4630707af66d8b6f7bdec317 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Mon, 2 Dec 2024 16:44:43 +1000 Subject: [PATCH 06/18] Renamed environment configuration files to match CICD building --- config/{.env.development => .env.dev} | 0 config/{.env.production => .env.prod} | 0 config/{.env.testing => .env.test} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename config/{.env.development => .env.dev} (100%) rename config/{.env.production => .env.prod} (100%) rename config/{.env.testing => .env.test} (100%) diff --git a/config/.env.development b/config/.env.dev similarity index 100% rename from config/.env.development rename to config/.env.dev diff --git a/config/.env.production b/config/.env.prod similarity index 100% rename from config/.env.production rename to config/.env.prod diff --git a/config/.env.testing b/config/.env.test similarity index 100% rename from config/.env.testing rename to config/.env.test From d7b232e6daf4b0b5bb002a9e383a41ab93e22f26 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Tue, 3 Dec 2024 09:18:56 +1000 Subject: [PATCH 07/18] Fixed testing configuration to use cognito --- config/.env.test | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/.env.test b/config/.env.test index 5275865..1cf723f 100644 --- a/config/.env.test +++ b/config/.env.test @@ -1,11 +1,11 @@ # Authentication -# VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_OOXU9GW39 -# VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob -VITE_AUTH_AUTHORITY=https://auth-test.ala.org.au/cas/oidc/.well-known -VITE_AUTH_CLIENT_ID=biocollect-pwa-test +VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_OOXU9GW39 +VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob +# VITE_AUTH_AUTHORITY=https://auth-test.ala.org.au/cas/oidc/.well-known +# VITE_AUTH_CLIENT_ID=biocollect-pwa-test VITE_AUTH_REDIRECT_URI=https://biocollect-test.ala.org.au/pwa-mobile -# VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout -#VITE_AUTH_SCOPE=ENTER-HERE +VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout +VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API From eaa5dfe04288fe9643f04929593a7f74dc22d8a0 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 4 Dec 2024 09:32:42 +1000 Subject: [PATCH 08/18] Removed unnecessary build config, fixed survey queryin --- config/.env.dev | 17 ++++++++--------- package.json | 6 +----- src/helpers/api/endpoints/biocollect.ts | 3 +-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/config/.env.dev b/config/.env.dev index d6142fa..a39787e 100644 --- a/config/.env.dev +++ b/config/.env.dev @@ -1,15 +1,14 @@ # Authentication -# VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_OOXU9GW39 -# VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob -VITE_AUTH_AUTHORITY=https://auth.ala.org.au/cas/oidc/.well-known -VITE_AUTH_CLIENT_ID=biocollect-pwa-prod -VITE_AUTH_REDIRECT_URI=https://biocollect-dev.ala.org.au/pwa-mobile -# VITE_AUTH_REDIRECT_URI=http://localhost:5173/pwa-mobile -# VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout -# VITE_AUTH_SCOPE="ala" +VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_OOXU9GW39 +VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob +# VITE_AUTH_AUTHORITY=https://auth-test.ala.org.au/cas/oidc/.well-known +# VITE_AUTH_CLIENT_ID=biocollect-pwa-test +VITE_AUTH_REDIRECT_URI=http://localhost:5173 +VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout +VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API VITE_API_TIMEOUT=0 -VITE_API_BIOCOLLECT=https://biocollect-dev.ala.org.au +VITE_API_BIOCOLLECT=https://biocollect-test.ala.org.au VITE_API_BIOCOLLECT_HUB=acsa \ No newline at end of file diff --git a/package.json b/package.json index 944b071..6288d63 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,8 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite --host", + "dev": "vite --host --mode dev", "run:functionaltest": "vite --host --mode functionaltest", - "build:production": "tsc && vite build", - "build:staging": "tsc && vite build --mode staging", - "build:testing": "tsc && vite build --mode testing", - "build:development": "tsc && vite build --mode development", "build:functionaltest": "tsc && vite build --mode functionaltest", "build:cicd": "./cicd/build.sh", "lint": "eslint ./src", diff --git a/src/helpers/api/endpoints/biocollect.ts b/src/helpers/api/endpoints/biocollect.ts index 8aa6d97..f34491e 100644 --- a/src/helpers/api/endpoints/biocollect.ts +++ b/src/helpers/api/endpoints/biocollect.ts @@ -16,8 +16,7 @@ const filterActiveSurveys = (surveys: BioCollectSurvey[]) => surveys?.filter( ({ startDate, endDate, published }) => new Date(startDate).getTime() <= Date.now() && - (!endDate || new Date(endDate).getTime() >= Date.now()) && - published + (!endDate || new Date(endDate).getTime() >= Date.now()) && (published !== undefined ? published : true) ) || []; const formatProjects = (projects: BioCollectProject[]) => { From e789771d6d81b01aad701a9f2348a19a15c27e49 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 4 Dec 2024 11:05:43 +1000 Subject: [PATCH 09/18] Changed PWA path from pwa-mobile to mobile-app --- config/.env.functionaltest | 2 +- config/.env.prod | 2 +- config/.env.staging | 2 +- config/.env.test | 2 +- src/Routes.tsx | 2 +- vite.config.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/.env.functionaltest b/config/.env.functionaltest index d286942..91ab940 100644 --- a/config/.env.functionaltest +++ b/config/.env.functionaltest @@ -1,7 +1,7 @@ # Authentication VITE_AUTH_AUTHORITY=http://localhost:8018/cas/oidc/.well-known VITE_AUTH_CLIENT_ID=oidcId -VITE_AUTH_REDIRECT_URI=http://localhost:5173/pwa-mobile +VITE_AUTH_REDIRECT_URI=http://localhost:5173/mobile-app # VITE_AUTH_END_SESSION_URI=ENTER-HERE VITE_AUTH_SCOPE="openid profile ala roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 diff --git a/config/.env.prod b/config/.env.prod index 6ff591d..0b0a202 100644 --- a/config/.env.prod +++ b/config/.env.prod @@ -1,7 +1,7 @@ # Authentication VITE_AUTH_AUTHORITY=https://auth.ala.org.au/cas/oidc/.well-known VITE_AUTH_CLIENT_ID=biocollect-pwa-prod -VITE_AUTH_REDIRECT_URI=https://biocollect.ala.org.au/pwa-mobile +VITE_AUTH_REDIRECT_URI=https://biocollect.ala.org.au/mobile-app # VITE_AUTH_END_SESSION_URI=ENTER-HERE VITE_AUTH_SCOPE="openid profile ala roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 diff --git a/config/.env.staging b/config/.env.staging index f1ac3cb..7b24482 100644 --- a/config/.env.staging +++ b/config/.env.staging @@ -1,7 +1,7 @@ # Authentication VITE_AUTH_AUTHORITY=https://auth.ala.org.au/cas/oidc/.well-known VITE_AUTH_CLIENT_ID=biocollect-pwa-prod -VITE_AUTH_REDIRECT_URI=https://biocollect-staging.ala.org.au/pwa-mobile +VITE_AUTH_REDIRECT_URI=https://biocollect-staging.ala.org.au/mobile-app # VITE_AUTH_END_SESSION_URI=ENTER-HERE VITE_AUTH_SCOPE="openid profile ala roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 diff --git a/config/.env.test b/config/.env.test index 1cf723f..9de3365 100644 --- a/config/.env.test +++ b/config/.env.test @@ -3,7 +3,7 @@ VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeas VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob # VITE_AUTH_AUTHORITY=https://auth-test.ala.org.au/cas/oidc/.well-known # VITE_AUTH_CLIENT_ID=biocollect-pwa-test -VITE_AUTH_REDIRECT_URI=https://biocollect-test.ala.org.au/pwa-mobile +VITE_AUTH_REDIRECT_URI=https://biocollect-test.ala.org.au/mobile-app VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 diff --git a/src/Routes.tsx b/src/Routes.tsx index 1119a65..9e3b1bd 100644 --- a/src/Routes.tsx +++ b/src/Routes.tsx @@ -88,7 +88,7 @@ export default function Routes() { }, ], { - basename: '/pwa-mobile', + basename: '/mobile-app', } ) ); diff --git a/vite.config.ts b/vite.config.ts index d67fa61..1f11e41 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -88,7 +88,7 @@ const pwaOptions: Partial = { // https://vitejs.dev/config/ export default defineConfig({ - base: '/pwa-mobile', + base: '/mobile-app', plugins: [react(), tsconfigPaths(), visualizer() as any, VitePWA(pwaOptions)], envDir: './config', }); From 8cf3e7be0ac4e6944b2c214b5533b44b8defe396 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 4 Dec 2024 12:36:30 +1000 Subject: [PATCH 10/18] Fixed dev config --- config/.env.dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/.env.dev b/config/.env.dev index a39787e..1ada23c 100644 --- a/config/.env.dev +++ b/config/.env.dev @@ -3,12 +3,12 @@ VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeas VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob # VITE_AUTH_AUTHORITY=https://auth-test.ala.org.au/cas/oidc/.well-known # VITE_AUTH_CLIENT_ID=biocollect-pwa-test -VITE_AUTH_REDIRECT_URI=http://localhost:5173 +VITE_AUTH_REDIRECT_URI=https://biocollect-dev.ala.org.au/mobile-app VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API VITE_API_TIMEOUT=0 -VITE_API_BIOCOLLECT=https://biocollect-test.ala.org.au +VITE_API_BIOCOLLECT=https://biocollect-dev.ala.org.au VITE_API_BIOCOLLECT_HUB=acsa \ No newline at end of file From 4c8f83ff602771381947c06de27908fef6283808 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 4 Dec 2024 12:40:53 +1000 Subject: [PATCH 11/18] Point development build to test biocollect WS --- config/.env.dev | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/.env.dev b/config/.env.dev index 1ada23c..af03a7e 100644 --- a/config/.env.dev +++ b/config/.env.dev @@ -6,9 +6,10 @@ VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob VITE_AUTH_REDIRECT_URI=https://biocollect-dev.ala.org.au/mobile-app VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" +# VITE_AUTH_SCOPE="openid profile ala roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API VITE_API_TIMEOUT=0 -VITE_API_BIOCOLLECT=https://biocollect-dev.ala.org.au +VITE_API_BIOCOLLECT=https://biocollect-test.ala.org.au VITE_API_BIOCOLLECT_HUB=acsa \ No newline at end of file From e059057b3dbd11939acd4b4a5dec2601cd0a67d6 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 4 Dec 2024 14:23:50 +1000 Subject: [PATCH 12/18] Revert dev config to CAS auth-dev & biocollect-dev API --- config/.env.dev | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/.env.dev b/config/.env.dev index af03a7e..617d7dd 100644 --- a/config/.env.dev +++ b/config/.env.dev @@ -1,15 +1,15 @@ # Authentication -VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_OOXU9GW39 -VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob -# VITE_AUTH_AUTHORITY=https://auth-test.ala.org.au/cas/oidc/.well-known -# VITE_AUTH_CLIENT_ID=biocollect-pwa-test +# VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_OOXU9GW39 +# VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob +VITE_AUTH_AUTHORITY=https://auth-dev.ala.org.au/cas/oidc/.well-known +VITE_AUTH_CLIENT_ID=biocollect-pwa-dev VITE_AUTH_REDIRECT_URI=https://biocollect-dev.ala.org.au/mobile-app -VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout -VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" -# VITE_AUTH_SCOPE="openid profile ala roles" +# VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout +# VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" +VITE_AUTH_SCOPE="openid profile ala roles" VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000 # API VITE_API_TIMEOUT=0 -VITE_API_BIOCOLLECT=https://biocollect-test.ala.org.au +VITE_API_BIOCOLLECT=https://biocollect-dev.ala.org.au VITE_API_BIOCOLLECT_HUB=acsa \ No newline at end of file From 2b100b102082a977f825c9ddd56036cee3ab298e Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 4 Dec 2024 14:45:59 +1000 Subject: [PATCH 13/18] Dev to use CAS prod auth --- config/.env.dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/.env.dev b/config/.env.dev index 617d7dd..51b4dc3 100644 --- a/config/.env.dev +++ b/config/.env.dev @@ -1,8 +1,8 @@ # Authentication # VITE_AUTH_AUTHORITY=https://cognito-idp.ap-southeast-2.amazonaws.com/ap-southeast-2_OOXU9GW39 # VITE_AUTH_CLIENT_ID=7hrtrc4d6q4v6kkficnu7l43ob -VITE_AUTH_AUTHORITY=https://auth-dev.ala.org.au/cas/oidc/.well-known -VITE_AUTH_CLIENT_ID=biocollect-pwa-dev +VITE_AUTH_AUTHORITY=https://auth.ala.org.au/cas/oidc/.well-known +VITE_AUTH_CLIENT_ID=biocollect-pwa-prod VITE_AUTH_REDIRECT_URI=https://biocollect-dev.ala.org.au/mobile-app # VITE_AUTH_END_SESSION_URI=https://auth-secure.auth.ap-southeast-2.amazoncognito.com/logout # VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles" From bbbfebf850a59c1a9487ea31d326dc7b296cdf5d Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Thu, 5 Dec 2024 15:27:19 +1000 Subject: [PATCH 14/18] Made the project explorer home only show enrolled projects by default --- src/helpers/api/endpoints/biocollect.ts | 3 ++- src/views/Home/index.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/api/endpoints/biocollect.ts b/src/helpers/api/endpoints/biocollect.ts index f34491e..b3c09ed 100644 --- a/src/helpers/api/endpoints/biocollect.ts +++ b/src/helpers/api/endpoints/biocollect.ts @@ -16,7 +16,8 @@ const filterActiveSurveys = (surveys: BioCollectSurvey[]) => surveys?.filter( ({ startDate, endDate, published }) => new Date(startDate).getTime() <= Date.now() && - (!endDate || new Date(endDate).getTime() >= Date.now()) && (published !== undefined ? published : true) + (!endDate || new Date(endDate).getTime() >= Date.now()) && + (published !== undefined ? published : true) ) || []; const formatProjects = (projects: BioCollectProject[]) => { diff --git a/src/views/Home/index.tsx b/src/views/Home/index.tsx index 1d8dcd8..4d9b4ac 100644 --- a/src/views/Home/index.tsx +++ b/src/views/Home/index.tsx @@ -61,7 +61,7 @@ export function Home() { (getNumber('page', 1, params) - 1) * paramMax, paramMax, getString('pSort', 'dateCreatedSort', params), - getBool('isUserPage', false, params), + getBool('isUserPage', true, params), getString('search', undefined, params), getBool('offline', !onLine, params) ); From 58da263afc2d3f559456b9ddb13a180aa376ff46 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Fri, 6 Dec 2024 13:19:00 +1000 Subject: [PATCH 15/18] Tweaked header to fit mobile screen --- src/layout/Header.tsx | 23 ++++++++++++++++------- src/layout/InstallButton.tsx | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/layout/Header.tsx b/src/layout/Header.tsx index f79c5b2..805baaa 100644 --- a/src/layout/Header.tsx +++ b/src/layout/Header.tsx @@ -7,6 +7,7 @@ import { UnstyledButton, Badge, Loader, + ThemeIcon, } from '@mantine/core'; import { Link } from 'react-router-dom'; import { useAuth } from 'react-oidc-context'; @@ -18,6 +19,8 @@ import { IconFileUpload, IconUser, IconSettings, + IconPlugConnected, + IconPlugConnectedX, } from '@tabler/icons-react'; import jwtDecode from 'jwt-decode'; @@ -74,11 +77,17 @@ export default function Header() { } /> - - - {onLine ? 'online' : 'offline'} - - + + {onLine ? ( + + ) : ( + + )} + @@ -94,7 +103,7 @@ export default function Header() { const { user, isAuthenticated } = auth; if (!isAuthenticated) return ; - + // Use the given name from the profile field, otherwise fallback to the JWT const given_name = user?.profile.given_name || @@ -159,7 +168,7 @@ export default function Header() { Help } disabled={auth.isLoading || !onLine} diff --git a/src/layout/InstallButton.tsx b/src/layout/InstallButton.tsx index 2428ce8..62c61d6 100644 --- a/src/layout/InstallButton.tsx +++ b/src/layout/InstallButton.tsx @@ -114,7 +114,7 @@ export function InstallButton() { ) } > - {install ? 'Install' : 'Installation Instructions'} + {install ? 'Install' : 'Install Instructions'} Date: Mon, 9 Dec 2024 12:03:59 +1000 Subject: [PATCH 16/18] Update index.html --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 98230ea..892626f 100644 --- a/index.html +++ b/index.html @@ -5,19 +5,19 @@ Date: Tue, 10 Dec 2024 12:51:25 +1000 Subject: [PATCH 17/18] Update PWA help article --- src/layout/Header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layout/Header.tsx b/src/layout/Header.tsx index 805baaa..924055a 100644 --- a/src/layout/Header.tsx +++ b/src/layout/Header.tsx @@ -161,7 +161,7 @@ export default function Header() { } > From 73c319e2dea296b0b39f6b3e22c22f75fa3235b1 Mon Sep 17 00:00:00 2001 From: Jack Brinkman Date: Wed, 11 Dec 2024 09:06:50 +1000 Subject: [PATCH 18/18] Updated auth header hook to run whenever auth changes --- src/helpers/api/provider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/api/provider.tsx b/src/helpers/api/provider.tsx index f448d85..0a6bc81 100644 --- a/src/helpers/api/provider.tsx +++ b/src/helpers/api/provider.tsx @@ -23,7 +23,7 @@ const APIProvider = (props: PropsWithChildren<{}>): ReactElement => { } else { delete axios.defaults.headers['Authorization']; } - }, [auth.isAuthenticated]); + }, [auth.isAuthenticated, auth.user, auth]); return (