rename production environments

This commit is contained in:
NlightN22 2024-03-03 15:36:01 +07:00
parent ea0c039e93
commit 6847493fbf
7 changed files with 29 additions and 45 deletions

View File

@ -1,5 +1,3 @@
REACT_APP_HOST=localhost
REACT_APP_PORT=5173
REACT_APP_FRIGATE_PROXY=http://localhost:4000
REACT_APP_OPENID_SERVER=https://your.server.com:443/realms/your-realm
REACT_APP_CLIENT_ID=frontend-client
FRIGATE_PROXY=http://localhost:4000
OPENID_SERVER=https://your.server.com:443/realms/your-realm
CLIENT_ID=frontend-client

View File

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
# Build commands:
# - rm build -r -Force ; yarn build
# - $VERSION=0.2
# - $VERSION=0.4
# - rm build -r -Force ; rm ./node_modules/.cache/babel-loader -r -Force ; yarn build
# - docker build --pull --rm -t oncharterliz/multi-frigate:latest -t oncharterliz/multi-frigate:$VERSION "."
# - docker image push --all-tags oncharterliz/multi-frigate

View File

@ -8,11 +8,9 @@ services:
front:
image: oncharterliz/multi-frigate:latest
environment:
REACT_APP_HOST: localhost
REACT_APP_PORT: 5173
REACT_APP_FRIGATE_PROXY: http://localhost:4000
REACT_APP_OPENID_SERVER: https://server:port/realms/your-realm
REACT_APP_CLIENT_ID: frontend-client
FRIGATE_PROXY: http://localhost:4000
OPENID_SERVER: https://server:port/realms/your-realm
CLIENT_ID: frontend-client
ports:
- 80:80 # set your port here
```

View File

@ -4,10 +4,8 @@ services:
front:
image: oncharterliz/multi-frigate:latest
environment:
REACT_APP_HOST: localhost
REACT_APP_PORT: 5173
REACT_APP_FRIGATE_PROXY: http://localhost:4000
REACT_APP_OPENID_SERVER: https://server:port/realms/your-realm
REACT_APP_CLIENT_ID: frontend-client
FRIGATE_PROXY: http://localhost:4000
OPENID_SERVER: https://server:port/realms/your-realm
CLIENT_ID: frontend-client
ports:
- 80:80 # set your port here

View File

@ -20,7 +20,7 @@ const queryClient = new QueryClient({
})
function App() {
const maxErrorAuthConts = 2
const maxErrorAuthCounts = 2
const systemColorScheme = useColorScheme()
const [colorScheme, setColorScheme] = useState<ColorScheme>(getCookie('mantine-color-scheme') as ColorScheme || systemColorScheme)
const [authErrorCounter, setAuthErrorCounter] = useState(0)
@ -35,33 +35,33 @@ function App() {
// automatically sign-in
useEffect(() => {
if (!hasAuthParams() &&
!auth.isAuthenticated && !auth.activeNavigator && !auth.isLoading && authErrorCounter < maxErrorAuthConts) {
console.log('Not authenticated! Redirect! ErrorCounter', authErrorCounter)
!auth.isAuthenticated && !auth.activeNavigator && !auth.isLoading && authErrorCounter < maxErrorAuthCounts) {
console.error('Not authenticated! Redirect! ErrorCounter', authErrorCounter)
setAuthErrorCounter(prevCount => prevCount + 1)
auth.signinRedirect()
}
}, [auth, auth.isAuthenticated, auth.activeNavigator, auth.isLoading, auth.signinRedirect])
}, [auth, auth.isAuthenticated, auth.activeNavigator, auth.isLoading, auth.signinRedirect, authErrorCounter])
if (auth.activeNavigator || auth.isLoading) {
return <CenterLoader />
}
if (authErrorCounter > maxErrorAuthConts) {
console.log('maxErrorAuthConts authority', keycloakConfig.authority)
console.log('maxErrorAuthConts client_id', keycloakConfig.client_id)
console.log('maxErrorAuthConts redirect_uri', keycloakConfig.redirect_uri)
if (authErrorCounter > maxErrorAuthCounts) {
console.error('maxErrorAuthCounts authority', keycloakConfig.authority)
console.error('maxErrorAuthCounts client_id', keycloakConfig.client_id)
console.error('maxErrorAuthCounts redirect_uri', keycloakConfig.redirect_uri)
return <RetryErrorPage backVisible={false} mainVisible={false} onRetry={() => auth.signinRedirect()} />
}
if (!auth.isAuthenticated && !auth.isLoading && authErrorCounter < maxErrorAuthConts) {
if (!auth.isAuthenticated && !auth.isLoading && authErrorCounter < maxErrorAuthCounts) {
if (hasAuthParams()) {
console.log('auth.isAuthenticated', auth.isAuthenticated)
console.log('auth.isLoading', auth.isLoading)
console.warn('Not authenticated, isAuthenticated:', auth.isAuthenticated)
console.warn('Not authenticated, isLoading:', auth.isLoading)
return <RetryErrorPage backVisible={false} mainVisible={false} onRetry={() => auth.signinRedirect()} />
} else {
console.log('Not authenticated! Redirect! auth ErrorCounter', authErrorCounter)
console.error('Not authenticated! Redirect! Error Counter:', authErrorCounter)
setAuthErrorCounter(prevCount => prevCount + 1);
auth.signinRedirect()
}
@ -89,13 +89,6 @@ function App() {
radius: "xl",
}
},
// Image: {
// styles: (theme) => ({
// placeholder: {
// backgroundColor: 'transparent',
// }
// })
// },
}
}}
>

View File

@ -2,17 +2,16 @@ import { z } from "zod"
export const appMode = process.env.NODE_ENV
export const isProduction = appMode === "production"
export const host = isProduction ? window.env?.REACT_APP_HOST : process.env.HOST
export const port = isProduction ? window.env?.REACT_APP_PORT : process.env.PORT
const proxy = isProduction ? window.env?.REACT_APP_FRIGATE_PROXY : process.env.REACT_APP_FRIGATE_PROXY
const proxy = isProduction ? window.env?.FRIGATE_PROXY : process.env.REACT_APP_FRIGATE_PROXY
const proxyParsed = z.string().url().safeParse(proxy)
if (!proxyParsed.success) throw Error(`FRIGATE_PROXY must be string and URL. FRIGATE_PROXY:${proxy}`)
export const proxyURL = new URL(proxy || '')
const oidpServer = isProduction ? window.env?.REACT_APP_OPENID_SERVER : process.env.REACT_APP_OPENID_SERVER
const oidpServer = isProduction ? window.env?.OPENID_SERVER : process.env.REACT_APP_OPENID_SERVER
const oidpServerParsed= z.string().url().safeParse(oidpServer)
if (!oidpServerParsed.success) throw Error('REACT_APP_OPENID_SERVER must be string and URL')
const oidpClientId = isProduction ? window.env?.REACT_APP_CLIENT_ID : process.env.REACT_APP_CLIENT_ID
if (!oidpServerParsed.success) throw Error(`OPENID_SERVER must be string and URL. OPENID_SERVER:${oidpServer}`)
const oidpClientId = isProduction ? window.env?.CLIENT_ID : process.env.REACT_APP_CLIENT_ID
export const oidpSettings = {
server: oidpServer || '',
clientId: oidpClientId || '',

View File

@ -24,8 +24,6 @@ const FrigateHostsTable = ({ data, showAddButton = false, saveCallback, changedC
const [reversed, setReversed] = useState(false)
const [sortedName, setSortedName] = useState<string | null>(null)
console.log('data', data)
console.log('tableData', tableData)
useEffect(() => {
setTableData(data);