Add Enabled flag to AlarmGroups; filter disabled groups from AlarmOperation#593
Add Enabled flag to AlarmGroups; filter disabled groups from AlarmOperation#593
Conversation
|
@copilot Can you remove the SQL file for migration and add the migration to the PR as a comment? |
Done — the migration file has been removed in commit -- Migration: Add Enabled flag to AlarmGroup
-- Existing rows default to Enabled = 1 (true) to preserve existing behavior.
-- Add Enabled column to AlarmGroup if it does not already exist
IF NOT EXISTS (
SELECT 1
FROM sys.columns
WHERE object_id = OBJECT_ID('AlarmGroup')
AND name = 'Enabled'
)
BEGIN
ALTER TABLE AlarmGroup
ADD Enabled BIT NOT NULL DEFAULT(1)
END
GO
-- Drop and recreate ActiveAlarmView to filter disabled AlarmGroups
IF OBJECT_ID('ActiveAlarmView', 'V') IS NOT NULL
DROP VIEW ActiveAlarmView
GO
CREATE VIEW ActiveAlarmView AS
SELECT
Alarm.ID AS AlarmID,
Alarm.AlarmGroupID AS AlarmGroupID,
AlarmGroup.AlarmTypeID AS AlarmTypeID,
AlarmFactor.ID AS AlarmFactorID,
AlarmFactor.SeverityID,
Alarm.SeriesID AS SeriesID,
AlarmFactor.Factor AS Value
FROM
(
SELECT AF.ID, AF.Factor, AF.AlarmGroupID, AF.SeverityID
FROM AlarmFactor AF
INNER JOIN AlarmGroup AG ON AF.AlarmGroupID = AG.ID AND AG.Enabled = 1
UNION
SELECT
NULL AS ID,
1.0 AS Factor,
AlarmGroup.ID AS AlarmGroupID,
AlarmGroup.SeverityID
FROM AlarmGroup
WHERE AlarmGroup.Enabled = 1
) AlarmFactor LEFT JOIN
Alarm ON AlarmFactor.AlarmGroupID = alarm.AlarmGroupID LEFT JOIN
AlarmGroup ON Alarm.AlarmGroupID = AlarmGroup.ID
GO
-- Drop and recreate AlarmGroupView to include Enabled column
IF OBJECT_ID('AlarmGroupView', 'V') IS NOT NULL
DROP VIEW AlarmGroupView
GO
CREATE VIEW AlarmGroupView AS
SELECT
AlarmGroup.ID,
AlarmGroup.Name,
AlarmSeverity.Name AlarmSeverity,
CountStats.ChannelCount Channels,
CountStats.MeterCount Meters,
LastAlarm.StartTime LastAlarmStart,
LastAlarm.EndTime LastAlarmEnd,
LastAlarm.ChannelName LastChannel,
LastAlarm.MeterName LastMeter,
AlarmType.Description AS AlarmType,
AlarmGroup.Enabled
FROM
AlarmGroup LEFT JOIN
AlarmSeverity ON AlarmGroup.SeverityID = AlarmSeverity.ID LEFT JOIN
AlarmType ON AlarmGroup.AlarmTypeID = AlarmType.ID OUTER APPLY
(
SELECT
COUNT(DISTINCT Channel.ID) ChannelCount,
COUNT(DISTINCT Channel.MeterID) MeterCount
FROM
Channel JOIN
Series ON Series.ChannelID = Channel.ID JOIN
Alarm ON Alarm.SeriesID = Series.ID
WHERE Alarm.AlarmGroupID = AlarmGroup.ID
) CountStats OUTER APPLY
(
SELECT TOP 1
LatestAlarmLog.StartTime,
LatestAlarmLog.EndTime,
Channel.Name ChannelName,
Meter.Name MeterName
FROM
Alarm JOIN
Series ON Alarm.SeriesID = Series.ID JOIN
Channel ON Series.ChannelID = Channel.ID JOIN
Meter ON Channel.MeterID = Meter.ID JOIN
LatestAlarmLog ON LatestAlarmLog.AlarmID = Alarm.ID
WHERE Alarm.AlarmGroupID = AlarmGroup.ID
ORDER BY
LatestAlarmLog.StartTime DESC,
LatestAlarmLog.AlarmLogID DESC
) LastAlarm
GO |
|
@copilot Add a button to the AlarmGroup Wizard when editing alarm Groups to allow the user to skip steps 2 onwards and save the changes directly. It should be |
Done in commit |
Co-authored-by: clackner-gpa <52460212+clackner-gpa@users.noreply.github.com>
…ment Co-authored-by: clackner-gpa <52460212+clackner-gpa@users.noreply.github.com> Agent-Logs-Url: https://github.com/GridProtectionAlliance/openXDA/sessions/00a7e9c8-0c77-45e4-a0a9-4079d3ee589b
…of Next) Co-authored-by: clackner-gpa <52460212+clackner-gpa@users.noreply.github.com> Agent-Logs-Url: https://github.com/GridProtectionAlliance/openXDA/sessions/bad3bfe2-e021-4f1b-a406-78811ea47a03
991c219 to
6f18ee8
Compare
AlarmGroupshad no enable/disable mechanism, soAlarmOperationalways evaluated all alarms regardless of intent. This adds anEnabledflag with defaulttrue(preserving existing behavior) and filters disabled groups out of alarm evaluation at the SQL level.Data Model
Enabled BIT NOT NULL DEFAULT(1)toAlarmGrouptableAlarmGroupandAlarmGroupViewC# models updated with[DefaultValue(true)] public bool Enabled { get; set; }SQL Views
ActiveAlarmView: both UNION branches now exclude disabled groups —AlarmFactorbranch usesINNER JOIN AlarmGroup AG ON ... AND AG.Enabled = 1; synthetic-factor branch usesWHERE AlarmGroup.Enabled = 1. This is whereHIDSAlarmOperationqueries, so no C# changes are needed.AlarmGroupView: exposesEnabledcolumn for UI consumption( SELECT AF.ID, AF.Factor, AF.AlarmGroupID, AF.SeverityID FROM AlarmFactor AF INNER JOIN AlarmGroup AG ON AF.AlarmGroupID = AG.ID AND AG.Enabled = 1 UNION SELECT NULL, 1.0, AlarmGroup.ID, AlarmGroup.SeverityID FROM AlarmGroup WHERE AlarmGroup.Enabled = 1 ) AlarmFactor LEFT JOIN ...Migration
The migration SQL for existing databases is provided as a PR comment. It performs an idempotent
ALTER TABLE(column add guarded byIF NOT EXISTS), followed by drop/recreate of both views — safe to run against existing databases.API / TypeScript
IAlarmGroupandIAlarmGroupViewinterfaces gainEnabled: booleanEnabled: truein Redux reset actionUI (SPCTools)
GeneralSettings.tsx:CheckBoxforEnabledin the wizard's general settings stepAlarmGroup.tsx: Status column (Enabled/Disabled badge) in the list view;Enabledadded as a searchable fieldWizardHome.tsx: "Save" button (btn-success) added to the left of the "Continue" button when editing an existing alarm group (steps 1–3 only); allows saving changes directly without completing the remaining wizard steps. The button is disabled with a validation tooltip when the current step has unmet required fields.Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.