Skip to content

Commit

Permalink
Plan rendering inside a timestrip (#6852)
Browse files Browse the repository at this point in the history
* Use the width and height of the container of the plan to set the activity widths and now markers

* Use the right parent to determine height and width

---------

Co-authored-by: Jesse Mazzella <[email protected]>
  • Loading branch information
shefalijoshi and ozyx authored Jul 28, 2023
1 parent d4e51cb commit 3c2b032
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
9 changes: 6 additions & 3 deletions src/plugins/plan/components/Plan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,23 @@ export default {
if (!clientWidth) {
//this is a hack - need a better way to find the parent of this component
let parent = this.openmct.layout.$refs.browseObject.$el;
let parent = this.getParent();
if (parent) {
clientWidth = parent.getBoundingClientRect().width;
}
}
return clientWidth - 200;
},
getParent() {
//this is a hack - need a better way to find the parent of this component
return this.$el.closest('.is-object-type-time-strip');
},
getClientHeight() {
let clientHeight = this.$refs.plan.clientHeight;
if (!clientHeight) {
//this is a hack - need a better way to find the parent of this component
let parent = this.openmct.layout.$refs.browseObject.$el;
let parent = this.getParent();
if (parent) {
clientHeight = parent.getBoundingClientRect().height;
}
Expand Down
13 changes: 11 additions & 2 deletions src/plugins/timeline/TimelineViewLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import TimelineObjectView from './TimelineObjectView.vue';
import TimelineAxis from '../../ui/components/TimeSystemAxis.vue';
import SwimLane from '@/ui/components/swim-lane/SwimLane.vue';
import { getValidatedData } from '../plan/util';
import _ from 'lodash';
const unknownObjectType = {
definition: {
Expand Down Expand Up @@ -81,6 +82,7 @@ export default {
this.composition.off('remove', this.removeItem);
this.composition.off('reorder', this.reorder);
this.stopFollowingTimeContext();
this.contentResizeObserver.disconnect();
},
mounted() {
this.items = [];
Expand All @@ -92,6 +94,10 @@ export default {
this.composition.on('reorder', this.reorder);
this.composition.load();
}
this.handleContentResize = _.debounce(this.handleContentResize, 500);
this.contentResizeObserver = new ResizeObserver(this.handleContentResize);
this.contentResizeObserver.observe(this.$refs.timelineHolder);
},
methods: {
addItem(domainObject) {
Expand Down Expand Up @@ -132,18 +138,21 @@ export default {
this.items[reorderEvent.newIndex] = oldItems[reorderEvent.oldIndex];
});
},
handleContentResize() {
this.updateContentHeight();
},
updateContentHeight() {
const clientHeight = this.getClientHeight();
if (this.height !== clientHeight) {
this.height = clientHeight;
}
},
getClientHeight() {
let clientHeight = this.$refs.contentHolder.getBoundingClientRect().height;
let clientHeight = this.$refs.timelineHolder.getBoundingClientRect().height;
if (!clientHeight) {
//this is a hack - need a better way to find the parent of this component
let parent = this.openmct.layout.$refs.browseObject.$el;
let parent = this.$el.closest('.c-object-view');
if (parent) {
clientHeight = parent.getBoundingClientRect().height;
}
Expand Down
24 changes: 10 additions & 14 deletions src/ui/components/TimeSystemAxis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default {
},
timeSystem(newTimeSystem) {
this.drawAxis(this.bounds, newTimeSystem);
},
contentHeight() {
this.updateNowMarker();
}
},
mounted() {
Expand Down Expand Up @@ -110,20 +113,13 @@ export default {
}
},
updateNowMarker() {
if (this.openmct.time.getClock() === undefined) {
let nowMarker = document.querySelector('.nowMarker');
if (nowMarker) {
nowMarker.classList.add('hidden');
}
} else {
let nowMarker = document.querySelector('.nowMarker');
if (nowMarker) {
nowMarker.classList.remove('hidden');
nowMarker.style.height = this.contentHeight + 'px';
const nowTimeStamp = this.openmct.time.getClock().currentValue();
const now = this.xScale(nowTimeStamp);
nowMarker.style.left = now + this.offset + 'px';
}
let nowMarker = this.$el.querySelector('.nowMarker');
if (nowMarker) {
nowMarker.classList.remove('hidden');
nowMarker.style.height = this.contentHeight + 'px';
const nowTimeStamp = this.openmct.time.now();
const now = this.xScale(nowTimeStamp);
nowMarker.style.left = now + this.offset + 'px';
}
},
setDimensions() {
Expand Down

0 comments on commit 3c2b032

Please sign in to comment.