Compare commits

...

10 Commits

Author SHA1 Message Date
Michael Rogers
8ed4aa4338 Duplicate sizedImageHeight with thumbnail height calculation 2022-04-21 17:59:05 -05:00
Michael Rogers
6190908e25 Adjust constant minimums 2022-04-21 16:54:18 -05:00
Michael Rogers
0ccf75b135 Trailing spaces 2022-04-21 16:27:09 -05:00
Michael Rogers
b839a651de Fixed linting errors 2022-04-21 16:23:01 -05:00
Michael Rogers
ad3185ab7f Cleanup 2022-04-21 16:10:13 -05:00
Michael Rogers
2f453fdeed Set an arbitrary threshold to maintain visibility after image resize 2022-04-21 16:07:09 -05:00
Michael Rogers
b6101387e9 Externalize consts 2022-04-21 15:46:01 -05:00
Michael Rogers
178532c218 Display flex instead of block 2022-04-21 15:44:10 -05:00
Michael Rogers
0740b863d3 show timestrip computed value 2022-04-19 17:21:36 -05:00
Shefali Joshi
d19088cec6 Conditional styles for stacked plots (#4965) 2022-03-31 14:47:58 -07:00
5 changed files with 230 additions and 3 deletions

View File

@@ -162,7 +162,8 @@
class="c-imagery__thumbs-wrapper"
:class="[
{ 'is-paused': isPaused && !isFixed },
{ 'is-autoscroll-off': !resizingWindow && !autoScroll && !isPaused }
{ 'is-autoscroll-off': !resizingWindow && !autoScroll && !isPaused },
{ 'show-thumbnail': showImageThumbnails}
]"
>
<div
@@ -229,6 +230,9 @@ const SCROLL_LATENCY = 250;
const ZOOM_SCALE_DEFAULT = 1;
const THUMBNAIL_LAYOUT_MIN_WIDTH = 400;
const THUMBNAIL_LAYOUT_MIN_HEIGHT = 300;
export default {
components: {
Compass,
@@ -286,7 +290,8 @@ export default {
imageTranslateY: 0,
pan: undefined,
animateZoom: true,
imagePanned: false
imagePanned: false,
showImageThumbnails: false
};
},
computed: {
@@ -458,6 +463,7 @@ export default {
height: this.sizedImageHeight
};
}
},
watch: {
imageHistory: {
@@ -502,6 +508,10 @@ export default {
this.resetAgeCSS();
this.updateRelatedTelemetryForFocusedImage();
this.getImageNaturalDimensions();
},
sizedImageDimensions() {
const previousVisibility = this.showImageThumbnails;
this.showImageThumbnails = this.shouldDisplayThumbnails(previousVisibility);
}
},
async mounted() {
@@ -1050,6 +1060,31 @@ export default {
},
setCursorStates(states) {
this.cursorStates = states;
},
shouldDisplayThumbnails(previousVisibility) {
const focusedImageNaturalAspectRatio = this.$refs.focusedImage.naturalWidth / this.$refs.focusedImage.naturalHeight;
// FIXME: magic number of thumbnail height;
// cannot use this.$refs.thumbsWrapper.getBoundingClientRect since zeroed out by display:none
const thumbnailContainerHeight = 135;
let sizedImageWidth;
let sizedImageHeight;
// if the image thumbnail strip is not visible, subtract from container height
let imageContainerHeight = previousVisibility ? this.imageContainerHeight : this.imageContainerHeight - thumbnailContainerHeight;
let imageContainerWidth = this.imageContainerWidth;
if ((imageContainerWidth / imageContainerHeight) > focusedImageNaturalAspectRatio) {
// container is wider than image
sizedImageWidth = imageContainerHeight * focusedImageNaturalAspectRatio;
sizedImageHeight = imageContainerHeight;
} else {
// container is taller than image
sizedImageWidth = imageContainerWidth;
sizedImageHeight = imageContainerWidth / focusedImageNaturalAspectRatio;
}
return (
sizedImageWidth >= THUMBNAIL_LAYOUT_MIN_WIDTH
&& sizedImageHeight >= THUMBNAIL_LAYOUT_MIN_HEIGHT
);
}
}
};

View File

@@ -142,9 +142,9 @@
}
}
&__thumbs-scroll-area {
flex: 0 1 auto;
display: flex;
flex-direction: row;
height: 135px;
overflow-x: auto;
@@ -200,6 +200,11 @@
// When Imagery is in a layout, hide the thumbs area
display: none;
}
.show-thumbnail {
.c-imagery__thumbs-scroll-area {
display: flex;
}
}
}
/*************************************** IMAGERY LOCAL CONTROLS*/

View File

@@ -571,6 +571,34 @@ describe("the plugin", function () {
range: 2
}
}]
},
configuration: {
objectStyles: {
staticStyle: {
style: {
backgroundColor: 'rgb(0, 200, 0)',
color: '',
border: ''
}
},
conditionSetIdentifier: {
namespace: '',
key: 'testConditionSetId'
},
selectedConditionId: 'conditionId1',
defaultConditionId: 'conditionId1',
styles: [
{
conditionId: 'conditionId1',
style: {
backgroundColor: 'rgb(0, 155, 0)',
color: '',
output: '',
border: ''
}
}
]
}
}
};
@@ -815,6 +843,20 @@ describe("the plugin", function () {
});
});
it("shows styles for telemetry objects if available", (done) => {
Vue.nextTick(() => {
let conditionalStylesContainer = element.querySelectorAll(".c-plot--stacked-container .js-style-receiver");
let hasStyles = 0;
conditionalStylesContainer.forEach(el => {
if (el.style.backgroundColor !== '') {
hasStyles++;
}
});
expect(hasStyles).toBe(1);
done();
});
});
describe('limits', () => {
it('lines are not displayed by default', () => {

View File

@@ -26,8 +26,10 @@
import MctPlot from '../MctPlot.vue';
import Vue from "vue";
import conditionalStylesMixin from "./mixins/objectStyles-mixin";
export default {
mixins: [conditionalStylesMixin],
inject: ['openmct', 'domainObject', 'path'],
props: {
object: {

View File

@@ -0,0 +1,143 @@
/*****************************************************************************
* 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 StyleRuleManager from "@/plugins/condition/StyleRuleManager";
import {STYLE_CONSTANTS} from "@/plugins/condition/utils/constants";
export default {
inject: ['openmct', 'domainObject', 'path'],
data() {
return {
objectStyle: undefined
};
},
mounted() {
this.objectStyles = this.getObjectStyleForItem(this.object.configuration);
this.initObjectStyles();
},
beforeDestroy() {
if (this.stopListeningStyles) {
this.stopListeningStyles();
}
if (this.styleRuleManager) {
this.styleRuleManager.destroy();
}
},
methods: {
getObjectStyleForItem(config) {
if (config && config.objectStyles) {
return config.objectStyles ? Object.assign({}, config.objectStyles) : undefined;
} else {
return undefined;
}
},
initObjectStyles() {
if (!this.styleRuleManager) {
this.styleRuleManager = new StyleRuleManager(this.objectStyles, this.openmct, this.updateStyle.bind(this), true);
} else {
this.styleRuleManager.updateObjectStyleConfig(this.objectStyles);
}
if (this.stopListeningStyles) {
this.stopListeningStyles();
}
this.stopListeningStyles = this.openmct.objects.observe(this.object, 'configuration.objectStyles', (newObjectStyle) => {
//Updating styles in the inspector view will trigger this so that the changes are reflected immediately
this.styleRuleManager.updateObjectStyleConfig(newObjectStyle);
});
if (this.object && this.object.configuration && this.object.configuration.fontStyle) {
const { fontSize, font } = this.object.configuration.fontStyle;
this.setFontSize(fontSize);
this.setFont(font);
}
this.stopListeningFontStyles = this.openmct.objects.observe(this.object, 'configuration.fontStyle', (newFontStyle) => {
this.setFontSize(newFontStyle.fontSize);
this.setFont(newFontStyle.font);
});
},
getStyleReceiver() {
let styleReceiver;
if (this.$el !== undefined) {
styleReceiver = this.$el.querySelector('.js-style-receiver')
|| this.$el.querySelector(':first-child');
if (styleReceiver === null) {
styleReceiver = undefined;
}
}
return styleReceiver;
},
setFontSize(newSize) {
let elemToStyle = this.getStyleReceiver();
if (elemToStyle !== undefined) {
elemToStyle.dataset.fontSize = newSize;
}
},
setFont(newFont) {
let elemToStyle = this.getStyleReceiver();
if (elemToStyle !== undefined) {
elemToStyle.dataset.font = newFont;
}
},
updateStyle(styleObj) {
let elemToStyle = this.getStyleReceiver();
if (!styleObj || elemToStyle === undefined) {
return;
}
let keys = Object.keys(styleObj);
keys.forEach(key => {
if (elemToStyle) {
if ((typeof styleObj[key] === 'string') && (styleObj[key].indexOf('__no_value') > -1)) {
if (elemToStyle.style[key]) {
elemToStyle.style[key] = '';
}
} else {
if (!styleObj.isStyleInvisible && elemToStyle.classList.contains(STYLE_CONSTANTS.isStyleInvisible)) {
elemToStyle.classList.remove(STYLE_CONSTANTS.isStyleInvisible);
} else if (styleObj.isStyleInvisible && !elemToStyle.classList.contains(styleObj.isStyleInvisible)) {
elemToStyle.classList.add(styleObj.isStyleInvisible);
}
elemToStyle.style[key] = styleObj[key];
}
}
});
if (this.object && this.object.type === 'conditionWidget' && keys.includes('output')) {
this.openmct.objects.mutate(this.object, 'conditionalLabel', styleObj.output);
} else {
this.openmct.objects.mutate(this.object, 'conditionalLabel', '');
}
}
}
};