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

Time conductor refactor #7818

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
eeb4f99
add missing licensing comment
davetsay Apr 15, 2024
31be2cb
use vue component naming convention
davetsay Apr 15, 2024
c8f8a09
script, template, style
davetsay Apr 16, 2024
f56a8a1
Revert "script, template, style"
davetsay Apr 16, 2024
ff605a0
create useTimeSystem composable
davetsay Apr 16, 2024
10457a5
Merge branch 'master' into time-conductor-options
davetsay Apr 17, 2024
eeda4c6
forgot to push useTimeSystem
davetsay Apr 17, 2024
d0a7763
extend useTimeSystem to return reactive formatters
davetsay Apr 17, 2024
a11fcc3
return reactive isUTCBased
davetsay Apr 17, 2024
5adc86c
add useTimeMode composable
davetsay Apr 17, 2024
15126fd
add useTimeBounds composable
davetsay Apr 17, 2024
e624821
add useClockOffsets composable
davetsay Apr 18, 2024
00c9d29
WIP change replication in time api calls to use composables
davetsay Apr 19, 2024
2c55945
missed file in commit
davetsay Apr 19, 2024
4f37d95
use composables for conductor mode
davetsay May 1, 2024
3788a13
create useClock composable
davetsay May 14, 2024
23e12fa
whoops. mistook prettier red squiggly for code not used red squiggly.
davetsay May 14, 2024
bd1c7d9
vue naming convention
davetsay May 14, 2024
852ee74
change composables to allow for timeContexts
davetsay May 16, 2024
11adbd2
change timeContexts to be reactive to objectPath
davetsay May 17, 2024
0776003
reactivity and non fixes
davetsay May 18, 2024
5dba73e
use `shallowRef` for clock object
davetsay May 21, 2024
1bb49ea
WIP: get independent time contexts working again
davetsay May 22, 2024
9a57792
vue component naming conventions
davetsay May 22, 2024
e479c91
WIP: mostly fixed independent time conductor
davetsay May 22, 2024
9e56a22
provide timecontext even if its the global/timeapi for shared components
davetsay Jun 5, 2024
0168f92
incorporate provided timecontext into independant time conductor comp…
davetsay Jun 6, 2024
a029982
better jsdoc message
davetsay Jun 6, 2024
0254367
fix missing clock on independent time mode change
davetsay Jun 6, 2024
0cbdbc6
switch to reactive formatter for zoom
davetsay Jun 6, 2024
f349390
use reactive timecontext in fixed inputs
davetsay Jun 6, 2024
1aa3097
use reactive clock props
davetsay Jun 11, 2024
1d77368
edit for clarity
davetsay Jul 3, 2024
7ace3d0
remove unused injection
davetsay Jul 3, 2024
f1cf12d
change ITC to use composables
davetsay Jul 3, 2024
b3c99ae
update to use composables
davetsay Jul 3, 2024
fbf145c
rename because need both datetime and time inputs
davetsay Jul 3, 2024
eb314a6
make message universal to all timeSystems
davetsay Jul 11, 2024
9924f53
only change time options if independent conductor enabled
davetsay Jul 11, 2024
9065158
make date time only for supporting time systems
davetsay Jul 11, 2024
e2092a7
fix css for bounds single inputs
davetsay Jul 12, 2024
3922ade
time formats can specify date/time delimiters
davetsay Jul 12, 2024
5037254
move history out of form
davetsay Aug 21, 2024
6db96df
handle toggle independent time
davetsay Aug 21, 2024
760ca40
Merge branch 'master' into time-conductor-options-4.0.0
davetsay Aug 22, 2024
211272c
v-if logic one component up
davetsay Aug 22, 2024
140184e
add back date selector
davetsay Nov 14, 2024
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
12 changes: 10 additions & 2 deletions src/api/time/IndependentTimeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,16 @@
return this.upstreamTimeContext.setMode(...arguments);
}

if (mode === MODES.realtime && this.activeClock === undefined) {
throw `Unknown clock. Has a clock been registered with 'addClock'?`;
if (mode === MODES.realtime) {
// TODO: This should probably happen up front in creating an independent time context
// TODO: not just in time every time setMode is called
if (this.activeClock === undefined) {
this.activeClock = this.globalTimeContext.getClock();

Check warning on line 328 in src/api/time/IndependentTimeContext.js

View check run for this annotation

Codecov / codecov/patch

src/api/time/IndependentTimeContext.js#L328

Added line #L328 was not covered by tests
}

if (this.activeClock === undefined) {
throw `Unknown clock. Has a clock been registered with 'addClock'?`;

Check warning on line 332 in src/api/time/IndependentTimeContext.js

View check run for this annotation

Codecov / codecov/patch

src/api/time/IndependentTimeContext.js#L332

Added line #L332 was not covered by tests
}
}

if (mode !== this.mode) {
Expand Down
20 changes: 10 additions & 10 deletions src/api/time/TimeAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,30 +134,30 @@

/**
* Get or set an independent time context which follows the TimeAPI timeSystem,
* but with different offsets for a given domain object
* @param {string} key The identifier key of the domain object these offsets are set for
* @param {ClockOffsets | TimeConductorBounds} value This maintains a sliding time window of a fixed width that automatically updates
* @param {key | string} clockKey the real time clock key currently in use
* but with different bounds for a given domain object
* @param {string} keyString The keyString identifier of the domain object these offsets are set for
* @param {TimeConductorBounds | ClockOffsets} boundsOrOffsets either bounds if in fixed mode, or offsets if in realtime mode
* @param {string} clockKey the key for the real time clock to use
*/
addIndependentContext(key, value, clockKey) {
let timeContext = this.getIndependentContext(key);
addIndependentContext(keyString, boundsOrOffsets, clockKey) {
let timeContext = this.getIndependentContext(keyString);

//stop following upstream time context since the view has it's own
timeContext.resetContext();

if (clockKey) {
timeContext.setClock(clockKey);
timeContext.setMode(REALTIME_MODE_KEY, value);
timeContext.setMode(REALTIME_MODE_KEY, boundsOrOffsets);

Check warning on line 150 in src/api/time/TimeAPI.js

View check run for this annotation

Codecov / codecov/patch

src/api/time/TimeAPI.js#L150

Added line #L150 was not covered by tests
} else {
timeContext.setMode(FIXED_MODE_KEY, value);
timeContext.setMode(FIXED_MODE_KEY, boundsOrOffsets);
}

// Notify any nested views to update, pass in the viewKey so that particular view can skip getting an upstream context
this.emit('refreshContext', key);
this.emit('refreshContext', keyString);

return () => {
//follow any upstream time context
this.emit('removeOwnContext', key);
this.emit('removeOwnContext', keyString);
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/time/TimeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class TimeContext extends EventEmitter {
} else if (bounds.start > bounds.end) {
return {
valid: false,
message: 'Specified start date exceeds end bound'
message: 'Start bound exceeds end bound'
};
}

Expand Down
23 changes: 2 additions & 21 deletions src/plugins/timeConductor/ConductorAxis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,16 @@ import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js';
import utcMultiTimeFormat from './utcMultiTimeFormat.js';

const PADDING = 1;
const DEFAULT_DURATION_FORMATTER = 'duration';
const PIXELS_PER_TICK = 100;
const PIXELS_PER_TICK_WIDE = 200;

export default {
inject: ['openmct'],
inject: ['openmct', 'isFixedTimeMode'],
props: {
viewBounds: {
type: Object,
required: true
},
isFixed: {
type: Boolean,
required: true
},
altPressed: {
type: Boolean,
required: true
Expand Down Expand Up @@ -198,22 +193,8 @@ export default {
this.axisElement.call(this.xAxis);
this.setScale();
},
getActiveFormatter() {
let timeSystem = this.openmct.time.getTimeSystem();

if (this.isFixed) {
return this.getFormatter(timeSystem.timeFormat);
} else {
return this.getFormatter(timeSystem.durationFormat || DEFAULT_DURATION_FORMATTER);
}
},
getFormatter(key) {
return this.openmct.telemetry.getValueFormatter({
format: key
}).formatter;
},
dragStart($event) {
if (this.isFixed) {
if (this.isFixedTimeMode) {
this.dragStartX = $event.clientX;

if (this.altPressed) {
Expand Down
80 changes: 8 additions & 72 deletions src/plugins/timeConductor/ConductorClock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<div v-if="readOnly === false" ref="clockButton" class="c-tc-input-popup__options">
<div class="c-menu-button c-ctrl-wrapper c-ctrl-wrapper--menus-left">
<button
class="c-button--menu js-clock-button"
:class="[buttonCssClass, selectedClock.cssClass]"
class="c-button--menu js-clock-button c-icon-button"
:class="selectedClock.cssClass"
aria-label="Time Conductor Clock Menu"
@click.prevent.stop="showClocksMenu"
>
Expand All @@ -38,18 +38,8 @@
</template>

<script>
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js';
import clockMixin from './clock-mixin.js';
export default {
mixins: [clockMixin],
inject: {
openmct: 'openmct',
configuration: {
from: 'configuration',
default: undefined
}
},
inject: ['openmct', 'configuration', 'clock', 'getAllClockMetadata', 'getClockMetadata'],
props: {
readOnly: {
type: Boolean,
Expand All @@ -58,21 +48,13 @@ export default {
}
}
},
emits: ['clock-updated'],
data() {
const activeClock = this.getActiveClock();
return {
selectedClock: activeClock ? this.getClockMetadata(activeClock) : undefined,
clocks: []
};
computed: {
selectedClock() {
return this.getClockMetadata(this.clock);
}
},
mounted() {
this.loadClocks(this.configuration.menuOptions);
this.openmct.time.on(TIME_CONTEXT_EVENTS.clockChanged, this.setViewFromClock);
},
unmounted() {
this.openmct.time.off(TIME_CONTEXT_EVENTS.clockChanged, this.setViewFromClock);
this.clocks = this.getAllClockMetadata(this.configuration.menuOptions);
},
methods: {
showClocksMenu() {
Expand All @@ -86,52 +68,6 @@ export default {
};
this.dismiss = this.openmct.menus.showSuperMenu(x, y, this.clocks, menuOptions);
},
setClock(clockKey) {
const option = {
clockKey
};
let configuration = this.getMatchingConfig({
clock: clockKey,
timeSystem: this.openmct.time.getTimeSystem().key
});
if (configuration === undefined) {
configuration = this.getMatchingConfig({
clock: clockKey
});
option.timeSystem = configuration.timeSystem;
option.bounds = configuration.bounds;
// this.openmct.time.setTimeSystem(configuration.timeSystem, configuration.bounds);
}
const offsets = this.openmct.time.getClockOffsets() ?? configuration.clockOffsets;
option.offsets = offsets;
this.$emit('clock-updated', option);
},
getMatchingConfig(options) {
const matchers = {
clock(config) {
return options.clock === config.clock;
},
timeSystem(config) {
return options.timeSystem === config.timeSystem;
}
};
function configMatches(config) {
return Object.keys(options).reduce((match, option) => {
return match && matchers[option](config);
}, true);
}
return this.configuration.menuOptions.filter(configMatches)[0];
},
setViewFromClock(clock) {
this.selectedClock = this.getClockMetadata(clock);
}
}
};
Expand Down
Loading
Loading