Add auto-print G-code injection for queue items (#422)

Per-model start/end G-code snippets configurable in Settings (Workflow
  tab). Queue items get "Inject G-code" toggle — scheduler injects
  snippets into a temp 3MF copy before FTP upload. Supports Farmloop,
  SwapMod, AutoClear, Printflow 3D and similar bed-clearing systems.
  Original files are never modified.
This commit is contained in:
maziggy
2026-04-05 11:14:26 +02:00
parent aa9b60a265
commit f006472f79
29 changed files with 778 additions and 182 deletions
@@ -1,6 +1,6 @@
import { useState, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { Calendar, Clock, Hand, Power, Layers } from 'lucide-react';
import { Calendar, Clock, Hand, Power, Layers, Code } from 'lucide-react';
import type { ScheduleOptionsProps, ScheduleType } from './types';
import {
formatDateInput,
@@ -27,6 +27,7 @@ export function ScheduleOptionsPanel({
canControlPrinter = true,
showStagger = false,
printerCount = 0,
hasGcodeSnippets = false,
}: ScheduleOptionsProps) {
const { t } = useTranslation();
const [dateValue, setDateValue] = useState('');
@@ -251,6 +252,23 @@ export function ScheduleOptionsPanel({
</label>
</div>
{/* G-code injection */}
{hasGcodeSnippets && (
<div className="flex items-center gap-2">
<input
type="checkbox"
id="gcodeInjection"
checked={options.gcodeInjection}
onChange={(e) => onChange({ ...options, gcodeInjection: e.target.checked })}
className="rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"
/>
<label htmlFor="gcodeInjection" className="text-sm flex items-center gap-1 text-bambu-gray">
<Code className="w-3.5 h-3.5" />
{t('printModal.gcodeInjection', 'Inject auto-print G-code')}
</label>
</div>
)}
{/* Stagger start */}
{showStagger && options.scheduleType !== 'manual' && (
<div className="space-y-3">