Compare commits

...

12 Commits

Author SHA1 Message Date
David Tsay
e624821ab1 add useClockOffsets composable
documentation update to useTimeBounds
2024-04-17 17:15:40 -07:00
David Tsay
15126fd550 add useTimeBounds composable 2024-04-17 16:12:36 -07:00
David Tsay
5adc86c71e add useTimeMode composable
fix listener in useTimeSystem
2024-04-17 14:16:25 -07:00
David Tsay
a11fcc3231 return reactive isUTCBased 2024-04-17 11:32:10 -07:00
David Tsay
d0a77637c0 extend useTimeSystem to return reactive formatters 2024-04-17 11:22:31 -07:00
David Tsay
eeda4c62fc forgot to push useTimeSystem 2024-04-17 10:46:34 -07:00
David Tsay
10457a583e Merge branch 'master' into time-conductor-options 2024-04-17 10:44:56 -07:00
David Tsay
ff605a0a0d create useTimeSystem composable 2024-04-16 16:44:32 -07:00
David Tsay
f56a8a1f5d Revert "script, template, style"
This reverts commit c8f8a098f2.
2024-04-15 19:43:22 -07:00
David Tsay
c8f8a098f2 script, template, style 2024-04-15 18:22:58 -07:00
David Tsay
31be2cba3d use vue component naming convention 2024-04-15 16:04:48 -07:00
David Tsay
eeb4f995a4 add missing licensing comment 2024-04-15 15:52:35 -07:00
8 changed files with 329 additions and 1 deletions

View File

@@ -74,6 +74,7 @@
<script>
import _ from 'lodash';
import { inject, onMounted, provide } from 'vue';
import {
FIXED_MODE_KEY,
@@ -90,6 +91,7 @@ import ConductorModeIcon from './ConductorModeIcon.vue';
import ConductorPopUp from './ConductorPopUp.vue';
import conductorPopUpManager from './conductorPopUpManager.js';
import ConductorTimeSystem from './ConductorTimeSystem.vue';
import { useTimeSystem } from './useTimeSystem.js';
const DEFAULT_DURATION_FORMATTER = 'duration';
@@ -106,6 +108,16 @@ export default {
},
mixins: [conductorPopUpManager],
inject: ['openmct', 'configuration'],
setup() {
const openmct = inject('openmct');
const { observeTimeSystem, timeSystemKey } = useTimeSystem(openmct);
onMounted(() => observeTimeSystem());
provide('timeSystemKey', timeSystemKey);
return { timeSystemKey };
},
data() {
const isFixed = this.openmct.time.isFixed();
const bounds = this.openmct.time.getBounds();

View File

@@ -20,7 +20,7 @@
at runtime from the About dialog for additional information.
-->
<template>
<time-popup-fixed
<TimePopupFixed
v-if="readOnly === false"
:input-bounds="bounds"
:input-time-system="timeSystem"

View File

@@ -1,3 +1,25 @@
<!--
Open MCT, Copyright (c) 2014-2024, 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.
-->
<template>
<form ref="fixedDeltaInput">
<div class="c-tc-input-popup__input-grid">

View File

@@ -1,3 +1,25 @@
<!--
Open MCT, Copyright (c) 2014-2024, 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.
-->
<template>
<form ref="deltaInput">
<div class="c-tc-input-popup__input-grid">

View File

@@ -0,0 +1,59 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2024, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web 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 Web 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 { onBeforeUnmount, shallowRef } from 'vue';
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js';
/**
* Provides reactive `offsets`,
* as well as a function to observe and update offsets changes,
* which automatically stops observing when the component is unmounted.
*
* @param {OpenMCT} openmct the Open MCT API
* @returns {{
* observeClockOffsets: () => void,
* offsets: import('vue').Ref<object>,
* }}
*/
export function useClockOffsets(openmct, options) {
let stopObservingClockOffsets;
const offsets = shallowRef(openmct.time.getClockOffsets());
onBeforeUnmount(() => stopObservingClockOffsets?.());
function observeClockOffsets() {
openmct.time.on(TIME_CONTEXT_EVENTS.clockOffsetsChanged, updateClockOffsets);
stopObservingClockOffsets = () =>
openmct.time.off(TIME_CONTEXT_EVENTS.clockOffsetsChanged, updateClockOffsets);
}
function updateClockOffsets(_offsets) {
offsets.value = _offsets;
}
return {
observeClockOffsets,
offsets
};
}

View File

@@ -0,0 +1,64 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2024, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web 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 Web 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 { onBeforeUnmount, ref, shallowRef } from 'vue';
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js';
import throttle from '../../utils/throttle.js';
/**
* Provides reactive `bounds`,
* as well as a function to observe and update bounds changes,
* which automatically stops observing when the component is unmounted.
*
* @param {OpenMCT} openmct the Open MCT API
* @returns {{
* observeTimeBounds: () => void,
* bounds: import('vue').Ref<object>,
* isTick: import('vue').Ref<boolean>
* }}
*/
export function useTimeBounds(openmct, options) {
let stopObservingTimeBounds;
const bounds = shallowRef(openmct.time.getBounds());
const isTick = ref(false);
onBeforeUnmount(() => stopObservingTimeBounds?.());
function observeTimeBounds(milliseconds = 300) {
openmct.time.on(TIME_CONTEXT_EVENTS.boundsChanged, throttle(updateTimeBounds), milliseconds);
stopObservingTimeBounds = () =>
openmct.time.off(TIME_CONTEXT_EVENTS.boundsChanged, throttle(updateTimeBounds), milliseconds);
}
function updateTimeBounds(_timeBounds, _isTick) {
bounds.value = _timeBounds;
isTick.value = _isTick;
}
return {
observeTimeBounds,
isTick,
bounds
};
}

View File

@@ -0,0 +1,66 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2024, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web 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 Web 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 { computed, onBeforeUnmount, ref } from 'vue';
import {
FIXED_MODE_KEY,
REALTIME_MODE_KEY,
TIME_CONTEXT_EVENTS
} from '../../api/time/constants.js';
/**
* Provides reactive `isFixedTimeMode` and `isRealTimeMode`,
* as well as a function to observe and update the component's time mode,
* which automatically stops observing when the component is unmounted.
*
* @param {OpenMCT} openmct the Open MCT API
* @returns {{
* observeTimeMode: () => void,
* isFixedTimeMode: import('vue').Ref<boolean>,
* isRealTimeMode: import('vue').Ref<boolean>
* }}
*/
export function useTimeMode(openmct, options) {
let stopObservingTimeMode;
const timeMode = ref(openmct.time.getMode());
const isFixedTimeMode = computed(() => timeMode.value === FIXED_MODE_KEY);
const isRealTimeMode = computed(() => timeMode.value === REALTIME_MODE_KEY);
onBeforeUnmount(() => stopObservingTimeMode?.());
function observeTimeMode() {
openmct.time.on(TIME_CONTEXT_EVENTS.modeChanged, updateTimeMode);
stopObservingTimeMode = () => openmct.time.off(TIME_CONTEXT_EVENTS.modeChanged, updateTimeMode);
}
function updateTimeMode(_timeMode) {
timeMode.value = _timeMode;
}
return {
observeTimeMode,
isFixedTimeMode,
isRealTimeMode
};
}

View File

@@ -0,0 +1,83 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2024, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web 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 Web 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 { onBeforeUnmount, ref } from 'vue';
const DEFAULT_DURATION_FORMATTER = 'duration';
/**
* Provides a reactive destructuring of the component's current time system,
* as well as a function to observe and update the component's time system,
* which automatically stops observing when the component is unmounted.
*
* @param {OpenMCT} openmct the Open MCT API
* @returns {{
* observeTimeSystem: () => void,
* timeSystemKey: import('vue').Ref<string>,
* timeSystemFormatter: import('vue').Ref<() => void>,
* timeSystemDurationFormatter: import('vue').Ref<() => void>,
* isTimeSystemUTCBased: import('vue').Ref<boolean>
* }}
*/
export function useTimeSystem(openmct, options) {
let stopObservingTimeSystem;
const currentTimeSystem = openmct.time.getTimeSystem();
const timeSystemKey = ref(currentTimeSystem.key);
const timeSystemFormatter = ref(getFormatter(openmct, currentTimeSystem.timeFormat));
const timeSystemDurationFormatter = ref(
getFormatter(openmct, currentTimeSystem.durationFormat || DEFAULT_DURATION_FORMATTER)
);
const isTimeSystemUTCBased = ref(currentTimeSystem.isUTCBased);
onBeforeUnmount(() => stopObservingTimeSystem?.());
function observeTimeSystem() {
openmct.time.on('timeSystemChanged', updateTimeSystem);
stopObservingTimeSystem = () => openmct.time.off('timeSystemChanged', updateTimeSystem);
}
function updateTimeSystem(timeSystem) {
timeSystemKey.value = timeSystem.key;
timeSystemFormatter.value = getFormatter(openmct, timeSystem.timeFormat);
timeSystemDurationFormatter.value = getFormatter(
openmct,
timeSystem.durationFormat || DEFAULT_DURATION_FORMATTER
);
isTimeSystemUTCBased.value = timeSystem.isUTCBased;
}
return {
observeTimeSystem,
timeSystemKey,
timeSystemFormatter,
timeSystemDurationFormatter,
isTimeSystemUTCBased
};
}
function getFormatter(openmct, key) {
return openmct.telemetry.getValueFormatter({
format: key
}).formatter;
}