Browse Source

Minor bugfixes in queueing module

maziggy 8 tháng trước cách đây
mục cha
commit
a322b8fad4
3 tập tin đã thay đổi với 13 bổ sung24 xóa
  1. 12 23
      frontend/src/pages/QueuePage.tsx
  2. 0 0
      static/assets/index-DCANm19J.js
  3. 1 1
      static/index.html

+ 12 - 23
frontend/src/pages/QueuePage.tsx

@@ -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

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
static/assets/index-DCANm19J.js


+ 1 - 1
static/index.html

@@ -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>

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác