A Flask web application for displaying LINEA production records from the MOSYS Pervasive database with real-time search, sorting, and filtering.
- ✅ Date Range Filtering: Preset buttons (7/30/60/90 days) + custom date picker
- ✅ Column Search: Real-time AJAX search on all text columns (500ms debounce)
- ✅ Sortable Columns: Click headers to sort ascending/descending
- ✅ Responsive Design: Columns hide on smaller screens
- ✅ Refined Minimal UI: Elegant design with Inter font and smooth animations
- ✅ SQLAlchemy ORM: Direct database queries (no pandas dependency)
LINEA_60/
├── app/
│ ├── __init__.py # Flask app factory
│ ├── models/
│ │ ├── notcojan.py # NOTCOJAN table model
│ │ └── collaudo.py # COLLAUDO table model
│ ├── routes/
│ │ └── linea.py # LINEA routes + AJAX API
│ ├── templates/
│ │ ├── base.html # Base template
│ │ └── linea/
│ │ └── index.html # Main table view
│ └── static/
│ ├── css/
│ │ └── linea.css # Refined Minimal styles
│ └── js/
│ └── linea.js # AJAX functionality
├── config.py # Configuration
├── run.py # Application entry point
├── requirements.txt # Dependencies
└── docs/
└── plans/
└── 2026-02-10-linea-flask-app-design.md
- Python 3.8+
- ODBC DSN configured:
STAAMP_DB - Pervasive database access
-
Clone or navigate to the project directory:
cd C:\Users\piotrperesiak\PycharmProjects\LINEA_60
-
Create virtual environment:
python -m venv .venv .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment (optional):
copy .env.example .env # Edit .env with your settings -
Verify ODBC DSN connection:
- Ensure
STAAMP_DBDSN is configured in Windows ODBC Data Source Administrator - Test connection to Pervasive database
- Ensure
python run.pyThe application will be available at: http://localhost:5000/linea
set FLASK_CONFIG=production
set SECRET_KEY=your-secure-secret-key
python run.pyNavigate to /linea to see the production records table.
Default behavior:
- Shows last 30 days of records
- Records sorted by date (descending)
Preset buttons:
- Click "7 dni", "30 dni", "60 dni", or "90 dni" for quick date ranges
Custom range:
- Select "Od" (from) date
- Select "Do" (to) date
- Click "Zastosuj" to apply
Type in the search box below any column header to filter records:
- COMM (Commessa): Order number
- NR_NIEZG (Nr NC): Non-conformity number
- TYP_UWAGI (Typ): Note type
- UWAGA: Combined notes (searches NOTE_01 through NOTE_10)
- MASZYNA: Machine/Press
- KOD_DETALU: Article code
- NR_FORMY: Mold number (STAMPO_I + STAMPO_P)
Search is case-insensitive with 500ms debounce for smooth UX.
Click on any column header with a sort icon to toggle:
- First click: Sort ascending
- Second click: Sort descending
Sortable columns:
- COMM, DATA, GODZ, NR_NIEZG, TYP_UWAGI, MASZYNA, KOD_DETALU, NR_FORMY
Primary keys: COMMESSA, DATA, ORA
Fields:
NOTE_01throughNOTE_10: Combined intoUWAGANUMERO_NC: Non-conformity numberTIPO_NOTA: Note type
Properties:
formatted_date: Converts YYYYMMDD → YYYY/MM/DDformatted_time: Converts HHMM → HH:MMcombined_notes: Joins all NOTE fields
Primary key: COMMESSA
Fields:
PRESSA: Machine/PressARTICOLO: Article codeSTAMPO_I,STAMPO_P: Mold parts (combined into NR_FORMY)
Main view with table
Query Parameters:
days: Preset range (7, 30, 60, 90)date_from: Custom start date (YYYY-MM-DD)date_to: Custom end date (YYYY-MM-DD)
AJAX endpoint for filtered records
Query Parameters:
- Date range:
days,date_from,date_to - Search:
search_COMM,search_NR_NIEZG,search_TYP_UWAGI,search_UWAGA,search_MASZYNA,search_KOD_DETALU,search_NR_FORMY - Sort:
sort(field name),dir(asc/desc)
Response:
{
"success": true,
"records": [...],
"total": 42
}All 9 columns visible
Hidden columns:
- GODZ (Time)
- NR_NIEZG (NC Number)
Hidden columns:
- GODZ, NR_NIEZG, TYP_UWAGI, KOD_DETALU
- Backend: Flask 3.x, SQLAlchemy 2.x
- Database: Pervasive SQL (via pyodbc)
- Frontend: Custom CSS (Refined Minimal), Vanilla JavaScript
- Font: Inter (Google Fonts)
Enable SQL query logging in config.py:
SQLALCHEMY_ENGINE_OPTIONS = {
'echo': True # Shows SQL queries in console
}- Models: Add to
app/models/ - Routes: Add to
app/routes/ - Templates: Add to
app/templates/ - Static files: Add to
app/static/
Error: "Can't open connection"
- Verify ODBC DSN
STAAMP_DBis configured - Check Pervasive database is running
- Test connection with ODBC Data Source Administrator
- Check date range (default is last 30 days)
- Verify NOTCOJAN table has recent data
- Check browser console for JavaScript errors
- Enable SQL logging to see queries
- Check JavaScript console for errors
- Verify
/linea/api/searchendpoint is accessible - Clear browser cache and reload
Internal use only - Staamp Production System
For issues or questions, contact the development team.