Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plan rendering inside a timestrip #6852

Merged
merged 4 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use $parent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we can't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s the issue here?

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