Skip to content

Commit

Permalink
dangerous config option
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Jan 13, 2023
1 parent a519ab4 commit f1c4f81
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default function App() {
if (res.tile_server) {
setStatic('tileServer', res.tile_server)
}
setStatic('dangerous', res.dangerous || false)
} else {
router.navigate('/login')
}
Expand Down
1 change: 1 addition & 0 deletions client/src/assets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface Config {
tile_server: string
scanner_type: string
logged_in: boolean
dangerous: boolean
}

export interface Circle {
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/dialogs/Manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { Button, Dialog, DialogActions, DialogContent } from '@mui/material'
import type { Feature, FeatureCollection } from 'geojson'
import useDeepCompareEffect from 'use-deep-compare-effect'

import { useStatic } from '@hooks/useStatic'
import { save } from '@services/fetches'

import DialogHeader from './Header'
import { Code } from '../Code'

Expand Down Expand Up @@ -73,7 +75,7 @@ export default function Manager({ open, setOpen, geojson }: Props) {
Save to Koji
</Button>
<Button
disabled
disabled={!useStatic.getState().dangerous}
onClick={() =>
save('/api/v1/geofence/save-scanner', code).then((res) =>
console.log(res),
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/drawer/routing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function EditTab() {
buttons={['cluster', 'route', 'bootstrap']}
/>
</ListItem>
<Toggle field="save_to_db" disabled />
<Toggle field="save_to_db" disabled={!useStatic.getState().dangerous} />
<ListItemButton
color="primary"
disabled={Object.values(layerEditing).some((v) => v)}
Expand Down
2 changes: 2 additions & 0 deletions client/src/hooks/useStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface UseStatic {
kojiRoutes: { name: string; id: number; type: string }[]
scannerRoutes: { name: string; id: number; type: string }[]
scannerType: string
dangerous: boolean
tileServer: string
geojson: FeatureCollection
layerEditing: {
Expand Down Expand Up @@ -70,6 +71,7 @@ export const useStatic = create<UseStatic>((set, get) => ({
geofences: {},
routes: [],
scannerType: 'rdm',
dangerous: false,
geojson: {
type: 'FeatureCollection',
features: [],
Expand Down
1 change: 1 addition & 0 deletions server/api/src/private/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async fn config(scanner_type: web::Data<String>, session: Session) -> Result<Htt
} else {
false
},
dangerous: std::env::var("DANGEROUS").is_ok(),
}))
}

Expand Down
1 change: 1 addition & 0 deletions server/model/src/api/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ pub struct ConfigResponse {
pub tile_server: String,
pub scanner_type: String,
pub logged_in: bool,
pub dangerous: bool,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down

0 comments on commit f1c4f81

Please sign in to comment.