From e1e54eded18d79f0a82825c532a0728039cbf9ae Mon Sep 17 00:00:00 2001 From: cproudlock Date: Tue, 18 Nov 2025 08:59:42 -0500 Subject: [PATCH] Apply 30-minute fade timer to all notification types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extended the shopfloor-dashboard's 30-minute fade/removal logic from incidents-only to ALL notification types (Changes, Awareness, TBD). Changes to api_shopfloor.asp: - Removed typecolor='danger' restriction from is_current and is_resolved - Now shows all completed notifications for 30 minutes regardless of type - All notification types fade progressively over 30 minutes after completion Changes to displaynotifications.asp: - Added TIMESTAMPDIFF to calculate minutes_since_end - Added is_complete flag for completed notifications - Filter query to only show active OR recently completed (within 30 minutes) - Progressive opacity fade: 100% → 50% over 30 minutes - Changed status badge to "Complete" (info) for completed items - Automatically hides notifications 30 minutes after endtime Behavior: - Notification is marked complete (endtime passed) - Shows at 100% opacity initially - Fades to 50% opacity over next 30 minutes - Automatically removed from display after 30 minutes - Works for ALL types: Incident, Change, Awareness, TBD 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- api_shopfloor.asp | 6 +++--- displaynotifications.asp | 30 +++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/api_shopfloor.asp b/api_shopfloor.asp index 6d508a9..82fded6 100644 --- a/api_shopfloor.asp +++ b/api_shopfloor.asp @@ -17,11 +17,11 @@ strSQL = "SELECT n.notificationid, n.notification, n.starttime, n.endtime, " & _ "nt.typename, nt.typecolor, bu.businessunit, " & _ "CASE " & _ " WHEN n.starttime <= NOW() AND (n.endtime IS NULL OR n.endtime >= NOW()) THEN 1 " & _ - " WHEN nt.typecolor = 'danger' AND n.endtime IS NOT NULL AND n.endtime < NOW() AND DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW() THEN 1 " & _ + " WHEN n.endtime IS NOT NULL AND n.endtime < NOW() AND DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW() THEN 1 " & _ " ELSE 0 " & _ "END as is_current, " & _ "CASE " & _ - " WHEN nt.typecolor = 'danger' AND n.endtime IS NOT NULL AND n.endtime < NOW() THEN 1 " & _ + " WHEN n.endtime IS NOT NULL AND n.endtime < NOW() THEN 1 " & _ " ELSE 0 " & _ "END as is_resolved, " & _ "CASE " & _ @@ -34,7 +34,7 @@ strSQL = "SELECT n.notificationid, n.notification, n.starttime, n.endtime, " & _ "LEFT JOIN businessunits bu ON n.businessunitid = bu.businessunitid " & _ "WHERE n.isshopfloor = 1 AND (" & _ " n.isactive = 1 OR " & _ - " (n.isactive = 0 AND nt.typecolor = 'danger' AND n.endtime IS NOT NULL AND " & _ + " (n.isactive = 0 AND n.endtime IS NOT NULL AND " & _ " DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW())" & _ ")" diff --git a/displaynotifications.asp b/displaynotifications.asp index ac7e888..7ef8af9 100644 --- a/displaynotifications.asp +++ b/displaynotifications.asp @@ -65,10 +65,18 @@ <% Dim strSQL, rs - strSQL = "SELECT n.*, nt.typename, nt.typecolor, bu.businessunit " & _ + strSQL = "SELECT n.*, nt.typename, nt.typecolor, bu.businessunit, " & _ + "TIMESTAMPDIFF(MINUTE, n.endtime, NOW()) as minutes_since_end, " & _ + "CASE " & _ + " WHEN n.endtime IS NOT NULL AND n.endtime < NOW() THEN 1 " & _ + " ELSE 0 " & _ + "END as is_complete " & _ "FROM notifications n " & _ "LEFT JOIN notificationtypes nt ON n.notificationtypeid = nt.notificationtypeid " & _ "LEFT JOIN businessunits bu ON n.businessunitid = bu.businessunitid " & _ + "WHERE n.isactive = 1 OR " & _ + " (n.isactive = 0 AND n.endtime IS NOT NULL AND " & _ + " DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW()) " & _ "ORDER BY n.notificationid DESC" Set rs = objconn.Execute(strSQL) @@ -76,7 +84,7 @@ Response.Write("No notifications found.") Else Do While Not rs.EOF - Dim statusText, statusClass, typeText, typeColor + Dim statusText, statusClass, typeText, typeColor, rowOpacity, rowStyle If CBool(rs("isactive")) = True Then statusText = "Active" statusClass = "success" @@ -85,6 +93,20 @@ statusClass = "secondary" End If + ' Calculate opacity for completed notifications (fade over 30 minutes) + rowOpacity = 1.0 + If rs("is_complete") = 1 And Not IsNull(rs("minutes_since_end")) Then + ' Fade from 1.0 to 0.5 over 30 minutes + Dim minutesSinceEnd + minutesSinceEnd = CDbl(rs("minutes_since_end")) + If minutesSinceEnd >= 0 Then + rowOpacity = 1.0 - (minutesSinceEnd / 30) * 0.5 + If rowOpacity < 0.5 Then rowOpacity = 0.5 + End If + statusText = "Complete" + statusClass = "info" + End If + ' Get notification type info If IsNull(rs("typename")) Or rs("typename") = "" Then typeText = "TBD" @@ -102,7 +124,9 @@ businessUnitText = Server.HTMLEncode(rs("businessunit")) End If - Response.Write("") + ' Apply opacity style + rowStyle = "opacity: " & rowOpacity & ";" + Response.Write("") Response.Write("" & Server.HTMLEncode(rs("notification") & "") & "") Response.Write("" & typeText & "") Response.Write("" & businessUnitText & "")