Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8e17182
Rename FDM to MINAS2
SvenVw Mar 12, 2025
05bc116
Add titles and descriptions to pages
SvenVw Mar 12, 2025
199cba4
Add message at signin page that the app is still in development
SvenVw Mar 12, 2025
7240125
Merge branch 'main' into rename-to-minas2
SvenVw Mar 12, 2025
04feb27
Update fdm-app/app/routes/farm.$b_id_farm.field.$b_id.soil.tsx
SvenVw Mar 12, 2025
2be80c9
Nitpicks
SvenVw Mar 12, 2025
c1d4ee1
Merge pull request #102 from SvenVw/development
SvenVw Mar 13, 2025
b1d1696
Merge branch 'main' into rename-to-minas2
SvenVw Mar 21, 2025
f16f3a7
Setup a first configuration file
SvenVw Mar 21, 2025
7f914f8
Use name from config file
SvenVw Mar 24, 2025
9e18bf4
Standardize use of of paths
SvenVw Mar 24, 2025
3fbd91e
Enable split between client and server config
SvenVw Apr 3, 2025
07a63ce
Update importing the config for meta
SvenVw Apr 3, 2025
2b3e550
Use config for Senty
SvenVw Apr 3, 2025
58822a2
Use config for db connection
SvenVw Apr 3, 2025
18f4436
Convert mapbox into an integration
SvenVw Apr 3, 2025
f3e8615
Add integration with NMI API
SvenVw Apr 3, 2025
28ec588
Merge branch 'development' into rename-to-minas2
SvenVw Apr 3, 2025
b02af68
Various merge fixes
SvenVw Apr 3, 2025
e4baba5
Format the code
SvenVw Apr 3, 2025
823da91
js file does not support loading config yet
SvenVw Apr 3, 2025
fde253e
Fix loading config at build
SvenVw Apr 3, 2025
a298559
Fix loading environmentals
SvenVw Apr 3, 2025
189672a
Fix merge issue at signin
SvenVw Apr 3, 2025
1025f3f
Remove not needed import
SvenVw Apr 3, 2025
80c09af
Various fixes
SvenVw Apr 3, 2025
962f0bf
Improve config for logo
SvenVw Apr 4, 2025
fab4b6d
Fix config
SvenVw Apr 4, 2025
a45ef0c
Fix sidebar
SvenVw Apr 4, 2025
f7f4b9e
Enable posthog only when config for posthog is provided
SvenVw Apr 4, 2025
993f420
Make Sentry optional
SvenVw Apr 4, 2025
c01d00d
Improve documentation about the configuation
SvenVw Apr 4, 2025
e2483da
Use name defined in config
SvenVw Apr 4, 2025
00d472f
Fix merged files
SvenVw Apr 4, 2025
f4d59a8
Update changeset
SvenVw Apr 4, 2025
7594b4a
Fix type
SvenVw Apr 4, 2025
c3bf855
Nitpicks
SvenVw Apr 4, 2025
a60bc50
Typo
SvenVw Apr 4, 2025
ac88db4
Format the code
SvenVw Apr 4, 2025
6389c77
Merge branch 'development' into rename-to-minas2
SvenVw Apr 7, 2025
3418b7a
Merge branch 'development' into rename-to-minas2
SvenVw Apr 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/all-schools-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": minor
---

Add titles and descriptions to pages
5 changes: 5 additions & 0 deletions .changeset/fluffy-hotels-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": minor
---

Add a message at signin page that the app is still in development
5 changes: 5 additions & 0 deletions .changeset/warm-dryers-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@svenvw/fdm-app": minor
---

Make fdm-app configurable for various settings, including the name
123 changes: 64 additions & 59 deletions fdm-app/.env.example
Original file line number Diff line number Diff line change
@@ -1,85 +1,90 @@
# NodeJS Configuration
# Sets the environment for the application (development, production).
# Example: development, production
# -------------------------------------
# General Application Configuration
# -------------------------------------
# Sets the environment (development, production). Affects logging, error handling, etc.
# Required: Yes
NODE_ENV=

# Secret key used to sign session cookies.
# Must be a strong, randomly generated string. Do not hardcode or commit this value to version control. Use a secure secret management system.
# Rotate this key periodically. Compromising this secret can allow attackers to hijack user sessions.
FDM_SESSION_SECRET=
# Public name of the application displayed in the UI.
# Required: Yes
VITE_FDM_NAME=

# DB configuration
# The hostname or IP address of the PostgreSQL database server.
POSTGRES_HOST=
# Port the application server will listen on.
# Required: Yes (Defaults may exist in deployment environment)
PORT=

# The port number on which the PostgreSQL database server is listening. Defaults to 5432 if not specified.
POSTGRES_PORT=
# -------------------------------------
# Session Management
# -------------------------------------
# Secret key used to sign session cookies. MUST be a strong, random string.
# Keep this secret and rotate periodically.
# Required: Yes
FDM_SESSION_SECRET=

# The name of the PostgreSQL database to connect to.
# -------------------------------------
# Database Configuration (PostgreSQL)
# -------------------------------------
# Required: Yes
POSTGRES_HOST=
POSTGRES_PORT=5432 # Default PostgreSQL port
POSTGRES_DB=

# The username used to authenticate with the PostgreSQL database server.
POSTGRES_USER=

# The password used to authenticate with the PostgreSQL database server. Ensure this is stored securely and not exposed in version control.
POSTGRES_PASSWORD=

# Mapbox configuration
# API token for Mapbox services. Required to use Mapbox features.
# Obtain your token from the Mapbox website. Keep this token secure and do not expose it in version control.
MAPBOX_TOKEN=

# Authentication configuration
# Secret key used BY better-auth
# -------------------------------------
# Authentication (Better Auth & OAuth Providers)
# -------------------------------------
# Secret key used BY the better-auth library.
# Required: Yes
BETTER_AUTH_SECRET=

# URL of application used by better-auth
# Full base URL of this application (used for redirects by better-auth).
# Example: http://localhost:5173 or https://yourdomain.com
# Required: Yes
BETTER_AUTH_URL=

# Google OAuth Credentials (Optional: Leave empty to disable Google Sign-In)
# Required: No
GOOGLE_CLIENT_ID=

GOOGLE_CLIENT_SECRET=

# Microsoft OAuth2 client ID obtained from Azure Portal
# Microsoft OAuth Credentials (Optional: Leave empty to disable Microsoft Sign-In)
# Required: No
MS_CLIENT_ID=

# Microsoft OAuth2 client secret obtained from Azure Portal. Keep this secure and never commit to version control.
MS_CLIENT_SECRET=

# URL of .fgb file that contains the fields available to be selected
AVAILABLE_FIELDS_URL=
# -------------------------------------
# Map & Data Configuration
# -------------------------------------
# Mapbox API token for displaying maps.
# Required: Yes (for map functionality)
MAPBOX_TOKEN=

# URL to the FlatGeobuf (.fgb) file containing selectable field geometries.
# Required: Yes (for field selection functionality)
AVAILABLE_FIELDS_URL=

# Sentry configuration
# Sentry organization
# -------------------------------------
# Analytics & Error Tracking (Optional)
# -------------------------------------
# To enable Sentry error tracking and performance monitoring, fill in ALL VITE_SENTRY_* variables below.
# Leave them empty to disable Sentry integration.
# Required: No
VITE_SENTRY_ORG=

# Sentry project
VITE_SENTRY_PROJECT=

# Sentry DSN
VITE_SENTRY_DSN=

# Sentry auth token
VITE_SENTRY_TRACE_SAMPLE_RATE=1.0 # Sample rate for performance monitoring (0.0 to 1.0)
VITE_SENTRY_REPLAY_SAMPLE_RATE=0.1 # Sample rate for session replay (0.0 to 1.0)
VITE_SENTRY_REPLAY_SAMPLE_RATE_ON_ERROR=1.0 # Sample rate for session replay when errors occur (0.0 to 1.0)
VITE_SENTRY_PROFILE_SAMPLE_RATE=1.0 # Sample rate for profiling (0.0 to 1.0)
VITE_SENTRY_SECURITY_REPORT_URI= # Used for CSP reporting

# Sentry Auth Token (Required ONLY for uploading source maps during build, not for runtime)
# Required: No (for runtime)
SENTRY_AUTH_TOKEN=

# Sentry trace sample rate
VITE_SENTRY_TRACE_SAMPLE_RATE=

# Sentry replay sample rate
VITE_SENTRY_REPLAY_SAMPLE_RATE=

# Sentry replay sample rate on error
VITE_SENTRY_REPLAY_SAMPLE_RATE_ON_ERROR=

# Sentry profile sample rate
VITE_SENTRY_PROFILE_SAMPLE_RATE=

# Sentry security report URI for CSP reporting
VITE_SENTRY_SECURITY_REPORT_URI=

# Posthog configuration
# Posthog public key
VITE_PUBLIC_POSTHOG_KEY=
# Posthog host
VITE_PUBLIC_POSTHOG_HOST=
# To enable PostHog product analytics, fill in BOTH variables below.
# Leave them empty to disable PostHog integration.
# Required: No
VITE_PUBLIC_POSTHOG_KEY= # Example: phc_...
VITE_PUBLIC_POSTHOG_HOST= # Example: https://eu.i.posthog.com
20 changes: 18 additions & 2 deletions fdm-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,25 @@ The `fdm-app` is a React application providing a user-friendly interface for vis
pnpm add @svenvw/fdm-app
```

3. **Configuration:** Set the required environment variables, including the database URL, API keys, and other relevant settings. Create a `.env` file in the root directory of your application and copy the values from the `.env.example` file.
3. **Configuration:**
Configure the application by setting environment variables. Create a `.env` file in the `fdm-app` directory by copying the provided `.env.example` file:

4. **Running the App:**
```bash
cp .env.example .env
```

Edit the `.env` file and provide values for the necessary variables. Key configuration areas include:
* **General:** Application name (`VITE_FDM_NAME`), environment (`NODE_ENV`).
* **Session:** A strong secret key (`FDM_SESSION_SECRET`).
* **Database:** Connection details for your PostgreSQL database.
* **Authentication:** Secrets and URLs for `better-auth` and optionally OAuth providers (Google, Microsoft).
* **Mapbox:** API token for map rendering (`MAPBOX_TOKEN`).
* **Data URLs:** Paths to external data files (`AVAILABLE_FIELDS_URL`).
* **Analytics (Optional):** Configuration for Sentry and/or PostHog. These services are disabled by default. To enable them, provide the relevant keys/DSNs as described in `.env.example`.

Refer to the comments within the `.env.example` file for detailed explanations of each variable and whether it's required. **Never commit your `.env` file to version control.**

4. **Running the App:**
```bash
# Development mode
pnpm dev
Expand Down
9 changes: 4 additions & 5 deletions fdm-app/app/components/blocks/farm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@ import { zodResolver } from "@hookform/resolvers/zod"
import { Form } from "react-router"
import { RemixFormProvider, useRemixForm } from "remix-hook-form"
import type { z } from "zod"

import { Button } from "@/components/ui/button"
import { Button } from "~/components/ui/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
} from "~/components/ui/card"
import {
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form"
import { Input } from "@/components/ui/input"
} from "~/components/ui/form"
import { Input } from "~/components/ui/input"
import { LoadingSpinner } from "../custom/loadingspinner"

export interface fertilizersListType {
Expand Down
26 changes: 12 additions & 14 deletions fdm-app/app/components/blocks/fields.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
import { useToast } from "@/hooks/use-toast"
import type { FeatureCollection } from "geojson"
import { Check, ChevronsUpDown } from "lucide-react"
import { useEffect, useState } from "react"
import { Form, useNavigation } from "react-router"

import { FieldMap } from "@/components/blocks/field-map"
// Components
import { Button } from "@/components/ui/button"
import { ClientOnly } from "remix-utils/client-only"
import { FieldMap } from "~/components/blocks/field-map"
import { Button } from "~/components/ui/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
} from "~/components/ui/card"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
} from "~/components/ui/command"
import { Input } from "~/components/ui/input"
import { Label } from "~/components/ui/label"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
} from "~/components/ui/popover"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { useToast } from "@/hooks/use-toast"
import { cn } from "@/lib/utils"
import { Check, ChevronsUpDown } from "lucide-react"
import { ClientOnly } from "remix-utils/client-only"
} from "~/components/ui/select"
import { cn } from "~/lib/utils"
import { Skeleton } from "../ui/skeleton"

interface CultivationOption {
Expand Down
24 changes: 12 additions & 12 deletions fdm-app/app/components/custom/atlas/atlas-panels.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { LoadingSpinner } from "@/components/custom/loadingspinner"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
import type { FeatureCollection } from "geojson"
import throttle from "lodash.throttle"
import { Check, Info } from "lucide-react"
import { useEffect, useState } from "react"
import { useMap } from "react-map-gl"
import type { MapBoxZoomEvent, MapEvent, MapMouseEvent } from "react-map-gl"
import { data, useFetcher } from "react-router"
import { LoadingSpinner } from "~/components/custom/loadingspinner"
import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert"
import { Button } from "~/components/ui/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import { cn } from "@/lib/utils"
import type { FeatureCollection } from "geojson"
import throttle from "lodash.throttle"
import { Check, Info } from "lucide-react"
import { useEffect, useState } from "react"
import { useMap } from "react-map-gl"
import type { MapBoxZoomEvent, MapEvent, MapMouseEvent } from "react-map-gl"
import { useFetcher } from "react-router"
} from "~/components/ui/card"
import { cn } from "~/lib/utils"

export function FieldsPanelHover({
zoomLevelFields,
Expand Down
4 changes: 2 additions & 2 deletions fdm-app/app/components/custom/atlas/atlas-sources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import throttle from "lodash.throttle"
import { type Dispatch, type SetStateAction, useEffect, useState } from "react"
import { Source, useMap } from "react-map-gl"
import { generateFeatureClass } from "./atlas-functions"
import type { fieldsAvailableUrlType } from "./atlas.d"
import type { FieldsAvailableUrlType } from "./atlas.d"

export function FieldsSourceNotClickable({
id,
Expand Down Expand Up @@ -108,7 +108,7 @@ export function FieldsSourceAvailable({
children,
}: {
id: string
url: fieldsAvailableUrlType
url: FieldsAvailableUrlType
zoomLevelFields: number
children: JSX.Element
}) {
Expand Down
2 changes: 1 addition & 1 deletion fdm-app/app/components/custom/atlas/atlas.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface MapFieldsProps {
mapboxToken: string
mapStyle: "mapbox://styles/mapbox/satellite-streets-v12"
fieldsSelected: FeatureCollection | null
fieldsAvailableUrl: fieldsAvailableUrlType
fieldsAvailableUrl: FieldsAvailableUrlType
fieldsSaved: FeatureCollection | null
}

Expand Down
14 changes: 8 additions & 6 deletions fdm-app/app/components/custom/banner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Button } from "@/components/ui/button"
import { Cookie, CookieIcon, X } from "lucide-react"
import { Cookie, X } from "lucide-react"
import posthog from "posthog-js"
import { useEffect, useState } from "react"
import { Button } from "~/components/ui/button"
import { clientConfig } from "~/lib/config"

type ConsentType = "yes" | "no" | "undecided"

Expand Down Expand Up @@ -36,7 +37,8 @@ export function Banner() {
}, [])

useEffect(() => {
if (consentGiven !== "undecided") {
// Set PostHog persistence based on consent, if PostHog is configured
if (clientConfig.analytics.posthog && consentGiven !== "undecided") {
try {
posthog.set_config({
persistence:
Expand Down Expand Up @@ -116,7 +118,7 @@ export function Banner() {
<div className="grid gap-2">
<div className="border-b border-border h-14 flex items-center justify-between p-4">
<h1 className="text-lg font-medium">
Cookies op FDM
{`Cookies op ${clientConfig.name}`}
</h1>
<div className="flex gap-2">
<Cookie className="h-[1.2rem] w-[1.2rem]" />
Expand All @@ -132,9 +134,9 @@ export function Banner() {
</div>
<div className="p-4">
<p className="text-sm font-normal text-start">
Wij gebruiken cookies enkel om FDM te
{`Wij gebruiken cookies enkel om ${clientConfig.name} te
verbeteren, zodat we weten wat er goed en
fout gaat.
fout gaat.`}
<br />
Geen zorgen, we gebruiken ze niet voor
advertenties en ook niet om je online te
Expand Down
Loading