Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a button to log alarms from the AlarmsList and AlarmsTable components. #684

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Version History
===============

v6.7.0
------

* Add a button to log alarms from the AlarmsList and AlarmsTable components. `<https://github.com/lsst-ts/LOVE-frontend/pull/684>`_

v6.6.0
------

Expand Down
3 changes: 3 additions & 0 deletions love/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1272,19 +1272,22 @@ 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') {
return [`Requesting command ${salCommand.csc}.${salCommand.salindex}.${salCommand.cmd}`];
}

if (component === 'Watcher') {
console.log(salCommand);
const alarm = salCommand.params.name;
if (result === 'Done') {
return [`Alarm '${alarm}' ${watcherSuccessfulCmds[cmd]} successfully`, result];
Expand Down
15 changes: 3 additions & 12 deletions love/src/components/Layout/Layout.container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions love/src/components/Layout/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ class Layout extends Component {
<AlarmsList
alarms={filteredAlarms}
ackAlarm={this.props.ackAlarm}
logAlarm={this.props.logAlarm}
taiToUtc={this.props.taiToUtc}
user={this.props.user}
/>
Expand Down
2 changes: 1 addition & 1 deletion love/src/components/OLE/NonExposure/NonExposure.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion love/src/components/Watcher/AlarmsList/AlarmsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className={styles.alarmsContainer} title="Alarms">
{alarms.length < 1 ? (
Expand All @@ -57,6 +59,7 @@ export default function AlarmList({ alarms, taiToUtc, ackAlarm, user }) {
severityUpdateTimestamp,
reason: alarm.reason?.value,
ackAlarm: ackAlarm,
logAlarm: logAlarm,
};

return <CompactAlarm key={alarm.name?.value} {...alarmProps}></CompactAlarm>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function CompactAlarm({
reason,
severityUpdateTimestamp,
ackAlarm,
logAlarm,
}) {
const severityStatus = severityToStatus[severity];
const maxSeverityStatus = severityToStatus[maxSeverity];
Expand Down Expand Up @@ -88,6 +89,18 @@ export default function CompactAlarm({
>
ACK
</Button>
<Button
title="Log alarm details to the Narrativelog"
status="info"
shape="rounder"
onClick={(event) => {
event.stopPropagation();
logAlarm(name);
event.nativeEvent.stopImmediatePropagation();
}}
>
LOG
</Button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ this program. If not, see <http://www.gnu.org/licenses/>.

.ackButtonContainer {
display: flex;
gap: 0.5em;
justify-content: center;
padding-top: 0.5em;
}
23 changes: 20 additions & 3 deletions love/src/components/Watcher/AlarmsTable/AlarmsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ export default class AlarmsTable extends PureComponent {

return (
<>
<td className={styles.ackButton} />
<td className={styles.actionButton}></td>
<td className={styles.actionButton}></td>
<ColumnHeader
{...defaultColumnProps}
className={styles.status}
Expand Down Expand Up @@ -304,7 +305,22 @@ export default class AlarmsTable extends PureComponent {
].join(' ')}
onClick={() => this.clickGearIcon(key)}
>
<td title={reasonStr} className={[styles.firstColumn, styles.ackButton].join(' ')}>
<td title={reasonStr} className={[styles.firstColumn, styles.actionButton].join(' ')}>
<div className={styles.statusWrapper}>
<Button
title="Log this alarm to the Narrativelog"
status="info"
onClick={(event) => {
event.stopPropagation();
this.props.logAlarm(row.name.value);
}}
command
>
LOG
</Button>
</div>
</td>
<td title={reasonStr} className={[styles.firstColumn, styles.actionButton].join(' ')}>
{!isAcknowledged(row) ? (
<div className={styles.statusWrapper}>
<Button
Expand Down Expand Up @@ -374,7 +390,8 @@ export default class AlarmsTable extends PureComponent {
' ',
)}
>
<td colSpan={1} className={styles.ackButton}></td>
<td colSpan={1} className={styles.actionButton}></td>
<td colSpan={1} className={styles.actionButton}></td>
<td colSpan={4} className={styles.expandedRowContent}>
<DetailsPanel
alarm={row}
Expand Down
36 changes: 21 additions & 15 deletions love/src/components/Watcher/AlarmsTable/AlarmsTable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ table {
}

.wrapper {
display: flex;
/* display: flex;
flex-flow: column;
align-items: flex-end;
width: inherit;
height: 100%;
height: 100%; */
}

.controlsContainer {
Expand All @@ -55,23 +55,24 @@ table {
}

.dataTableWrapper {
display: flex;
/* display: flex;
flex-flow: row;
justify-content: center;
width: inherit;
flex: 1;
min-height: 0;
min-height: 0; */
}

.dataTable {
display: grid;
grid-template-rows: min-content minmax(0, 1fr);
table-layout: fixed;
overflow-x: auto;
/* display: grid; */
/* grid-template-rows: min-content minmax(0, 1fr); */
/* table-layout: fixed; */
border-collapse: collapse;
}

/****************** Columns styles ***************/
.dataTable .ackButton {
.dataTable .actionButton {
width: var(--ack-width);
text-align: center;
}
Expand Down Expand Up @@ -123,21 +124,21 @@ table {

/****************** General table head and body styles ***************/
.dataTable thead {
display: table;
/* display: table;
table-layout: fixed;
width: 100%;
word-wrap: break-word;
word-wrap: break-word; */
}

.dataTable tbody {
display: block;
height: 100%; /* necessary for scroll */
overflow-x: hidden;
/* display: block; */
/* height: 100%; necessary for scroll */
/* overflow-x: hidden; */
}
.dataTable tbody tr {
display: table;
/* display: table;
table-layout: fixed;
width: 100%;
width: 100%; */
}
.dataTable th,
td {
Expand Down Expand Up @@ -229,6 +230,11 @@ td {
padding: 1em;
}

.dataTable .expandedRow .actionButton {
width: calc(var(--ack-width) * 1.365);
text-align: center;
}

.dataTable .unackExpandedRow .expandedRowContent {
background: var(--table-unack-row-background);
border-bottom: 1px solid var(--table-unack-row-border);
Expand Down
2 changes: 2 additions & 0 deletions love/src/components/Watcher/Watcher.container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { getUsername, getAllAlarms, getTaiToUtc, getAllTime } from '../../redux/selectors';
import { addGroup, removeGroup, requestSALCommand } from '../../redux/actions/ws';
import { logAlarm } from '../../redux/actions/alarms';
import SubscriptionTableContainer from '../GeneralPurpose/SubscriptionTable/SubscriptionTable.container';
import Watcher from './Watcher';
// import mockAlarms from './AlarmsTable/mock'
Expand Down Expand Up @@ -138,6 +139,7 @@ const mapDispatchToProps = (dispatch) => {
}),
);
},
logAlarm: (name) => dispatch(logAlarm(name)),
};
};

Expand Down
6 changes: 6 additions & 0 deletions love/src/components/Watcher/Watcher.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default class Watcher extends Component {
muteAlarm: PropTypes.func,
/** Function to dispatch an alarm unmute */
unmuteAlarm: PropTypes.func,
/** Function to dispatch an alarm logging */
logAlarm: PropTypes.func,
/** Function to subscribe to streams to receive the alarms */
subscribeToStreams: PropTypes.func,
/** Function to unsubscribe to streams to stop receiving the alarms */
Expand Down Expand Up @@ -196,6 +198,10 @@ export default class Watcher extends Component {
unackAlarm={this.props.unackAlarm}
muteAlarm={this.props.muteAlarm}
unmuteAlarm={this.props.unmuteAlarm}
logAlarm={(name) => {
this.setState({ waiting: true });
this.props.logAlarm(name);
}}
sortFunctions={this.state.selectedTab === 'unmuted' ? this.sortFunctions : this.mutedSortFunctions}
/>
</div>
Expand Down
33 changes: 33 additions & 0 deletions love/src/redux/actions/alarms.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { RECEIVE_ALARM, RECEIVE_ALL_ALARMS } from './actionTypes';
import { requestSALCommand } from './ws';

export const receiveAlarm = (alarm) => {
return {
Expand All @@ -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,
},
}),
);
};
};
Loading