mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-20 22:01:45 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 68a1f9683e | |||
| 5c57116a68 | |||
| 48508b9df4 | |||
| c8250256a7 |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.4",
|
"version": "2.9.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.4",
|
"version": "2.9.6",
|
||||||
"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.4",
|
"version": "2.9.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -341,14 +341,13 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({
|
|||||||
initTransportPositions(dayId)
|
initTransportPositions(dayId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build base list: ALL places (timed and untimed) + notes sorted by order_index/sort_order
|
// All places keep their order_index — untimed can be freely moved, timed auto-sort when time is set
|
||||||
// Places keep their order_index ordering — only transports are inserted based on time.
|
|
||||||
const baseItems = [
|
const baseItems = [
|
||||||
...da.map(a => ({ type: 'place' as const, sortKey: a.order_index, data: a })),
|
...da.map(a => ({ type: 'place' as const, sortKey: a.order_index, data: a })),
|
||||||
...dn.map(n => ({ type: 'note' as const, sortKey: n.sort_order, data: n })),
|
...dn.map(n => ({ type: 'note' as const, sortKey: n.sort_order, data: n })),
|
||||||
].sort((a, b) => a.sortKey - b.sortKey)
|
].sort((a, b) => a.sortKey - b.sortKey)
|
||||||
|
|
||||||
// Only transports are inserted among base items based on time/position
|
// Transports are inserted among places based on time
|
||||||
const timedTransports = transport.map(r => ({
|
const timedTransports = transport.map(r => ({
|
||||||
type: 'transport' as const,
|
type: 'transport' as const,
|
||||||
data: r,
|
data: r,
|
||||||
@@ -360,22 +359,20 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar({
|
|||||||
return timedTransports.map((item, i) => ({ ...item, sortKey: i }))
|
return timedTransports.map((item, i) => ({ ...item, sortKey: i }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert transports among base items using persisted position or time-to-position mapping.
|
// Insert transports among places based on per-day position or time
|
||||||
const result = [...baseItems]
|
const result = [...baseItems]
|
||||||
for (let ti = 0; ti < timedTransports.length; ti++) {
|
for (let ti = 0; ti < timedTransports.length; ti++) {
|
||||||
const timed = timedTransports[ti]
|
const timed = timedTransports[ti]
|
||||||
const minutes = timed.minutes
|
const minutes = timed.minutes
|
||||||
|
|
||||||
// Use per-day position if available, fallback to global position
|
// Use per-day position if explicitly set by user reorder
|
||||||
const dayObj = days.find(d => d.id === dayId)
|
|
||||||
const perDayPos = timed.data.day_positions?.[dayId] ?? timed.data.day_positions?.[String(dayId)]
|
const perDayPos = timed.data.day_positions?.[dayId] ?? timed.data.day_positions?.[String(dayId)]
|
||||||
const effectivePos = perDayPos ?? timed.data.day_plan_position
|
if (perDayPos != null) {
|
||||||
if (effectivePos != null) {
|
result.push({ type: timed.type, sortKey: perDayPos, data: timed.data })
|
||||||
result.push({ type: timed.type, sortKey: effectivePos, data: timed.data })
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find insertion position: after the last base item with time <= this transport's time
|
// Find insertion position: after the last place with time <= this transport's time
|
||||||
let insertAfterKey = -Infinity
|
let insertAfterKey = -Infinity
|
||||||
for (const item of result) {
|
for (const item of result) {
|
||||||
if (item.type === 'place') {
|
if (item.type === 'place') {
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.4",
|
"version": "2.9.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.4",
|
"version": "2.9.6",
|
||||||
"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.4",
|
"version": "2.9.6",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --import tsx src/index.ts",
|
"start": "node --import tsx src/index.ts",
|
||||||
|
|||||||
@@ -168,6 +168,34 @@ export function getParticipants(assignmentId: string | number) {
|
|||||||
export function updateTime(id: string | number, placeTime: string | null, endTime: string | null) {
|
export function updateTime(id: string | number, placeTime: string | null, endTime: string | null) {
|
||||||
db.prepare('UPDATE day_assignments SET assignment_time = ?, assignment_end_time = ? WHERE id = ?')
|
db.prepare('UPDATE day_assignments SET assignment_time = ?, assignment_end_time = ? WHERE id = ?')
|
||||||
.run(placeTime ?? null, endTime ?? null, id);
|
.run(placeTime ?? null, endTime ?? null, id);
|
||||||
|
|
||||||
|
// Auto-sort: reorder timed assignments chronologically within the day
|
||||||
|
if (placeTime) {
|
||||||
|
const assignment = db.prepare('SELECT day_id FROM day_assignments WHERE id = ?').get(id) as { day_id: number } | undefined;
|
||||||
|
if (assignment) {
|
||||||
|
const dayAssignments = db.prepare(`
|
||||||
|
SELECT da.id, COALESCE(da.assignment_time, p.place_time) as effective_time
|
||||||
|
FROM day_assignments da
|
||||||
|
JOIN places p ON da.place_id = p.id
|
||||||
|
WHERE da.day_id = ?
|
||||||
|
ORDER BY da.order_index ASC
|
||||||
|
`).all(assignment.day_id) as { id: number; effective_time: string | null }[];
|
||||||
|
|
||||||
|
// Separate timed and untimed, sort timed by time
|
||||||
|
const timed = dayAssignments.filter(a => a.effective_time).sort((a, b) => {
|
||||||
|
const ta = a.effective_time!.includes(':') ? a.effective_time! : '99:99';
|
||||||
|
const tb = b.effective_time!.includes(':') ? b.effective_time! : '99:99';
|
||||||
|
return ta.localeCompare(tb);
|
||||||
|
});
|
||||||
|
const untimed = dayAssignments.filter(a => !a.effective_time);
|
||||||
|
|
||||||
|
// Interleave: timed in chronological order, untimed keep relative position
|
||||||
|
const reordered = [...timed, ...untimed];
|
||||||
|
const update = db.prepare('UPDATE day_assignments SET order_index = ? WHERE id = ?');
|
||||||
|
reordered.forEach((a, i) => update.run(i, a.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return getAssignmentWithPlace(Number(id));
|
return getAssignmentWithPlace(Number(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,10 @@ export async function pipeAsset(url: string, response: Response, headers?: Recor
|
|||||||
await pipeline(Readable.fromWeb(resp.body as any), response);
|
await pipeline(Readable.fromWeb(resp.body as any), response);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (response.headersSent) return;
|
if (response.headersSent) {
|
||||||
|
response.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (error instanceof SsrfBlockedError) {
|
if (error instanceof SsrfBlockedError) {
|
||||||
response.status(400).json({ error: error.message });
|
response.status(400).json({ error: error.message });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user