Download frontend/src/components/workflow/ClassifyStep.jsx from Basel0/qshub: direct link, hf CLI and curl.
- Browser
- Download file 7.18 kB
-
https://huggingface.co/spaces/Basel0/qshub/resolve/452be5aadce06410a94de4c8d4c0205d10a0217d/frontend/src/components/workflow/ClassifyStep.jsx
- Command line
-
hf download hf://spaces/Basel0/qshub@452be5aadce06410a94de4c8d4c0205d10a0217d/frontend/src/components/workflow/ClassifyStep.jsx
-
curl -L -o ClassifyStep.jsx https://huggingface.co/spaces/Basel0/qshub/resolve/452be5aadce06410a94de4c8d4c0205d10a0217d/frontend/src/components/workflow/ClassifyStep.jsx
7.18 kB
| import React from 'react'; | |
| import { ZoomIn, ZoomOut } from 'lucide-react'; | |
| export default function ClassifyStep({ | |
| classifiedPages, | |
| setClassifiedPages, | |
| selectedPageIndex, | |
| setSelectedPageIndex, | |
| zoom, | |
| setZoom, | |
| isArabic, | |
| handleSaveClassifications, | |
| loading | |
| }) { | |
| return ( | |
| <div style={{ display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: '25px', height: 'calc(100vh - 160px)' }}> | |
| {/* Left Page Image Viewer */} | |
| <div className="glass-panel" style={{ display: 'flex', flexDirection: 'column', overflow: 'hidden' }}> | |
| <div style={{ padding: '12px 18px', borderBottom: '1px solid var(--border-color)', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> | |
| <span style={{ fontWeight: 700 }}> | |
| {isArabic ? 'معاينة المخطط' : 'Drawing Preview'} (Page {selectedPageIndex + 1}) | |
| </span> | |
| <div style={{ display: 'flex', gap: '8px' }}> | |
| <button className="btn btn-secondary" onClick={() => setZoom(prev => Math.max(0.5, prev - 0.2))} style={{ padding: '6px' }}><ZoomOut size={16} /></button> | |
| <button className="btn btn-secondary" onClick={() => setZoom(prev => Math.min(3, prev + 0.2))} style={{ padding: '6px' }}><ZoomIn size={16} /></button> | |
| </div> | |
| </div> | |
| <div style={{ flex: 1, overflow: 'auto', backgroundColor: '#334155', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '15px' }}> | |
| {classifiedPages[selectedPageIndex] && ( | |
| <img | |
| src={`${classifiedPages[selectedPageIndex].image_url}`} | |
| alt="Page preview" | |
| style={{ transform: `scale(${zoom})`, transformOrigin: 'center center', maxWidth: '100%', height: 'auto', transition: 'transform 0.1s ease', borderRadius: '4px' }} | |
| /> | |
| )} | |
| </div> | |
| </div> | |
| {/* Right Classify Options */} | |
| <div className="glass-panel" style={{ padding: '25px', display: 'flex', flexDirection: 'column', overflowY: 'auto' }}> | |
| <h3 style={{ fontSize: '1.2rem', fontWeight: 800, marginBottom: '5px' }}> | |
| {isArabic ? '2. نتائج التصنيف التلقائي للصفحات' : '2. Page Classification Results'} | |
| </h3> | |
| <p style={{ color: 'var(--text-secondary)', fontSize: '0.85rem', marginBottom: '20px' }}> | |
| {isArabic | |
| ? 'يرجى مراجعة وتأكيد تصنيف الصفحات. اختر الصفحة لمشاهدة المخطط على اليسار وتعديل نوعه.' | |
| : 'Review classifications. Select a page, review its image on the left, and adjust the category if needed.'} | |
| </p> | |
| <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: '12px', marginBottom: '20px' }}> | |
| {classifiedPages.map((page, idx) => ( | |
| <div | |
| key={idx} | |
| onClick={() => setSelectedPageIndex(idx)} | |
| style={{ | |
| display: 'flex', | |
| alignItems: 'center', | |
| justifyContent: 'space-between', | |
| padding: '10px 14px', | |
| borderRadius: '8px', | |
| border: '1px solid var(--border-color)', | |
| backgroundColor: idx === selectedPageIndex ? 'var(--primary-glow)' : 'var(--bg-secondary)', | |
| cursor: 'pointer' | |
| }} | |
| > | |
| <div> | |
| <span style={{ fontWeight: 700, fontSize: '0.88rem' }}> | |
| {page.pdf === 'structural' ? (isArabic ? 'إنشائي' : 'Structural') : (isArabic ? 'معماري' : 'Architectural')} P{page.page_num} | |
| </span> | |
| </div> | |
| <select | |
| className="form-input" | |
| value={page.detected_type} | |
| onChange={(e) => { | |
| const updated = [...classifiedPages]; | |
| updated[idx].detected_type = e.target.value; | |
| setClassifiedPages(updated); | |
| }} | |
| style={{ width: '160px', padding: '6px 10px', fontSize: '0.85rem' }} | |
| > | |
| <option value="unknown">{isArabic ? 'غير مصنف' : 'Unknown'}</option> | |
| <option value="foundations">{isArabic ? 'جدول القواعد (Foundations)' : 'Foundations Schedule'}</option> | |
| <option value="tie_beam">{isArabic ? 'مخطط الميدة (Tie Beams)' : 'Tie Beams Layout'}</option> | |
| <option value="upper_columns">{isArabic ? 'جدول الأعمدة (Columns Schedule)' : 'Columns Schedule'}</option> | |
| <option value="neck_columns">{isArabic ? 'أعمدة الأرضي/الرقبة (Neck Columns)' : 'Neck Columns'}</option> | |
| <option value="columns_1f">{isArabic ? 'أعمدة الأول (1st Floor Columns)' : '1st Floor Columns'}</option> | |
| <option value="columns_2f">{isArabic ? 'أعمدة الثاني (2nd Floor Columns)' : '2nd Floor Columns'}</option> | |
| <option value="columns_roof">{isArabic ? 'أعمدة السطح (Roof Columns)' : 'Roof Columns'}</option> | |
| <option value="slab_1st">{isArabic ? 'سقف الأول (1st Floor Slab)' : '1st Floor Slab'}</option> | |
| <option value="slab_2nd">{isArabic ? 'سقف الثاني (2nd Floor Slab)' : '2nd Floor Slab'}</option> | |
| <option value="roof_slab">{isArabic ? 'سقف السطح (Roof Slab)' : 'Roof Slab'}</option> | |
| <option value="setting_out">{isArabic ? 'مخطط الموقع/الموقع العام (Setting Out)' : 'Setting Out / Plot Plan'}</option> | |
| <option value="ground_floor_plan">{isArabic ? 'مخطط الأرضي (Ground Floor Plan)' : 'Ground Floor Plan'}</option> | |
| <option value="first_floor_plan">{isArabic ? 'مخطط الأول (1st Floor Plan)' : '1st Floor Plan'}</option> | |
| <option value="second_floor_plan">{isArabic ? 'مخطط الثاني (2nd Floor Plan)' : '2nd Floor Plan'}</option> | |
| <option value="roof_floor_plan">{isArabic ? 'مخطط السطح (Roof Floor Plan)' : 'Roof Floor Plan'}</option> | |
| <option value="elevations">{isArabic ? 'الواجهات (Elevations)' : 'Elevations'}</option> | |
| <option value="schedules">{isArabic ? 'جداول الفتحات والأبواب (Schedules)' : 'Schedules (Doors/Windows)'}</option> | |
| </select> | |
| </div> | |
| ))} | |
| </div> | |
| <button className="btn btn-primary" onClick={handleSaveClassifications} style={{ width: '100%' }} disabled={loading}> | |
| {loading ? ( | |
| <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '8px' }}> | |
| <div className="spin-anim" style={{ width: '16px', height: '16px', border: '2px solid white', borderTopColor: 'transparent', borderRadius: '50%' }}></div> | |
| <span>{isArabic ? 'جاري الحفظ...' : 'Saving & Proceeding...'}</span> | |
| </div> | |
| ) : ( | |
| isArabic ? 'حفظ وتأكيد التصنيفات' : 'Save & Proceed to Extraction' | |
| )} | |
| </button> | |
| </div> | |
| </div> | |
| ); | |
| } | |