-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error and Alarm list cleanup, split into seperate components; Add con…
…troller type badge to each item
- Loading branch information
1 parent
f42ff7b
commit c3e5039
Showing
4 changed files
with
98 additions
and
57 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/app/containers/Preferences/Safety/ErrorLogs/ErrorItem.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import { VscError } from 'react-icons/vsc'; | ||
import { BsAlarm } from 'react-icons/bs'; | ||
import { VerticalTimelineElement } from 'react-vertical-timeline-component'; | ||
|
||
import { ALARM } from 'app/constants'; | ||
|
||
import styles from '../../index.styl'; | ||
|
||
const colorCodes = { | ||
ALARM: '#d75f5f', | ||
ERROR: '#ff0000' | ||
}; | ||
|
||
const ErrorItem = ({ log, date, time }) => { | ||
return ( | ||
<VerticalTimelineElement | ||
className={`vertical-timeline-element--work ${styles.marginUpdate}`} | ||
contentStyle={{ height: 'auto', borderTop: `5px solid ${colorCodes[log.type]}` }} | ||
contentArrowStyle={{ top: '42%' }} | ||
iconStyle={{ top: '31%', background: colorCodes[log.type], color: '#fff' }} | ||
dateClassName={styles.inbuiltDate} | ||
icon={log.type === ALARM ? <BsAlarm /> : <VscError />} | ||
> | ||
<span className={styles.errorTag}>{log.type} - {log.source}</span> | ||
<span className={styles.errorDate}> | ||
{`On ${date} at ${time}`} | ||
</span> | ||
<p className={styles.errorReason}> | ||
{`${log.type} ${log.CODE} - ${log.MESSAGE}`} <br /> | ||
</p> | ||
|
||
<div style={{ display: 'flex', justifyContent: 'space-between' }}> | ||
<p> | ||
{ | ||
log.line && ( | ||
log.source !== 'Console' && log.source !== 'Feeder' ? `Line ${log.lineNumber}: ` : 'Line: ' | ||
) | ||
} | ||
{log.line} | ||
</p> | ||
<p style={{ border: '1px solid #d1d5db', borderRadius: '6px', padding: '0 1rem', fontWeight: 'bold' }}>{log.controller}</p> | ||
</div> | ||
</VerticalTimelineElement> | ||
); | ||
}; | ||
|
||
export default ErrorItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/app/containers/Preferences/Safety/ErrorLogs/LogList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import { VerticalTimeline } from 'react-vertical-timeline-component'; | ||
import uniqueID from 'lodash/uniqueId'; | ||
|
||
import ErrorItem from './ErrorItem'; | ||
import { convertISOStringToDateAndTime } from '../../../../lib/datetime'; | ||
|
||
import styles from '../../index.styl'; | ||
|
||
const LogList = ({ logs }) => { | ||
if (!logs || logs?.length === 0) { | ||
return ( | ||
<div className={styles.noErrors}> | ||
No history of alarms or errors | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<VerticalTimeline animate={false} layout="1-column-left" className={styles.verticalTimeline}> | ||
{ | ||
logs.map((log) => { | ||
const [date, time] = convertISOStringToDateAndTime(log.time); | ||
|
||
const key = uniqueID(); | ||
|
||
return ( | ||
<ErrorItem | ||
log={log} | ||
date={date} | ||
time={time} | ||
key={key} | ||
/> | ||
); | ||
}) | ||
} | ||
</VerticalTimeline> | ||
); | ||
}; | ||
|
||
export default LogList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -600,9 +600,6 @@ | |
.errorTag{ | ||
font-weight: 800; | ||
font-size: 1.2rem; | ||
} | ||
.errorReason{ | ||
|
||
} | ||
.errorDate{ | ||
float: right; | ||
|