-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gauge fixes for NaN and composition policy (#5608)
* Closes #5536, #5538 - Significant changes to code flow for better handling of missing telemetry values; closes #5538. - Changes to flow to handle range display when updating composition and when ranges are set by limits. - Added `GaugeCompositionPolicy.js`; closes #5536. * Closes #5536, #5538 - Code cleanup, linting. * Closes #5538 - Linting fixes. * Closes #5538 - Added test for 'Gauge does not display NaN when data not available'. * Closes #5538 - Refined test. * Closes #5538 - Refined 'NaN' test. - Added test for 'Gauge enforces composition policy'; * Closes #5538 - Fix linting issues. * Closes #5538 - Suggested changes from PR review. * Closes #5538 - Suggested changes from PR review. * Update e2e/tests/functional/plugins/gauge/gauge.e2e.spec.js Co-authored-by: Jesse Mazzella <[email protected]> * chore: lint:fix --------- Co-authored-by: Andrew Henry <[email protected]> Co-authored-by: David Tsay <[email protected]> Co-authored-by: Jesse Mazzella <[email protected]> Co-authored-by: Jesse Mazzella <[email protected]>
- Loading branch information
1 parent
a914e4f
commit 15ee830
Showing
4 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
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
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,51 @@ | ||
/***************************************************************************** | ||
* Open MCT, Copyright (c) 2014-2023, 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 GaugeCompositionPolicy(openmct) { | ||
function hasNumericTelemetry(domainObject) { | ||
const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject); | ||
if (!hasTelemetry) { | ||
return false; | ||
} | ||
|
||
const metadata = openmct.telemetry.getMetadata(domainObject); | ||
|
||
return metadata.values().length > 0 && hasDomainAndRange(metadata); | ||
} | ||
|
||
function hasDomainAndRange(metadata) { | ||
return ( | ||
metadata.valuesForHints(['range']).length > 0 && | ||
metadata.valuesForHints(['domain']).length > 0 | ||
); | ||
} | ||
|
||
return { | ||
allow: function (parent, child) { | ||
if (parent.type === 'gauge') { | ||
return hasNumericTelemetry(child); | ||
} | ||
|
||
return true; | ||
} | ||
}; | ||
} |
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
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