diff --git a/e2e/tests/functional/plugins/faultManagement/faultManagement.e2e.spec.js b/e2e/tests/functional/plugins/faultManagement/faultManagement.e2e.spec.js index fa6365fe0a..b2f7d49f3b 100644 --- a/e2e/tests/functional/plugins/faultManagement/faultManagement.e2e.spec.js +++ b/e2e/tests/functional/plugins/faultManagement/faultManagement.e2e.spec.js @@ -22,6 +22,7 @@ const { test, expect } = require('../../../../pluginFixtures'); const utils = require('../../../../helper/faultUtils'); +const { selectInspectorTab } = require('../../../../appActions'); test.describe('The Fault Management Plugin using example faults', () => { test.beforeEach(async ({ page }) => { @@ -38,6 +39,7 @@ test.describe('The Fault Management Plugin using example faults', () => { test('When selecting a fault, it has an "is-selected" class and it\'s information shows in the inspector @unstable', async ({ page }) => { await utils.selectFaultItem(page, 1); + await selectInspectorTab(page, 'Fault Management Configuration'); const selectedFaultName = await page.locator('.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname').textContent(); const inspectorFaultNameCount = await page.locator(`.c-inspector__properties >> :text("${selectedFaultName}")`).count(); @@ -52,6 +54,7 @@ test.describe('The Fault Management Plugin using example faults', () => { const selectedRows = page.locator('.c-fault-mgmt__list.is-selected .c-fault-mgmt__list-faultname'); expect.soft(await selectedRows.count()).toEqual(2); + await selectInspectorTab(page, 'Fault Management Configuration'); const firstSelectedFaultName = await selectedRows.nth(0).textContent(); const secondSelectedFaultName = await selectedRows.nth(1).textContent(); const firstNameInInspectorCount = await page.locator(`.c-inspector__properties >> :text("${firstSelectedFaultName}")`).count(); diff --git a/example/faultManagement/exampleFaultSource.js b/example/faultManagement/exampleFaultSource.js index 56d852fed8..70ac92af4d 100644 --- a/example/faultManagement/exampleFaultSource.js +++ b/example/faultManagement/exampleFaultSource.js @@ -33,6 +33,8 @@ export default function (staticFaults = false) { return Promise.resolve(faultsData); }, subscribe(domainObject, callback) { + callback({ type: 'global-alarm-status' }); + return () => {}; }, supportsRequest(domainObject) { diff --git a/src/api/faultmanagement/FaultManagementAPI.js b/src/api/faultmanagement/FaultManagementAPI.js index 9b8fa9d829..413d11080c 100644 --- a/src/api/faultmanagement/FaultManagementAPI.js +++ b/src/api/faultmanagement/FaultManagementAPI.js @@ -21,18 +21,31 @@ *****************************************************************************/ export default class FaultManagementAPI { + /** + * @param {import("openmct").OpenMCT} openmct + */ constructor(openmct) { this.openmct = openmct; } + /** + * @param {*} provider + */ addProvider(provider) { this.provider = provider; } + /** + * @returns {boolean} + */ supportsActions() { return this.provider?.acknowledgeFault !== undefined && this.provider?.shelveFault !== undefined; } + /** + * @param {import("../objects/ObjectAPI").DomainObject} domainObject + * @returns {Promise.} + */ request(domainObject) { if (!this.provider?.supportsRequest(domainObject)) { return Promise.reject(); @@ -41,6 +54,11 @@ export default class FaultManagementAPI { return this.provider.request(domainObject); } + /** + * @param {import("../objects/ObjectAPI").DomainObject} domainObject + * @param {Function} callback + * @returns {Function} unsubscribe + */ subscribe(domainObject, callback) { if (!this.provider?.supportsSubscribe(domainObject)) { return Promise.reject(); @@ -49,58 +67,55 @@ export default class FaultManagementAPI { return this.provider.subscribe(domainObject, callback); } + /** + * @param {Fault} fault + * @param {*} ackData + */ acknowledgeFault(fault, ackData) { return this.provider.acknowledgeFault(fault, ackData); } + /** + * @param {Fault} fault + * @param {*} shelveData + * @returns {Promise.} + */ shelveFault(fault, shelveData) { return this.provider.shelveFault(fault, shelveData); } } -/** @typedef {object} Fault - * @property {string} type - * @property {object} fault - * @property {boolean} fault.acknowledged - * @property {object} fault.currentValueInfo - * @property {number} fault.currentValueInfo.value - * @property {string} fault.currentValueInfo.rangeCondition - * @property {string} fault.currentValueInfo.monitoringResult - * @property {string} fault.id - * @property {string} fault.name - * @property {string} fault.namespace - * @property {number} fault.seqNum - * @property {string} fault.severity - * @property {boolean} fault.shelved - * @property {string} fault.shortDescription - * @property {string} fault.triggerTime - * @property {object} fault.triggerValueInfo - * @property {number} fault.triggerValueInfo.value - * @property {string} fault.triggerValueInfo.rangeCondition - * @property {string} fault.triggerValueInfo.monitoringResult - * @example - * { - * "type": "", - * "fault": { - * "acknowledged": true, - * "currentValueInfo": { - * "value": 0, - * "rangeCondition": "", - * "monitoringResult": "" - * }, - * "id": "", - * "name": "", - * "namespace": "", - * "seqNum": 0, - * "severity": "", - * "shelved": true, - * "shortDescription": "", - * "triggerTime": "", - * "triggerValueInfo": { - * "value": 0, - * "rangeCondition": "", - * "monitoringResult": "" - * } - * } - * } +/** + * @typedef {object} TriggerValueInfo + * @property {number} value + * @property {string} rangeCondition + * @property {string} monitoringResult + */ + +/** + * @typedef {object} CurrentValueInfo + * @property {number} value + * @property {string} rangeCondition + * @property {string} monitoringResult + */ + +/** + * @typedef {object} Fault + * @property {boolean} acknowledged + * @property {CurrentValueInfo} currentValueInfo + * @property {string} id + * @property {string} name + * @property {string} namespace + * @property {number} seqNum + * @property {string} severity + * @property {boolean} shelved + * @property {string} shortDescription + * @property {string} triggerTime + * @property {TriggerValueInfo} triggerValueInfo + */ + +/** + * @typedef {object} FaultAPIResponse + * @property {string} type + * @property {Fault} fault */ diff --git a/src/plugins/faultManagement/FaultManagementView.vue b/src/plugins/faultManagement/FaultManagementView.vue index 79340e5103..9444b29556 100644 --- a/src/plugins/faultManagement/FaultManagementView.vue +++ b/src/plugins/faultManagement/FaultManagementView.vue @@ -42,8 +42,6 @@ export default { }; }, mounted() { - this.updateFaultList(); - this.unsubscribe = this.openmct.faults .subscribe(this.domainObject, this.updateFault); }, @@ -68,7 +66,11 @@ export default { this.openmct.faults .request(this.domainObject) .then(faultsData => { - this.faultsList = faultsData.map(fd => fd.fault); + if (faultsData?.length > 0) { + this.faultsList = faultsData.map(fd => fd.fault); + } else { + this.faultsList = []; + } }); } }