mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-20 13:51:45 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 09ab829b17 | |||
| 66a057a070 | |||
| f2ffea5ba4 | |||
| b0dee4dafb |
@@ -161,6 +161,7 @@ services:
|
|||||||
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
||||||
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
||||||
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
||||||
|
# - MCP_MAX_SESSION_PER_USER=5 # Max concurrent MCP sessions per user (default: 5)
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
- ./uploads:/app/uploads
|
- ./uploads:/app/uploads
|
||||||
@@ -303,6 +304,7 @@ trek.yourdomain.com {
|
|||||||
| **Other** | | |
|
| **Other** | | |
|
||||||
| `DEMO_MODE` | Enable demo mode (hourly data resets) | `false` |
|
| `DEMO_MODE` | Enable demo mode (hourly data resets) | `false` |
|
||||||
| `MCP_RATE_LIMIT` | Max MCP API requests per user per minute | `60` |
|
| `MCP_RATE_LIMIT` | Max MCP API requests per user per minute | `60` |
|
||||||
|
| `MCP_MAX_SESSION_PER_USER` | Max concurrent MCP sessions per user | `5` |
|
||||||
|
|
||||||
## Optional API Keys
|
## Optional API Keys
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ env:
|
|||||||
# Enable demo mode (hourly data resets).
|
# Enable demo mode (hourly data resets).
|
||||||
# MCP_RATE_LIMIT: "60"
|
# MCP_RATE_LIMIT: "60"
|
||||||
# Max MCP API requests per user per minute. Defaults to 60.
|
# Max MCP API requests per user per minute. Defaults to 60.
|
||||||
|
# MCP_MAX_SESSION_PER_USER: "5"
|
||||||
|
# Max concurrent MCP sessions per user. Defaults to 5.
|
||||||
|
|
||||||
|
|
||||||
# Secret environment variables stored in a Kubernetes Secret.
|
# Secret environment variables stored in a Kubernetes Secret.
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.7",
|
"version": "2.9.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.7",
|
"version": "2.9.9",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-pdf/renderer": "^4.3.2",
|
"@react-pdf/renderer": "^4.3.2",
|
||||||
"axios": "^1.6.7",
|
"axios": "^1.6.7",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.7",
|
"version": "2.9.9",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { useToast } from '../shared/Toast'
|
|||||||
import { useTranslation } from '../../i18n'
|
import { useTranslation } from '../../i18n'
|
||||||
import { CustomDatePicker } from '../shared/CustomDateTimePicker'
|
import { CustomDatePicker } from '../shared/CustomDateTimePicker'
|
||||||
import CustomTimePicker from '../shared/CustomTimePicker'
|
import CustomTimePicker from '../shared/CustomTimePicker'
|
||||||
|
import { getAuthUrl } from '../../api/authUrl'
|
||||||
import type { Day, Place, Reservation, TripFile, AssignmentsMap, Accommodation } from '../../types'
|
import type { Day, Place, Reservation, TripFile, AssignmentsMap, Accommodation } from '../../types'
|
||||||
|
|
||||||
const TYPE_OPTIONS = [
|
const TYPE_OPTIONS = [
|
||||||
@@ -113,6 +114,9 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
|
|||||||
if (rawEnd.includes('T')) {
|
if (rawEnd.includes('T')) {
|
||||||
endDate = rawEnd.split('T')[0]
|
endDate = rawEnd.split('T')[0]
|
||||||
endTime = rawEnd.split('T')[1]?.slice(0, 5) || ''
|
endTime = rawEnd.split('T')[1]?.slice(0, 5) || ''
|
||||||
|
} else if (/^\d{4}-\d{2}-\d{2}$/.test(rawEnd)) {
|
||||||
|
endDate = rawEnd
|
||||||
|
endTime = ''
|
||||||
}
|
}
|
||||||
setForm({
|
setForm({
|
||||||
title: reservation.title || '',
|
title: reservation.title || '',
|
||||||
@@ -166,6 +170,22 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
|
|||||||
const startDate = form.reservation_time.split('T')[0]
|
const startDate = form.reservation_time.split('T')[0]
|
||||||
const startTime = form.reservation_time.split('T')[1] || '00:00'
|
const startTime = form.reservation_time.split('T')[1] || '00:00'
|
||||||
const endTime = form.reservation_end_time || '00:00'
|
const endTime = form.reservation_end_time || '00:00'
|
||||||
|
// For flights, compare in UTC using timezone offsets
|
||||||
|
if (form.type === 'flight') {
|
||||||
|
const parseOffset = (tz: string): number | null => {
|
||||||
|
if (!tz) return null
|
||||||
|
const m = tz.trim().match(/^(?:UTC|GMT)?\s*([+-])(\d{1,2})(?::(\d{2}))?$/i)
|
||||||
|
if (!m) return null
|
||||||
|
const sign = m[1] === '+' ? 1 : -1
|
||||||
|
return sign * (parseInt(m[2]) * 60 + parseInt(m[3] || '0'))
|
||||||
|
}
|
||||||
|
const depOffset = parseOffset(form.meta_departure_timezone)
|
||||||
|
const arrOffset = parseOffset(form.meta_arrival_timezone)
|
||||||
|
if (depOffset === null || arrOffset === null) return false
|
||||||
|
const depMinutes = new Date(`${startDate}T${startTime}`).getTime() - depOffset * 60000
|
||||||
|
const arrMinutes = new Date(`${form.end_date}T${endTime}`).getTime() - arrOffset * 60000
|
||||||
|
return arrMinutes <= depMinutes
|
||||||
|
}
|
||||||
const startFull = `${startDate}T${startTime}`
|
const startFull = `${startDate}T${startTime}`
|
||||||
const endFull = `${form.end_date}T${endTime}`
|
const endFull = `${form.end_date}T${endTime}`
|
||||||
return endFull <= startFull
|
return endFull <= startFull
|
||||||
@@ -204,7 +224,8 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
|
|||||||
}
|
}
|
||||||
const saveData: Record<string, any> = {
|
const saveData: Record<string, any> = {
|
||||||
title: form.title, type: form.type, status: form.status,
|
title: form.title, type: form.type, status: form.status,
|
||||||
reservation_time: form.reservation_time, reservation_end_time: combinedEndTime,
|
reservation_time: form.type === 'hotel' ? null : form.reservation_time,
|
||||||
|
reservation_end_time: form.type === 'hotel' ? null : combinedEndTime,
|
||||||
location: form.location, confirmation_number: form.confirmation_number,
|
location: form.location, confirmation_number: form.confirmation_number,
|
||||||
notes: form.notes,
|
notes: form.notes,
|
||||||
assignment_id: form.assignment_id || null,
|
assignment_id: form.assignment_id || null,
|
||||||
@@ -565,7 +586,7 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
|
|||||||
<div key={f.id} style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '5px 10px', background: 'var(--bg-secondary)', borderRadius: 8 }}>
|
<div key={f.id} style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '5px 10px', background: 'var(--bg-secondary)', borderRadius: 8 }}>
|
||||||
<FileText size={12} style={{ color: 'var(--text-muted)', flexShrink: 0 }} />
|
<FileText size={12} style={{ color: 'var(--text-muted)', flexShrink: 0 }} />
|
||||||
<span style={{ flex: 1, fontSize: 12, color: 'var(--text-secondary)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{f.original_name}</span>
|
<span style={{ flex: 1, fontSize: 12, color: 'var(--text-secondary)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{f.original_name}</span>
|
||||||
<a href={f.url} target="_blank" rel="noreferrer" style={{ color: 'var(--text-faint)', display: 'flex', flexShrink: 0 }}><ExternalLink size={11} /></a>
|
<a href="#" onClick={async (e) => { e.preventDefault(); const u = await getAuthUrl(f.url, 'download'); window.open(u, '_blank', 'noreferrer') }} style={{ color: 'var(--text-faint)', display: 'flex', flexShrink: 0, cursor: 'pointer' }}><ExternalLink size={11} /></a>
|
||||||
<button type="button" onClick={async () => {
|
<button type="button" onClick={async () => {
|
||||||
// Always unlink, never delete the file
|
// Always unlink, never delete the file
|
||||||
// Clear primary reservation_id if it points to this reservation
|
// Clear primary reservation_id if it points to this reservation
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
Calendar, Hash, CheckCircle2, Circle, Pencil, Trash2, Plus, ChevronDown, ChevronRight, Users,
|
Calendar, Hash, CheckCircle2, Circle, Pencil, Trash2, Plus, ChevronDown, ChevronRight, Users,
|
||||||
ExternalLink, BookMarked, Lightbulb, Link2, Clock,
|
ExternalLink, BookMarked, Lightbulb, Link2, Clock,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
|
import { getAuthUrl } from '../../api/authUrl'
|
||||||
import type { Reservation, Day, TripFile, AssignmentsMap } from '../../types'
|
import type { Reservation, Day, TripFile, AssignmentsMap } from '../../types'
|
||||||
|
|
||||||
interface AssignmentLookupEntry {
|
interface AssignmentLookupEntry {
|
||||||
@@ -138,7 +139,7 @@ function ReservationCard({ r, tripId, onEdit, onDelete, files = [], onNavigateTo
|
|||||||
<div style={{ fontSize: 9, fontWeight: 600, color: 'var(--text-faint)', textTransform: 'uppercase', letterSpacing: '0.03em' }}>{t('reservations.date')}</div>
|
<div style={{ fontSize: 9, fontWeight: 600, color: 'var(--text-faint)', textTransform: 'uppercase', letterSpacing: '0.03em' }}>{t('reservations.date')}</div>
|
||||||
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-primary)', marginTop: 1 }}>
|
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-primary)', marginTop: 1 }}>
|
||||||
{fmtDate(r.reservation_time)}
|
{fmtDate(r.reservation_time)}
|
||||||
{r.reservation_end_time?.includes('T') && r.reservation_end_time.split('T')[0] !== r.reservation_time.split('T')[0] && (
|
{r.reservation_end_time && (r.reservation_end_time.includes('T') ? r.reservation_end_time.split('T')[0] : r.reservation_end_time) !== r.reservation_time.split('T')[0] && (
|
||||||
<> – {fmtDate(r.reservation_end_time)}</>
|
<> – {fmtDate(r.reservation_end_time)}</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -252,7 +253,7 @@ function ReservationCard({ r, tripId, onEdit, onDelete, files = [], onNavigateTo
|
|||||||
<div style={{ fontSize: 9, fontWeight: 600, color: 'var(--text-faint)', textTransform: 'uppercase', letterSpacing: '0.03em', marginBottom: 3 }}>{t('files.title')}</div>
|
<div style={{ fontSize: 9, fontWeight: 600, color: 'var(--text-faint)', textTransform: 'uppercase', letterSpacing: '0.03em', marginBottom: 3 }}>{t('files.title')}</div>
|
||||||
<div style={{ padding: '4px 8px', borderRadius: 7, background: 'var(--bg-secondary)', display: 'flex', flexDirection: 'column', gap: 3 }}>
|
<div style={{ padding: '4px 8px', borderRadius: 7, background: 'var(--bg-secondary)', display: 'flex', flexDirection: 'column', gap: 3 }}>
|
||||||
{attachedFiles.map(f => (
|
{attachedFiles.map(f => (
|
||||||
<a key={f.id} href={f.url} target="_blank" rel="noreferrer" style={{ display: 'flex', alignItems: 'center', gap: 4, textDecoration: 'none', cursor: 'pointer' }}>
|
<a key={f.id} href="#" onClick={async (e) => { e.preventDefault(); const u = await getAuthUrl(f.url, 'download'); window.open(u, '_blank', 'noreferrer') }} style={{ display: 'flex', alignItems: 'center', gap: 4, textDecoration: 'none', cursor: 'pointer' }}>
|
||||||
<FileText size={9} style={{ color: 'var(--text-faint)', flexShrink: 0 }} />
|
<FileText size={9} style={{ color: 'var(--text-faint)', flexShrink: 0 }} />
|
||||||
<span style={{ fontSize: 10, color: 'var(--text-muted)', flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{f.original_name}</span>
|
<span style={{ fontSize: 10, color: 'var(--text-muted)', flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{f.original_name}</span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ services:
|
|||||||
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
||||||
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
||||||
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
||||||
|
# - MCP_MAX_SESSION_PER_USER=5 # Max concurrent MCP sessions per user (default: 5)
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
- ./uploads:/app/uploads
|
- ./uploads:/app/uploads
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ OIDC_SCOPE=openid email profile # Fully overrides the default. Add extra scopes
|
|||||||
DEMO_MODE=false # Demo mode - resets data hourly
|
DEMO_MODE=false # Demo mode - resets data hourly
|
||||||
|
|
||||||
# MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
# MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
||||||
|
# MCP_MAX_SESSION_PER_USER=5 # Max concurrent MCP sessions per user (default: 5)
|
||||||
|
|
||||||
# Initial admin account — only used on first boot when no users exist yet.
|
# Initial admin account — only used on first boot when no users exist yet.
|
||||||
# If both are set the admin account is created with these credentials.
|
# If both are set the admin account is created with these credentials.
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.7",
|
"version": "2.9.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.7",
|
"version": "2.9.9",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.28.0",
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
||||||
"archiver": "^6.0.1",
|
"archiver": "^6.0.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.7",
|
"version": "2.9.9",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --import tsx src/index.ts",
|
"start": "node --import tsx src/index.ts",
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ interface McpSession {
|
|||||||
const sessions = new Map<string, McpSession>();
|
const sessions = new Map<string, McpSession>();
|
||||||
|
|
||||||
const SESSION_TTL_MS = 60 * 60 * 1000; // 1 hour
|
const SESSION_TTL_MS = 60 * 60 * 1000; // 1 hour
|
||||||
const MAX_SESSIONS_PER_USER = 5;
|
const sessionParsed = Number.parseInt(process.env.MCP_MAX_SESSION_PER_USER ?? "");
|
||||||
|
const MAX_SESSIONS_PER_USER = Number.isFinite(sessionParsed) && sessionParsed > 0 ? sessionParsed : 5;
|
||||||
const RATE_LIMIT_WINDOW_MS = 60 * 1000; // 1 minute
|
const RATE_LIMIT_WINDOW_MS = 60 * 1000; // 1 minute
|
||||||
const parsed = Number.parseInt(process.env.MCP_RATE_LIMIT ?? "");
|
const parsed = Number.parseInt(process.env.MCP_RATE_LIMIT ?? "");
|
||||||
const RATE_LIMIT_MAX = Number.isFinite(parsed) && parsed > 0 ? parsed : 60; // requests per minute per user
|
const RATE_LIMIT_MAX = Number.isFinite(parsed) && parsed > 0 ? parsed : 60; // requests per minute per user
|
||||||
|
|||||||
@@ -234,8 +234,8 @@ export function updateReservation(id: string | number, tripId: string | number,
|
|||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
`).run(
|
`).run(
|
||||||
title || null,
|
title || null,
|
||||||
reservation_time !== undefined ? (reservation_time || null) : current.reservation_time,
|
(type ?? current.type) === 'hotel' ? null : (reservation_time !== undefined ? (reservation_time || null) : current.reservation_time),
|
||||||
reservation_end_time !== undefined ? (reservation_end_time || null) : current.reservation_end_time,
|
(type ?? current.type) === 'hotel' ? null : (reservation_end_time !== undefined ? (reservation_end_time || null) : current.reservation_end_time),
|
||||||
location !== undefined ? (location || null) : current.location,
|
location !== undefined ? (location || null) : current.location,
|
||||||
confirmation_number !== undefined ? (confirmation_number || null) : current.confirmation_number,
|
confirmation_number !== undefined ? (confirmation_number || null) : current.confirmation_number,
|
||||||
notes !== undefined ? (notes || null) : current.notes,
|
notes !== undefined ? (notes || null) : current.notes,
|
||||||
|
|||||||
@@ -58,4 +58,5 @@
|
|||||||
<!-- Other -->
|
<!-- Other -->
|
||||||
<Config Name="DEMO_MODE" Target="DEMO_MODE" Default="false" Mode="" Description="Enable demo mode (resets all data hourly). Not intended for regular use." Type="Variable" Display="advanced" Required="false" Mask="false">false</Config>
|
<Config Name="DEMO_MODE" Target="DEMO_MODE" Default="false" Mode="" Description="Enable demo mode (resets all data hourly). Not intended for regular use." Type="Variable" Display="advanced" Required="false" Mask="false">false</Config>
|
||||||
<Config Name="MCP_RATE_LIMIT" Target="MCP_RATE_LIMIT" Default="60" Mode="" Description="Max MCP API requests per user per minute." Type="Variable" Display="advanced" Required="false" Mask="false">60</Config>
|
<Config Name="MCP_RATE_LIMIT" Target="MCP_RATE_LIMIT" Default="60" Mode="" Description="Max MCP API requests per user per minute." Type="Variable" Display="advanced" Required="false" Mask="false">60</Config>
|
||||||
|
<Config Name="MCP_MAX_SESSION_PER_USER" Target="MCP_MAX_SESSION_PER_USER" Default="5" Mode="" Description="Max concurrent MCP sessions per user." Type="Variable" Display="advanced" Required="false" Mask="false">5</Config>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
Reference in New Issue
Block a user