diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f3d4c3655..38b03fcbd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Version History =============== +v6.7.0 +------ + +* Add a button to log alarms from the AlarmsList and AlarmsTable components. ``_ + v6.6.0 ------ diff --git a/love/src/Utils.js b/love/src/Utils.js index d20b3a822..990e4dff8 100644 --- a/love/src/Utils.js +++ b/love/src/Utils.js @@ -1272,12 +1272,14 @@ export const getNotificationMessage = (salCommand) => { cmd_unacknowledge: 'unacknowledged', cmd_mute: 'muted', cmd_unmute: 'unmuted', + cmd_makeLogEntry: 'logged', }; const watcherErrorCmds = { cmd_acknowledge: 'acknowledging', cmd_mute: 'muting', cmd_unmute: 'unmuting', + cmd_makeLogEntry: 'logging', }; if (salCommand.status === 'REQUESTED') { @@ -1285,6 +1287,7 @@ export const getNotificationMessage = (salCommand) => { } if (component === 'Watcher') { + console.log(salCommand); const alarm = salCommand.params.name; if (result === 'Done') { return [`Alarm '${alarm}' ${watcherSuccessfulCmds[cmd]} successfully`, result]; diff --git a/love/src/components/Layout/Layout.container.jsx b/love/src/components/Layout/Layout.container.jsx index c02346177..9c603a91c 100644 --- a/love/src/components/Layout/Layout.container.jsx +++ b/love/src/components/Layout/Layout.container.jsx @@ -40,6 +40,7 @@ import { getControlLocation, } from '../../redux/selectors'; import { logout, receiveConfig, requireSwapToken, cancelSwapToken } from '../../redux/actions/auth'; +import { logAlarm, ackAlarm } from '../../redux/actions/alarms'; import { addGroup, removeGroup, requestSALCommand, resetSubscriptions } from '../../redux/actions/ws'; import { fetchControlLocationLoopStart, fetchControlLocationLoopStop } from '../../redux/actions/observatoryState'; import { clearViewToEdit } from '../../redux/actions/uif'; @@ -119,19 +120,9 @@ const mapDispatchToProps = (dispatch) => { subscriptions.forEach((stream) => dispatch(removeGroup(stream))); }, ackAlarm: (name, severity, acknowledgedBy) => { - return dispatch( - requestSALCommand({ - cmd: 'cmd_acknowledge', - component: 'Watcher', - salindex: 0, - params: { - name, - severity, - acknowledgedBy, - }, - }), - ); + dispatch(ackAlarm(name, severity, acknowledgedBy)); }, + logAlarm: (name) => dispatch(logAlarm(name)), requireUserSwap: (bool) => { if (bool) dispatch(requireSwapToken); else dispatch(cancelSwapToken); diff --git a/love/src/components/Layout/Layout.jsx b/love/src/components/Layout/Layout.jsx index fcbb594bc..2b1290821 100644 --- a/love/src/components/Layout/Layout.jsx +++ b/love/src/components/Layout/Layout.jsx @@ -583,6 +583,7 @@ class Layout extends Component { diff --git a/love/src/components/OLE/NonExposure/NonExposure.jsx b/love/src/components/OLE/NonExposure/NonExposure.jsx index 64ec2c036..9c5d2ea73 100644 --- a/love/src/components/OLE/NonExposure/NonExposure.jsx +++ b/love/src/components/OLE/NonExposure/NonExposure.jsx @@ -332,7 +332,7 @@ export default class NonExposure extends Component { const csvData = data.map((row) => { const obsDay = getObsDayFromDate(moment(row.date_added + 'Z')); const escapedMessageText = row.message_text.replace(/"/g, '""'); - const parsedLevel = OLE_COMMENT_TYPE_OPTIONS.find((option) => option.value === row.level).label; + const parsedLevel = OLE_COMMENT_TYPE_OPTIONS.find((option) => option.value === row.level)?.label ?? 'Undefined'; return { ...row, obs_day: obsDay, diff --git a/love/src/components/Watcher/AlarmsList/AlarmsList.jsx b/love/src/components/Watcher/AlarmsList/AlarmsList.jsx index 231a64c68..a490fb056 100644 --- a/love/src/components/Watcher/AlarmsList/AlarmsList.jsx +++ b/love/src/components/Watcher/AlarmsList/AlarmsList.jsx @@ -32,9 +32,11 @@ AlarmList.propTypes = { alarms: PropTypes.array, /** Function to dispatch an alarm acknowledgement */ ackAlarm: PropTypes.func, + /** Function to dispatch an alarm logging */ + logAlarm: PropTypes.func, }; -export default function AlarmList({ alarms, taiToUtc, ackAlarm, user }) { +export default function AlarmList({ alarms, taiToUtc, ackAlarm, logAlarm, user }) { return (
{alarms.length < 1 ? ( @@ -57,6 +59,7 @@ export default function AlarmList({ alarms, taiToUtc, ackAlarm, user }) { severityUpdateTimestamp, reason: alarm.reason?.value, ackAlarm: ackAlarm, + logAlarm: logAlarm, }; return ; diff --git a/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.jsx b/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.jsx index a4cd378a8..f656f4aba 100644 --- a/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.jsx +++ b/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.jsx @@ -33,6 +33,7 @@ export default function CompactAlarm({ reason, severityUpdateTimestamp, ackAlarm, + logAlarm, }) { const severityStatus = severityToStatus[severity]; const maxSeverityStatus = severityToStatus[maxSeverity]; @@ -88,6 +89,18 @@ export default function CompactAlarm({ > ACK +
diff --git a/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.module.css b/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.module.css index 3bc4d0687..f2bea0fa6 100644 --- a/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.module.css +++ b/love/src/components/Watcher/AlarmsList/CompactAlarm/CompactAlarm.module.css @@ -106,6 +106,7 @@ this program. If not, see . .ackButtonContainer { display: flex; + gap: 0.5em; justify-content: center; padding-top: 0.5em; } diff --git a/love/src/components/Watcher/AlarmsTable/AlarmsTable.jsx b/love/src/components/Watcher/AlarmsTable/AlarmsTable.jsx index a2d69cc1a..d4300099a 100644 --- a/love/src/components/Watcher/AlarmsTable/AlarmsTable.jsx +++ b/love/src/components/Watcher/AlarmsTable/AlarmsTable.jsx @@ -247,7 +247,8 @@ export default class AlarmsTable extends PureComponent { return ( <> - + + this.clickGearIcon(key)} > - + +
+ +
+ + {!isAcknowledged(row) ? (
diff --git a/love/src/redux/actions/alarms.js b/love/src/redux/actions/alarms.js index 7182f12c6..bceb7da85 100644 --- a/love/src/redux/actions/alarms.js +++ b/love/src/redux/actions/alarms.js @@ -18,6 +18,7 @@ this program. If not, see . */ import { RECEIVE_ALARM, RECEIVE_ALL_ALARMS } from './actionTypes'; +import { requestSALCommand } from './ws'; export const receiveAlarm = (alarm) => { return { @@ -32,3 +33,35 @@ export const receiveAllAlarms = (alarmsStream) => { alarmsStream, }; }; + +export const ackAlarm = (name, severity, acknowledgedBy) => { + return (dispatch) => { + dispatch( + requestSALCommand({ + cmd: 'cmd_acknowledge', + component: 'Watcher', + salindex: 0, + params: { + name, + severity, + acknowledgedBy, + }, + }), + ); + }; +}; + +export const logAlarm = (name) => { + return (dispatch) => { + dispatch( + requestSALCommand({ + cmd: 'cmd_makeLogEntry', + component: 'Watcher', + salindex: 0, + params: { + name, + }, + }), + ); + }; +};