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

Use the current timestamp from the global clock #6851

Merged
merged 3 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e/tests/functional/planning/timelist.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ test.describe('Time List', () => {
const startBound = testPlan.TEST_GROUP[0].start;
const endBound = testPlan.TEST_GROUP[testPlan.TEST_GROUP.length - 1].end;

await page.goto(timelist.url);

// Switch to fixed time mode with all plan events within the bounds
await page.goto(
`${timelist.url}?tc.mode=fixed&tc.startBound=${startBound}&tc.endBound=${endBound}&tc.timeSystem=utc&view=timelist.view`
Expand Down
30 changes: 11 additions & 19 deletions src/plugins/timelist/Timelist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import { SORT_ORDER_OPTIONS } from './constants';
import _ from 'lodash';
import { v4 as uuid } from 'uuid';
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants';

const SCROLL_TIMEOUT = 10000;

Expand Down Expand Up @@ -114,10 +115,8 @@
},
mounted() {
this.isEditing = this.openmct.editor.isEditing();
this.timestamp = this.openmct.time.isRealTime()
? this.openmct.time.now()
: this.openmct.time.bounds().start;
this.openmct.time.on('clock', this.setViewFromClock);
this.timestamp = this.openmct.time.now();
this.openmct.time.on(TIME_CONTEXT_EVENTS.modeChanged, this.setFixedTime);

Check warning on line 119 in src/plugins/timelist/Timelist.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/timelist/Timelist.vue#L119

Added line #L119 was not covered by tests

this.getPlanDataAndSetConfig(this.domainObject);

Expand All @@ -138,7 +137,7 @@
this.status = this.openmct.status.get(this.domainObject.identifier);

this.updateTimestamp = _.throttle(this.updateTimestamp, 1000);
this.openmct.time.on('bounds', this.updateTimestamp);
this.openmct.time.on('tick', this.updateTimestamp);

Check warning on line 140 in src/plugins/timelist/Timelist.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/timelist/Timelist.vue#L140

Added line #L140 was not covered by tests
this.openmct.editor.on('isEditing', this.setEditState);

this.deferAutoScroll = _.debounce(this.deferAutoScroll, 500);
Expand All @@ -150,7 +149,7 @@
this.composition.load();
}

this.setViewFromClock(this.openmct.time.getClock());
this.setFixedTime(this.openmct.time.getMode());
},
beforeUnmount() {
if (this.unlisten) {
Expand All @@ -166,8 +165,8 @@
}

this.openmct.editor.off('isEditing', this.setEditState);
this.openmct.time.off('bounds', this.updateTimestamp);
this.openmct.time.off('clock', this.setViewFromClock);
this.openmct.time.off('tick', this.updateTimestamp);

Check warning on line 168 in src/plugins/timelist/Timelist.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/timelist/Timelist.vue#L168

Added line #L168 was not covered by tests
this.openmct.time.off(TIME_CONTEXT_EVENTS.modeChanged, this.setFixedTime);

this.$el.parentElement?.removeEventListener('scroll', this.deferAutoScroll, true);
if (this.clearAutoScrollDisabledTimer) {
Expand Down Expand Up @@ -202,22 +201,15 @@
this.listActivities();
}
},
updateTimestamp(bounds, isTick) {
if (isTick === true && this.openmct.time.isRealTime()) {
this.updateTimeStampAndListActivities(this.openmct.time.now());
} else if (isTick === false && !this.openmct.time.isRealTime()) {
// set the start time for fixed time using the selected bounds start
this.updateTimeStampAndListActivities(bounds.start);
}
updateTimestamp(timestamp) {
//The clock never stops ticking
this.updateTimeStampAndListActivities(timestamp);
},
setViewFromClock(newClock) {
setFixedTime() {
this.filterValue = this.domainObject.configuration.filter;
this.isFixedTime = !this.openmct.time.isRealTime();
if (this.isFixedTime) {
this.hideAll = false;
this.updateTimeStampAndListActivities(this.openmct.time.bounds()?.start);
} else {
this.updateTimeStampAndListActivities(this.openmct.time.now());
}
},
addItem(domainObject) {
Expand Down