diff --git a/example/faultManagment/exampleFaultSource.js b/example/faultManagment/exampleFaultSource.js new file mode 100644 index 0000000000..338f0903b5 --- /dev/null +++ b/example/faultManagment/exampleFaultSource.js @@ -0,0 +1,83 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +export default function () { + return function install(openmct) { + openmct.install(openmct.plugins.FaultManagement()); + + openmct.faults.addProvider({ + request(domainObject, options) { + const faults = JSON.parse(localStorage.getItem('faults')); + + return Promise.resolve(faults.alarms); + }, + subscribe(domainObject, callback) { + const faultsData = JSON.parse(localStorage.getItem('faults')).alarms; + + function getRandomIndex(start, end) { + return Math.floor(start + (Math.random() * (end - start + 1))); + } + + let id = setInterval(() => { + const index = getRandomIndex(0, faultsData.length - 1); + const randomFaultData = faultsData[index]; + const randomFault = randomFaultData.fault; + randomFault.currentValueInfo.value = Math.random(); + callback({ + fault: randomFault, + type: 'alarms' + }); + }, 300); + + return () => { + clearInterval(id); + }; + }, + supportsRequest(domainObject) { + const faults = localStorage.getItem('faults'); + + return faults && domainObject.type === 'faultManagement'; + }, + supportsSubscribe(domainObject) { + const faults = localStorage.getItem('faults'); + + return faults && domainObject.type === 'faultManagement'; + }, + acknowledgeFault(fault, { comment = '' }) { + console.log('acknowledgeFault', fault); + console.log('comment', comment); + + return Promise.resolve({ + success: true + }); + }, + shelveFault(fault, shelveData) { + console.log('shelveFault', fault); + console.log('shelveData', shelveData); + + return Promise.resolve({ + success: true + }); + } + }); + }; +} diff --git a/example/faultManagment/pluginSpec.js b/example/faultManagment/pluginSpec.js new file mode 100644 index 0000000000..b7a0fa6801 --- /dev/null +++ b/example/faultManagment/pluginSpec.js @@ -0,0 +1,47 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +import { + createOpenMct, + resetApplicationState +} from '../../src/utils/testing'; + +describe("The Example Fault Source Plugin", () => { + let openmct; + + beforeEach(() => { + openmct = createOpenMct(); + }); + + afterEach(() => { + return resetApplicationState(openmct); + }); + + it('is not installed by default', () => { + expect(openmct.faults.provider).toBeUndefined(); + }); + + it('can be installed', () => { + openmct.install(openmct.plugins.example.ExampleFaultSource()); + expect(openmct.faults.provider).not.toBeUndefined(); + }); +}); diff --git a/index.html b/index.html index 9afe2acb34..d8ec226c49 100644 --- a/index.html +++ b/index.html @@ -75,7 +75,6 @@ const TWO_HOURS = ONE_HOUR * 2; const ONE_DAY = ONE_HOUR * 24; - openmct.install(openmct.plugins.LocalStorage()); openmct.install(openmct.plugins.example.Generator()); @@ -192,7 +191,7 @@ openmct.install(openmct.plugins.ObjectMigration()); openmct.install(openmct.plugins.ClearData( ['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked', 'example.imagery'], - {indicator: true} + { indicator: true } )); openmct.install(openmct.plugins.Clock({ enableClockIndicator: true })); openmct.install(openmct.plugins.Timer()); diff --git a/src/MCT.js b/src/MCT.js index 1330201488..7fa54e7ad1 100644 --- a/src/MCT.js +++ b/src/MCT.js @@ -238,6 +238,7 @@ define([ this.priority = api.PriorityAPI; this.router = new ApplicationRouter(this); + this.faults = new api.FaultManagementAPI.default(this); this.forms = new api.FormsAPI.default(this); this.branding = BrandingAPI.default; diff --git a/src/api/api.js b/src/api/api.js index 6cb76a0d97..505213476a 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -24,6 +24,7 @@ define([ './actions/ActionsAPI', './composition/CompositionAPI', './Editor', + './faultmanagement/FaultManagementAPI', './forms/FormsAPI', './indicators/IndicatorAPI', './menu/MenuAPI', @@ -40,6 +41,7 @@ define([ ActionsAPI, CompositionAPI, EditorAPI, + FaultManagementAPI, FormsAPI, IndicatorAPI, MenuAPI, @@ -57,6 +59,7 @@ define([ ActionsAPI: ActionsAPI.default, CompositionAPI: CompositionAPI, EditorAPI: EditorAPI, + FaultManagementAPI: FaultManagementAPI, FormsAPI: FormsAPI, IndicatorAPI: IndicatorAPI.default, MenuAPI: MenuAPI.default, diff --git a/src/api/faultmanagement/FaultManagementAPI.js b/src/api/faultmanagement/FaultManagementAPI.js new file mode 100644 index 0000000000..b22a85c093 --- /dev/null +++ b/src/api/faultmanagement/FaultManagementAPI.js @@ -0,0 +1,106 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +export default class FaultManagementAPI { + constructor(openmct) { + this.openmct = openmct; + } + + addProvider(provider) { + this.provider = provider; + } + + supportsActions() { + return this.provider?.acknowledgeFault !== undefined && this.provider?.shelveFault !== undefined; + } + + request(domainObject) { + if (!this.provider?.supportsRequest(domainObject)) { + return Promise.reject(); + } + + return this.provider.request(domainObject); + } + + subscribe(domainObject, callback) { + if (!this.provider?.supportsSubscribe(domainObject)) { + return Promise.reject(); + } + + return this.provider.subscribe(domainObject, callback); + } + + acknowledgeFault(fault, ackData) { + return this.provider.acknowledgeFault(fault, ackData); + } + + 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": "" + * } + * } + * } + */ diff --git a/src/api/faultmanagement/FaultManagementAPISpec.js b/src/api/faultmanagement/FaultManagementAPISpec.js new file mode 100644 index 0000000000..61c87402e7 --- /dev/null +++ b/src/api/faultmanagement/FaultManagementAPISpec.js @@ -0,0 +1,144 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * License); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +import { + createOpenMct, + resetApplicationState +} from '../../utils/testing'; + +const faultName = 'super duper fault'; +const aFault = { + type: '', + fault: { + acknowledged: true, + currentValueInfo: { + value: 0, + rangeCondition: '', + monitoringResult: '' + }, + id: '', + name: faultName, + namespace: '', + seqNum: 0, + severity: '', + shelved: true, + shortDescription: '', + triggerTime: '', + triggerValueInfo: { + value: 0, + rangeCondition: '', + monitoringResult: '' + } + } +}; +const faultDomainObject = { + name: 'it is not your fault', + type: 'faultManagement', + identifier: { + key: 'nobodies', + namespace: 'fault' + } +}; +const aComment = 'THIS is my fault.'; +const faultManagementProvider = { + request() { + return Promise.resolve([aFault]); + }, + subscribe(domainObject, callback) { + return () => {}; + }, + supportsRequest(domainObject) { + return domainObject.type === 'faultManagement'; + }, + supportsSubscribe(domainObject) { + return domainObject.type === 'faultManagement'; + }, + acknowledgeFault(fault, { comment = '' }) { + return Promise.resolve({ + success: true + }); + }, + shelveFault(fault, shelveData) { + return Promise.resolve({ + success: true + }); + } +}; + +describe('The Fault Management API', () => { + let openmct; + + beforeEach(() => { + openmct = createOpenMct(); + openmct.install(openmct.plugins.FaultManagement()); + // openmct.install(openmct.plugins.example.ExampleFaultSource()); + openmct.faults.addProvider(faultManagementProvider); + }); + + afterEach(() => { + return resetApplicationState(openmct); + }); + + it('allows you to request a fault', async () => { + spyOn(faultManagementProvider, 'supportsRequest').and.callThrough(); + + let faultResponse = await openmct.faults.request(faultDomainObject); + + expect(faultManagementProvider.supportsRequest).toHaveBeenCalledWith(faultDomainObject); + expect(faultResponse[0].fault.name).toEqual(faultName); + }); + + it('allows you to subscribe to a fault', () => { + spyOn(faultManagementProvider, 'subscribe').and.callThrough(); + spyOn(faultManagementProvider, 'supportsSubscribe').and.callThrough(); + + let unsubscribe = openmct.faults.subscribe(faultDomainObject, () => {}); + + expect(unsubscribe).toEqual(jasmine.any(Function)); + expect(faultManagementProvider.supportsSubscribe).toHaveBeenCalledWith(faultDomainObject); + expect(faultManagementProvider.subscribe).toHaveBeenCalledOnceWith(faultDomainObject, jasmine.any(Function)); + + }); + + it('will tell you if the fault management provider supports actions', () => { + expect(openmct.faults.supportsActions()).toBeTrue(); + }); + + it('will allow you to acknowledge a fault', async () => { + spyOn(faultManagementProvider, 'acknowledgeFault').and.callThrough(); + + let ackResponse = await openmct.faults.acknowledgeFault(aFault, aComment); + + expect(faultManagementProvider.acknowledgeFault).toHaveBeenCalledWith(aFault, aComment); + expect(ackResponse.success).toBeTrue(); + }); + + it('will allow you to shelve a fault', async () => { + spyOn(faultManagementProvider, 'shelveFault').and.callThrough(); + + let shelveResponse = await openmct.faults.shelveFault(aFault, aComment); + + expect(faultManagementProvider.shelveFault).toHaveBeenCalledWith(aFault, aComment); + expect(shelveResponse.success).toBeTrue(); + }); + +}); diff --git a/src/api/menu/components/Menu.vue b/src/api/menu/components/Menu.vue index 4d0cf39372..23a11f19b9 100644 --- a/src/api/menu/components/Menu.vue +++ b/src/api/menu/components/Menu.vue @@ -36,7 +36,7 @@
  • +
    +
    Fault Details
    + + +
    Telemetry
    + +
    + + + diff --git a/src/plugins/faultManagement/FaultManagementInspectorViewProvider.js b/src/plugins/faultManagement/FaultManagementInspectorViewProvider.js new file mode 100644 index 0000000000..b4500496fc --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementInspectorViewProvider.js @@ -0,0 +1,71 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +import FaultManagementInspector from './FaultManagementInspector.vue'; + +import Vue from 'vue'; + +import { FAULT_MANAGEMENT_INSPECTOR, FAULT_MANAGEMENT_TYPE } from './constants'; + +export default function FaultManagementInspectorViewProvider(openmct) { + return { + openmct: openmct, + key: FAULT_MANAGEMENT_INSPECTOR, + name: 'FAULT_MANAGEMENT_TYPE', + canView: (selection) => { + if (selection.length !== 1 || selection[0].length === 0) { + return false; + } + + let object = selection[0][0].context.item; + + return object && object.type === FAULT_MANAGEMENT_TYPE; + }, + view: (selection) => { + let component; + + return { + show: function (element) { + component = new Vue({ + el: element, + components: { + FaultManagementInspector + }, + provide: { + openmct + }, + template: '' + }); + }, + destroy: function () { + if (component) { + component.$destroy(); + component = undefined; + } + } + }; + }, + priority: () => { + return 1; + } + }; +} diff --git a/src/plugins/faultManagement/FaultManagementListHeader.vue b/src/plugins/faultManagement/FaultManagementListHeader.vue new file mode 100644 index 0000000000..81ee602aa1 --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementListHeader.vue @@ -0,0 +1,103 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + + + + diff --git a/src/plugins/faultManagement/FaultManagementListItem.vue b/src/plugins/faultManagement/FaultManagementListItem.vue new file mode 100644 index 0000000000..977d5d6634 --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementListItem.vue @@ -0,0 +1,191 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + + + + diff --git a/src/plugins/faultManagement/FaultManagementListView.vue b/src/plugins/faultManagement/FaultManagementListView.vue new file mode 100644 index 0000000000..15f214fa92 --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementListView.vue @@ -0,0 +1,299 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + + + + diff --git a/src/plugins/faultManagement/FaultManagementObjectProvider.js b/src/plugins/faultManagement/FaultManagementObjectProvider.js new file mode 100644 index 0000000000..9565c27c1f --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementObjectProvider.js @@ -0,0 +1,56 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +import { FAULT_MANAGEMENT_TYPE, FAULT_MANAGEMENT_VIEW, FAULT_MANAGEMENT_NAMESPACE } from './constants'; + +export default class FaultManagementObjectProvider { + constructor(openmct) { + this.openmct = openmct; + this.namespace = FAULT_MANAGEMENT_NAMESPACE; + this.key = FAULT_MANAGEMENT_VIEW; + this.objects = {}; + + this.createFaultManagementRootObject(); + } + + createFaultManagementRootObject() { + this.rootObject = { + identifier: { + key: this.key, + namespace: this.namespace + }, + name: 'Fault Management', + type: FAULT_MANAGEMENT_TYPE, + location: 'ROOT' + }; + + this.openmct.objects.addRoot(this.rootObject.identifier); + } + + get(identifier) { + if (identifier.key === FAULT_MANAGEMENT_VIEW) { + return Promise.resolve(this.rootObject); + } + + return Promise.reject(); + } +} diff --git a/src/plugins/faultManagement/FaultManagementPlugin.js b/src/plugins/faultManagement/FaultManagementPlugin.js new file mode 100644 index 0000000000..13e5a5dd60 --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementPlugin.js @@ -0,0 +1,42 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +import FaultManagementViewProvider from './FaultManagementViewProvider'; +import FaultManagementObjectProvider from './FaultManagementObjectProvider'; +import FaultManagementInspectorViewProvider from './FaultManagementInspectorViewProvider'; + +import { FAULT_MANAGEMENT_TYPE, FAULT_MANAGEMENT_NAMESPACE } from './constants'; + +export default function FaultManagementPlugin() { + return function (openmct) { + openmct.types.addType(FAULT_MANAGEMENT_TYPE, { + name: 'Fault Management', + creatable: false, + description: 'Fault Management View', + cssClass: 'icon-telemetry' + }); + + openmct.objectViews.addProvider(new FaultManagementViewProvider(openmct)); + openmct.inspectorViews.addProvider(new FaultManagementInspectorViewProvider(openmct)); + openmct.objects.addProvider(FAULT_MANAGEMENT_NAMESPACE, new FaultManagementObjectProvider(openmct)); + }; +} diff --git a/src/plugins/faultManagement/FaultManagementSearch.vue b/src/plugins/faultManagement/FaultManagementSearch.vue new file mode 100644 index 0000000000..bfd2060ff1 --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementSearch.vue @@ -0,0 +1,90 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + + + + diff --git a/src/plugins/faultManagement/FaultManagementToolbar.vue b/src/plugins/faultManagement/FaultManagementToolbar.vue new file mode 100644 index 0000000000..c366081d9f --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementToolbar.vue @@ -0,0 +1,102 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + + + + diff --git a/src/plugins/faultManagement/FaultManagementView.vue b/src/plugins/faultManagement/FaultManagementView.vue new file mode 100644 index 0000000000..3ae0c9a2fb --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementView.vue @@ -0,0 +1,77 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + + + + diff --git a/src/plugins/faultManagement/FaultManagementViewProvider.js b/src/plugins/faultManagement/FaultManagementViewProvider.js new file mode 100644 index 0000000000..9576cfd97c --- /dev/null +++ b/src/plugins/faultManagement/FaultManagementViewProvider.js @@ -0,0 +1,69 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +import FaultManagementView from './FaultManagementView.vue'; +import { FAULT_MANAGEMENT_TYPE, FAULT_MANAGEMENT_VIEW } from './constants'; +import Vue from 'vue'; + +export default class FaultManagementViewProvider { + constructor(openmct) { + this.openmct = openmct; + this.key = FAULT_MANAGEMENT_VIEW; + } + + canView(domainObject) { + return domainObject.type === FAULT_MANAGEMENT_TYPE; + } + + canEdit(domainObject) { + return false; + } + + view(domainObject) { + let component; + const openmct = this.openmct; + + return { + show: (element) => { + component = new Vue({ + el: element, + components: { + FaultManagementView + }, + provide: { + openmct, + domainObject + }, + template: '' + }); + }, + destroy: () => { + if (!component) { + return; + } + + component.$destroy(); + component = undefined; + } + }; + } +} diff --git a/src/plugins/faultManagement/constants.js b/src/plugins/faultManagement/constants.js new file mode 100644 index 0000000000..9f0be44a51 --- /dev/null +++ b/src/plugins/faultManagement/constants.js @@ -0,0 +1,122 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +const FAULT_SEVERITY = { + 'CRITICAL': { + name: 'CRITICAL', + value: 'critical', + priority: 0 + }, + 'WARNING': { + name: 'WARNING', + value: 'warning', + priority: 1 + }, + 'WATCH': { + name: 'WATCH', + value: 'watch', + priority: 2 + } +}; + +export const FAULT_MANAGEMENT_TYPE = 'faultManagement'; +export const FAULT_MANAGEMENT_INSPECTOR = 'faultManagementInspector'; +export const FAULT_MANAGEMENT_ALARMS = 'alarms'; +export const FAULT_MANAGEMENT_GLOBAL_ALARMS = 'global-alarm-status'; +export const FAULT_MANAGEMENT_SHELVE_DURATIONS_IN_MS = [ + { + name: '5 Minutes', + value: 300000 + }, + { + name: '10 Minutes', + value: 600000 + }, + { + name: '15 Minutes', + value: 900000 + }, + { + name: 'Indefinite', + value: 0 + } +]; +export const FAULT_MANAGEMENT_VIEW = 'faultManagement.view'; +export const FAULT_MANAGEMENT_NAMESPACE = 'faults.taxonomy'; +export const FILTER_ITEMS = [ + 'Standard View', + 'Acknowledged', + 'Unacknowledged', + 'Shelved' +]; +export const SORT_ITEMS = { + 'newest-first': { + name: 'Newest First', + value: 'newest-first', + sortFunction: (a, b) => { + if (b.triggerTime > a.triggerTime) { + return 1; + } + + if (a.triggerTime > b.triggerTime) { + return -1; + } + + return 0; + } + }, + 'oldest-first': { + name: 'Oldest First', + value: 'oldest-first', + sortFunction: (a, b) => { + if (a.triggerTime > b.triggerTime) { + return 1; + } + + if (a.triggerTime < b.triggerTime) { + return -1; + } + + return 0; + } + }, + 'severity': { + name: 'Severity', + value: 'severity', + sortFunction: (a, b) => { + const diff = FAULT_SEVERITY[a.severity].priority - FAULT_SEVERITY[b.severity].priority; + if (diff !== 0) { + return diff; + } + + if (b.triggerTime > a.triggerTime) { + return 1; + } + + if (a.triggerTime > b.triggerTime) { + return -1; + } + + return 0; + } + } +}; diff --git a/src/plugins/faultManagement/fault-manager.scss b/src/plugins/faultManagement/fault-manager.scss new file mode 100644 index 0000000000..6b75e548ab --- /dev/null +++ b/src/plugins/faultManagement/fault-manager.scss @@ -0,0 +1,234 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +/*********************************************** FAULT PROPERTIES */ +.is-severity-critical{ + @include glyphBefore($glyph-icon-alert-triangle); + color: $colorStatusError; +} + +.is-severity-warning{ + @include glyphBefore($glyph-icon-alert-rect); + color: $colorStatusAlert; +} + +.is-severity-watch{ + @include glyphBefore($glyph-icon-info); + color: $colorCommand; +} + +.is-unacknowledged{ + .c-fault-mgmt__list-severity{ + @include pulse($animName: severityAnim, $dur: 200ms); + } +} + +.is-selected { + background: $colorSelectedBg; +} + +.is-shelved{ + .c-fault-mgmt__list-content{ + opacity: 50% !important; + font-style: italic; + } + .c-fault-mgmt__list-severity{ + @include pulse($animName: shelvedAnim, $dur: 0ms); + } +} + + + +/*********************************************** SEARCH */ +.c-fault-mgmt__search-row{ + display: flex; + align-items: center; + > * + * { + margin-left: 10px; + float: right; + } +} + +.c-fault-mgmt-search{ + width: 95%; +} + +/*********************************************** TOOLBAR */ +.c-fault-mgmt__toolbar{ + display: flex; + justify-content: center; + > * { + font-size: 1.25em; + } +} + +/*********************************************** LIST VIEW */ +.c-faults-list-view { + display: flex; + flex-direction: column; + > * + * { + margin-top: $interiorMargin; + } +} + + +/*********************************************** FAULT ITEM */ +.c-fault-mgmt__list{ + background: rgba($colorBodyFg, 0.1); + margin-bottom: 5px; + padding: 4px; + display: flex; + align-items: center; + + > * { + margin-left: $interiorMargin; + } + + &-severity{ + font-size: 2em; + margin-left: $interiorMarginLg; + } + + &-pathname{ + flex-wrap: wrap; + flex: 1 1 auto; + + } + &-path{ + font-size: .75em; + } + + &-faultname{ + font-weight: bold; + font-size: 1.3em; + } + + &-content{ + display: flex; + flex-wrap: wrap; + flex: 1 1 auto; + align-items: center; + } + + &-content-right{ + margin-left: auto; + display: flex; + flex-wrap: wrap; + } + + &-trigVal, &-curVal, &-trigTime{ + @include ellipsize; + border-radius: $controlCr; + padding: $interiorMargin; + width: 80px; + margin-right: $interiorMarginLg; + + } + + &-trigVal { + @include isLimit(); + background: rgba($colorBodyFg, 0.25); + } + + &-curVal { + @include isLimit(); + background: rgba($colorBodyFg, 0.25); + &-alert{ + background: $colorWarningHi; + } + } + + &-trigTime{ + width: auto; + } + + &-action-wrapper{ + display: flex; + align-content: right; + width: 100px; + } + + &-action-button{ + flex: 0 0 auto; + margin-left: auto; + justify-content: right; + } +} + +/*********************************************** LIST HEADER */ +.c-fault-mgmt__list-header{ + display: flex; + background: rgba($colorBodyFg, .23); + border-radius: $controlCr; + + &-tripVal, &-liveVal, &-trigTime{ + background: none; + } + + &-trigTime{ + width: 160px; + } + &-sortButton{ + flex: 0 0 auto; + margin-left: auto; + justify-content: right; + display: flex; + align-content: right; + width: 100px; + } + +} + +.is-severity-critical{ + @include glyphBefore($glyph-icon-alert-triangle); + color: $colorStatusError; +} + +.is-severity-warning{ + @include glyphBefore($glyph-icon-alert-rect); + color: $colorStatusAlert; +} + +.is-severity-watch{ + @include glyphBefore($glyph-icon-info); + color: $colorCommand; +} + +.is-unacknowledged{ + .c-fault-mgmt__list-severity{ + @include pulse($animName: severityAnim, $dur: 200ms); + } +} + +.is-selected { + background: $colorSelectedBg; +} + +.is-shelved{ + .c-fault-mgmt__list-content{ + opacity: 60% !important; + font-style: italic; + } + .c-fault-mgmt__list-severity{ + @include pulse($animName: shelvedAnim, $dur: 0ms); + } +} diff --git a/src/plugins/faultManagement/pluginSpec.js b/src/plugins/faultManagement/pluginSpec.js new file mode 100644 index 0000000000..07ad9664c3 --- /dev/null +++ b/src/plugins/faultManagement/pluginSpec.js @@ -0,0 +1,52 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2022, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +import { + createOpenMct, + resetApplicationState +} from '../../utils/testing'; +import { FAULT_MANAGEMENT_TYPE } from './constants'; + +describe("The Fault Management Plugin", () => { + let openmct; + + beforeEach(() => { + openmct = createOpenMct(); + }); + + afterEach(() => { + return resetApplicationState(openmct); + }); + + it('is not installed by default', () => { + let typeDef = openmct.types.get(FAULT_MANAGEMENT_TYPE).definition; + + expect(typeDef.name).toBe('Unknown Type'); + }); + + it('can be installed', () => { + openmct.install(openmct.plugins.FaultManagement()); + let typeDef = openmct.types.get(FAULT_MANAGEMENT_TYPE).definition; + + expect(typeDef.name).toBe('Fault Management'); + }); +}); diff --git a/src/plugins/plugins.js b/src/plugins/plugins.js index eb55cfa51e..10264993ec 100644 --- a/src/plugins/plugins.js +++ b/src/plugins/plugins.js @@ -32,6 +32,7 @@ define([ './autoflow/AutoflowTabularPlugin', './timeConductor/plugin', '../../example/imagery/plugin', + '../../example/faultManagment/exampleFaultSource', './imagery/plugin', './summaryWidget/plugin', './URLIndicatorPlugin/URLIndicatorPlugin', @@ -81,6 +82,7 @@ define([ './operatorStatus/plugin', './gauge/GaugePlugin', './timelist/plugin', + './faultManagement/FaultManagementPlugin', '../../example/exampleTags/plugin' ], function ( _, @@ -94,6 +96,7 @@ define([ AutoflowPlugin, TimeConductorPlugin, ExampleImagery, + ExampleFaultSource, ImageryPlugin, SummaryWidget, URLIndicatorPlugin, @@ -143,6 +146,7 @@ define([ OperatorStatus, GaugePlugin, TimeList, + FaultManagementPlugin, ExampleTags ) { const plugins = {}; @@ -150,6 +154,7 @@ define([ plugins.example = {}; plugins.example.ExampleUser = ExampleUser.default; plugins.example.ExampleImagery = ExampleImagery.default; + plugins.example.ExampleFaultSource = ExampleFaultSource.default; plugins.example.EventGeneratorPlugin = EventGeneratorPlugin.default; plugins.example.ExampleTags = ExampleTags.default; plugins.example.Generator = () => GeneratorPlugin; @@ -189,6 +194,7 @@ define([ plugins.Notebook = Notebook.NotebookPlugin; plugins.RestrictedNotebook = Notebook.RestrictedNotebookPlugin; plugins.DisplayLayout = DisplayLayoutPlugin.default; + plugins.FaultManagement = FaultManagementPlugin.default; plugins.FormActions = FormActions; plugins.FolderView = FolderView; plugins.Tabs = Tabs; diff --git a/src/styles/vue-styles.scss b/src/styles/vue-styles.scss index bf1e05b1de..bf172cef19 100644 --- a/src/styles/vue-styles.scss +++ b/src/styles/vue-styles.scss @@ -55,6 +55,7 @@ @import "./notebook.scss"; @import "../plugins/notebook/components/sidebar.scss"; @import "../plugins/gauge/gauge.scss"; +@import "../plugins/faultManagement/fault-manager.scss"; @import "../plugins/operatorStatus/operator-status"; #splash-screen { diff --git a/src/ui/inspector/Location.vue b/src/ui/inspector/Location.vue index 590b74ad14..9d661dfbce 100644 --- a/src/ui/inspector/Location.vue +++ b/src/ui/inspector/Location.vue @@ -21,7 +21,10 @@ *****************************************************************************/