Dashboard cards: rebuild deployable dists

This commit is contained in:
2026-08-11 14:31:24 -04:00
parent 0ed8be75d9
commit 3b37603691
14 changed files with 507 additions and 62 deletions

View File

@@ -871,3 +871,36 @@ def get_shopfloor_notifications():
'upcoming': upcoming_data,
'configversion': _config_version(),
})
@notifications_bp.route('/dashboard/active', methods=['GET'])
@jwt_required()
def dashboard_active():
"""Notifications currently showing on the floor.
The items, not a count. "4 active notifications" tells an admin nothing;
knowing WHICH message the shop is looking at right now is the point,
particularly when one is stale and nobody has taken it down.
A null start or end means open-ended, matching how the boards read them.
"""
now = datetime.now(timezone.utc).replace(tzinfo=None)
rows = (Notification.query
.filter(db.or_(Notification.starttime.is_(None),
Notification.starttime <= now),
db.or_(Notification.endtime.is_(None),
Notification.endtime >= now))
.order_by(Notification.starttime.desc())
.limit(25).all())
out = []
for row in rows:
notificationtype = getattr(row, 'notificationtype', None)
out.append({
'notificationid': row.notificationid,
'message': (row.notification or '').strip()[:120],
'typename': notificationtype.typename if notificationtype else None,
'endtime': row.endtime.isoformat() + 'Z' if row.endtime else None,
})
return success_response(out)