Merge branch 'main' into delete-map-user_type

This commit is contained in:
Ulf Gebhardt 2025-08-14 00:20:28 +01:00 committed by GitHub
commit 0a556fe83c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 124 additions and 11 deletions

View File

@ -1,4 +1,5 @@
VITE_OPEN_COLLECTIVE_API_KEY=your_key
VITE_API_URL=https://api.utopia-lab.org
VITE_API_URL=http://localhost:8055/
#VITE_API_URL=https://api.utopia-lab.org
VITE_VALIDATE_INVITE_FLOW_ID=01d61db0-25aa-4bfa-bc24-c6a8f208a455
VITE_REDEEM_INVITE_FLOW_ID=cc80ec73-ecf5-4789-bee5-1127fb1a6ed4

1
app/.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules/
dist/
.DS_Store
.env

View File

@ -113,7 +113,7 @@ function App() {
path: '/' + l.name, // url
icon: (
<SVG
src={'https://api.utopia-lab.org/assets/' + l.indexIcon}
src={config.apiUrl + 'assets/' + l.indexIcon}
className='tw:w-6 tw:h-6'
preProcessor={(code: string) =>
code.replace(/stroke=".*?"/g, 'stroke="currentColor"')
@ -134,7 +134,7 @@ function App() {
link.rel = 'icon'
document.getElementsByTagName('head')[0].appendChild(link)
}
link.href = map?.logo && 'https://api.utopia-lab.org/assets/' + map.logo // Specify the path to your favicon
link.href = map?.logo && config.apiUrl + 'assets/' + map.logo // Specify the path to your favicon
}
setLoading(false)
@ -148,7 +148,7 @@ function App() {
<div className='App tw:overflow-x-hidden'>
<AuthProvider userApi={userApi} inviteApi={inviteApi}>
<AppShell
assetsApi={new assetsApi('https://api.utopia-lab.org/assets/')}
assetsApi={new assetsApi(config.apiUrl + 'assets/')}
appName={map.name}
embedded={embedded}
openCollectiveApiKey={config.openCollectiveApiKey}

View File

@ -6,6 +6,8 @@
import { useEffect, useState } from 'react'
import { TextView } from 'utopia-ui'
import { config } from './config'
interface ChapterProps {
clickAction1: () => void
map?: any
@ -31,7 +33,7 @@ export function Welcome1({ clickAction1, map }: ChapterProps) {
<h3 className='tw:font-bold tw:text-lg'>Welcome to {map?.name || 'Utopia Map'}</h3>
<img
className='tw:float-right tw:w-32 tw:m-2'
src={'https://api.utopia-lab.org/assets/' + map.logo}
src={config.apiUrl + 'assets/' + map.logo}
></img>
<p className='tw:py-3'>
It is a tool for collaborative mapping to connect local initiatives, people and events.

View File

@ -4,6 +4,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { createDirectus, rest, authentication } from '@directus/sdk'
// eslint-disable-next-line import/no-relative-parent-imports
import { config } from '../config'
import type { AuthenticationData, AuthenticationStorage } from '@directus/sdk'
import type { Point } from 'geojson'
import type { Item } from 'utopia-ui'
@ -94,7 +97,7 @@ export async function getRefreshToken() {
return auth!.refresh_token
}
export const directusClient = createDirectus<MyCollections>('https://api.utopia-lab.org/')
export const directusClient = createDirectus<MyCollections>(config.apiUrl)
.with(rest())
.with(
authentication('json', {

View File

@ -1,5 +1,5 @@
export const config = {
apiUrl: String(import.meta.env.VITE_API_URL ?? 'https://api.utopia-lab.org'),
apiUrl: String(import.meta.env.VITE_API_URL ?? 'http://localhost:8055/'),
validateInviteFlowId: String(
import.meta.env.VITE_VALIDATE_INVITE_FLOW_ID ?? '01d61db0-25aa-4bfa-bc24-c6a8f208a455',
),

View File

@ -12,6 +12,7 @@ import { useNavigate } from 'react-router-dom'
import { MapOverlayPage } from 'utopia-ui'
import { itemsApi } from '../api/itemsApi'
import { config } from '../config'
export const Landingpage = () => {
const [isLandingpageVisible, setIsLandingpageVisible] = useState(true)
@ -137,7 +138,7 @@ export const Landingpage = () => {
<li key={idx}>
<div className='w-24 h-24 mx-auto'>
<img
src={`https://api.utopia-lab.org/assets/${item.image}`}
src={`${config.apiUrl}assets/${item.image}`}
className='w-full h-full rounded-full'
alt=''
/>

View File

@ -23,6 +23,7 @@ import {
} from 'utopia-ui'
import { itemsApi } from '../api/itemsApi'
import { config } from '../config'
import type { Place } from '../api/directus'
import type { LayerProps } from 'utopia-ui'
@ -94,7 +95,7 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) {
id={layer.id}
key={layer.id}
name={layer.name}
menuIcon={'https://api.utopia-lab.org/assets/' + layer.menuIcon}
menuIcon={config.apiUrl + 'assets/' + layer.menuIcon}
menuText={layer.menuText}
menuColor={layer.menuColor}
markerIcon={layer.markerIcon}

View File

@ -1,5 +1,12 @@
# Utopia Backend
To run the backend you can simply execute
`docker-compose up`
## Pull Data from Docker to Harddrive
In order to pull data from your locally running backend (see [docker-compose](../app/docker-compose.yml)) to your local harddrive, you can run the following command
```
npx directus-sync pull \
--directus-url http://localhost:8055 \
@ -7,6 +14,7 @@ npx directus-sync pull \
--directus-password admin123
```
## Push Data from Harddrive to Docker
To push local changes or to seed directus use the following command
```
npx directus-sync push \
@ -15,6 +23,24 @@ npx directus-sync push \
--directus-password admin123
```
## Seed Data for local development
Seed the development data via:
```
npx directus-sync seed push \
--directus-url http://localhost:8055 \
--directus-email admin@it4c.dev \
--directus-password admin123
```
## Seed Data - find differences
In order so see what changes would appear when seeding, you can execute:
```
npx directus-sync seed diff \
--directus-url http://localhost:8055 \
--directus-email admin@it4c.dev \
--directus-password admin123
```
## Backup Database
Either keep a copy of the `/data/database` folder or run the following command to get an sql dump
@ -22,6 +48,66 @@ Either keep a copy of the `/data/database` folder or run the following command t
docker exec -t utopia-map-database-1 pg_dumpall -c -U directus > dump.sql
```
## How to apply a database dump to the docker
Assuming you run docker-compose with the default postgress credentials and have the dump in cwd as ./dump.sql, execute:
Find current schema name:
```
echo "SELECT CURRENT_SCHEMA, CURRENT_SCHEMA();" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus"
```
> current_schema | current_schema
> ----------------+----------------
> public | public
> (1 row)
Drop schemata (loses all data):
```
echo "DROP SCHEMA public CASCADE;" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus"
echo "DROP SCHEMA tiger CASCADE;" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus"
echo "DROP SCHEMA tiger_data CASCADE;" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus"
echo "DROP SCHEMA topology CASCADE;" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus"
```
> drop cascades to table ...
> ...
> DROP SCHEMA
Create the public schema again:
```
echo "CREATE SCHEMA public;" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus"
```
Verify schemata:
```
echo "select schema_name from information_schema.schemata;" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus"
```
Verify database is empty:
```
echo "\dt" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus directus"
```
> Did not find any relations.
Create admin role & grant it:
```
echo "CREATE ROLE admin;" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus directus"
```
Apply dump:
```
docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql -v ON_ERROR_STOP=1 --username directus directus" < ./dump.sql
```
> Bring time depending on the dump size.
Reassign ownership of tables:
```
echo "REASSIGN OWNED BY admin TO directus" | docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql --username directus directus
```
> REASSIGN OWNED
## Access Data on local drive
In order to access the postgress data mounted to the local drive at `/data/database` you need to make it accessible (assuming you are not root):
@ -29,4 +115,4 @@ In order to access the postgress data mounted to the local drive at `/data/datab
sudo chmod 777 -R ./data/
```
This process is to be repeated whenever you restart the database docker container
This process is to be repeated whenever you restart the database docker container

View File

@ -0,0 +1,18 @@
{
"collection": "maps",
"meta": {
"insert_order": 1,
"create": true,
"update": true,
"delete": true,
"preserve_ids": false,
"ignore_on_update": []
},
"data": [
{
"_sync_id": "local-development",
"name": "Local Development",
"url": "http://local.development"
}
]
}

View File

@ -50,7 +50,7 @@ services:
SECRET: 'SECRET'
CORS_ENABLED: 'true'
CORS_ORIGIN: 'http://localhost:8080'
CORS_ORIGIN: 'array:http://localhost:8080,http://localhost:5174'
DB_CLIENT: 'pg'
DB_HOST: 'database'