Skip to content

Commit

Permalink
Merge pull request #26 from AtlasOfLivingAustralia/feature/config-fix
Browse files Browse the repository at this point in the history
Configuration fixes & tweaks
  • Loading branch information
jack-brinkman authored Dec 6, 2024
2 parents 8ccad29 + 58da263 commit 7d5a935
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 46 deletions.
6 changes: 3 additions & 3 deletions config/.env.development → config/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# 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_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="ala"
# VITE_AUTH_SCOPE="email openid profile ala/attrs ala/roles"
VITE_AUTH_SCOPE="openid profile ala roles"
VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000

# API
Expand Down
2 changes: 1 addition & 1 deletion config/.env.functionaltest
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/.env.production → config/.env.prod
Original file line number Diff line number Diff line change
@@ -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/mobile-app
# 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
10 changes: 5 additions & 5 deletions config/.env.staging
Original file line number Diff line number Diff line change
@@ -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/mobile-app
# VITE_AUTH_END_SESSION_URI=ENTER-HERE
VITE_AUTH_SCOPE="openid profile ala roles"
VITE_AUTH_TOKEN_REFRESH_INTERVAL=300000

# API
Expand Down
14 changes: 14 additions & 0 deletions config/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +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-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/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=10000
VITE_API_BIOCOLLECT=https://biocollect-test.ala.org.au
VITE_API_BIOCOLLECT_HUB=acsa
14 changes: 0 additions & 14 deletions config/.env.testing

This file was deleted.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function Routes() {
},
],
{
basename: '/pwa-mobile',
basename: '/mobile-app',
}
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/api/endpoints/biocollect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const filterActiveSurveys = (surveys: BioCollectSurvey[]) =>
({ startDate, endDate, published }) =>
new Date(startDate).getTime() <= Date.now() &&
(!endDate || new Date(endDate).getTime() >= Date.now()) &&
published
(published !== undefined ? published : true)
) || [];

const formatProjects = (projects: BioCollectProject[]) => {
Expand Down
23 changes: 16 additions & 7 deletions src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
UnstyledButton,
Badge,
Loader,
ThemeIcon,
} from '@mantine/core';
import { Link } from 'react-router-dom';
import { useAuth } from 'react-oidc-context';
Expand All @@ -18,6 +19,8 @@ import {
IconFileUpload,
IconUser,
IconSettings,
IconPlugConnected,
IconPlugConnectedX,
} from '@tabler/icons-react';
import jwtDecode from 'jwt-decode';

Expand Down Expand Up @@ -74,11 +77,17 @@ export default function Header() {
}
/>
</Link>
<Group spacing="xs">
<Badge radius="sm" color={onLine ? 'green' : 'red'}>
{onLine ? 'online' : 'offline'}
</Badge>
</Group>
<ThemeIcon
color={onLine ? 'green' : 'red'}
radius="lg"
variant="light"
>
{onLine ? (
<IconPlugConnected size="1rem" />
) : (
<IconPlugConnectedX size="1rem" />
)}
</ThemeIcon>
</Group>
<Group>
<InstallButton />
Expand All @@ -94,7 +103,7 @@ export default function Header() {
const { user, isAuthenticated } = auth;

if (!isAuthenticated) return <Loader size="sm" />;

// Use the given name from the profile field, otherwise fallback to the JWT
const given_name =
user?.profile.given_name ||
Expand Down Expand Up @@ -159,7 +168,7 @@ export default function Header() {
Help
</Menu.Item>
<Menu.Item
id='signOut'
id="signOut"
onClick={signOut}
icon={<IconLogout />}
disabled={auth.isLoading || !onLine}
Expand Down
2 changes: 1 addition & 1 deletion src/layout/InstallButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function InstallButton() {
)
}
>
{install ? 'Install' : 'Installation Instructions'}
{install ? 'Install' : 'Install Instructions'}
</Button>
<Modal
fullScreen={mobile}
Expand Down
16 changes: 12 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<AuthProvider
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}
{...authConfig}
userStore={userStore}
onSigninCallback={(user) => {
const params = new URLSearchParams(window.location.search);
Expand Down
2 changes: 1 addition & 1 deletion src/views/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const pwaOptions: Partial<VitePWAOptions> = {

// https://vitejs.dev/config/
export default defineConfig({
base: '/pwa-mobile',
base: '/mobile-app',
plugins: [react(), tsconfigPaths(), visualizer() as any, VitePWA(pwaOptions)],
envDir: './config',
});

0 comments on commit 7d5a935

Please sign in to comment.