mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 01:57:41 +02:00
Minor bugfixes in queueing module
This commit is contained in:
@@ -47,6 +47,7 @@ import { Card, CardContent } from '../components/Card';
|
||||
import { Button } from '../components/Button';
|
||||
import { ConfirmModal } from '../components/ConfirmModal';
|
||||
import { EditQueueItemModal } from '../components/EditQueueItemModal';
|
||||
import { AddToQueueModal } from '../components/AddToQueueModal';
|
||||
import { useToast } from '../contexts/ToastContext';
|
||||
|
||||
function formatDuration(seconds: number | null | undefined): string {
|
||||
@@ -310,6 +311,7 @@ export function QueuePage() {
|
||||
const [filterStatus, setFilterStatus] = useState<string>('');
|
||||
const [showClearHistoryConfirm, setShowClearHistoryConfirm] = useState(false);
|
||||
const [editItem, setEditItem] = useState<PrintQueueItem | null>(null);
|
||||
const [requeueItem, setRequeueItem] = useState<PrintQueueItem | null>(null);
|
||||
const [confirmAction, setConfirmAction] = useState<{
|
||||
type: 'cancel' | 'remove' | 'stop';
|
||||
item: PrintQueueItem;
|
||||
@@ -399,28 +401,6 @@ export function QueuePage() {
|
||||
onError: () => showToast('Failed to reorder queue', 'error'),
|
||||
});
|
||||
|
||||
const requeueMutation = useMutation({
|
||||
mutationFn: (item: PrintQueueItem) => {
|
||||
// Schedule far in future so it doesn't start immediately
|
||||
const futureDate = new Date();
|
||||
futureDate.setFullYear(futureDate.getFullYear() + 1);
|
||||
return api.addToQueue({
|
||||
printer_id: item.printer_id,
|
||||
archive_id: item.archive_id,
|
||||
scheduled_time: futureDate.toISOString(),
|
||||
require_previous_success: false,
|
||||
auto_off_after: false,
|
||||
});
|
||||
},
|
||||
onSuccess: (newItem) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['queue'] });
|
||||
showToast('Added back to queue - please set schedule');
|
||||
// Open edit modal for the new item
|
||||
setEditItem(newItem);
|
||||
},
|
||||
onError: (error: Error) => showToast(error.message || 'Failed to re-queue item', 'error'),
|
||||
});
|
||||
|
||||
const clearHistoryMutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
const historyItems = queue?.filter(i =>
|
||||
@@ -759,7 +739,7 @@ export function QueuePage() {
|
||||
onCancel={() => {}}
|
||||
onRemove={() => setConfirmAction({ type: 'remove', item })}
|
||||
onStop={() => {}}
|
||||
onRequeue={() => requeueMutation.mutate(item)}
|
||||
onRequeue={() => setRequeueItem(item)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -776,6 +756,15 @@ export function QueuePage() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Re-queue Modal */}
|
||||
{requeueItem && (
|
||||
<AddToQueueModal
|
||||
archiveId={requeueItem.archive_id}
|
||||
archiveName={requeueItem.archive_name || `Archive #${requeueItem.archive_id}`}
|
||||
onClose={() => setRequeueItem(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Confirm Action Modal */}
|
||||
{confirmAction && (
|
||||
<ConfirmModal
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -23,7 +23,7 @@
|
||||
|
||||
<!-- Splash screens for iOS -->
|
||||
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
|
||||
<script type="module" crossorigin src="/assets/index-CYUCozUo.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DCANm19J.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DUGbV7GF.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user