mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 23:36:41 +00:00
ab49f3f3a1
* refactor: merge FaultManagementListView into FaultManagementView * refactor: make `selectedFaults` a computed property * refactor: use named exports * fix: reset fault map AFTER selectedFaults have been acknowledged * a11y: add aria labels for fault management toolbar buttons * refactor: use named import/exports * a11y: add label * a11y: add aria label for checkboxes * fix: acknowledging or shelving single fault from context menu should only apply to selected fault * refactor: use change event instead of input event for checkbox * test: fix e2e tests, remove expect.softs * test: stabilize fault management e2e tests
74 lines
1.6 KiB
JavaScript
74 lines
1.6 KiB
JavaScript
const SEVERITIES = ['WATCH', 'WARNING', 'CRITICAL'];
|
|
const NAMESPACE = '/Example/fault-';
|
|
const getRandom = {
|
|
severity: () => SEVERITIES[Math.floor(Math.random() * 3)],
|
|
value: () => Math.random() + Math.floor(Math.random() * 21) - 10,
|
|
fault: (num, staticFaults) => {
|
|
let val = getRandom.value();
|
|
let severity = getRandom.severity();
|
|
let time = Date.now() - num;
|
|
|
|
if (staticFaults) {
|
|
let severityIndex = num > 3 ? num % 3 : num;
|
|
|
|
val = num;
|
|
severity = SEVERITIES[severityIndex - 1];
|
|
time = num;
|
|
}
|
|
|
|
return {
|
|
type: num,
|
|
fault: {
|
|
acknowledged: false,
|
|
currentValueInfo: {
|
|
value: val,
|
|
rangeCondition: severity,
|
|
monitoringResult: severity
|
|
},
|
|
id: `id-${num}`,
|
|
name: `Example Fault ${num}`,
|
|
namespace: NAMESPACE + num,
|
|
seqNum: 0,
|
|
severity: severity,
|
|
shelved: false,
|
|
shortDescription: '',
|
|
triggerTime: time,
|
|
triggerValueInfo: {
|
|
value: val,
|
|
rangeCondition: severity,
|
|
monitoringResult: severity
|
|
}
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
export function shelveFault(
|
|
fault,
|
|
opts = {
|
|
shelved: true,
|
|
comment: '',
|
|
shelveDuration: 90000
|
|
}
|
|
) {
|
|
fault.shelved = true;
|
|
|
|
setTimeout(() => {
|
|
fault.shelved = false;
|
|
}, opts.shelveDuration);
|
|
}
|
|
|
|
export function acknowledgeFault(fault) {
|
|
fault.acknowledged = true;
|
|
}
|
|
|
|
export function randomFaults(staticFaults, count = 5) {
|
|
let faults = [];
|
|
|
|
for (let x = 1, y = count + 1; x < y; x++) {
|
|
faults.push(getRandom.fault(x, staticFaults));
|
|
}
|
|
|
|
return faults;
|
|
}
|