mirror of
https://github.com/nasa/openmct.git
synced 2024-12-22 06:27:48 +00:00
use composables for conductor mode
This commit is contained in:
parent
2c559457f0
commit
4f37d955eb
@ -102,9 +102,20 @@ export default {
|
|||||||
inject: ['openmct', 'configuration'],
|
inject: ['openmct', 'configuration'],
|
||||||
setup() {
|
setup() {
|
||||||
const openmct = inject('openmct');
|
const openmct = inject('openmct');
|
||||||
const { observeTimeSystem, timeSystemFormatter, timeSystemDurationFormatter } =
|
const {
|
||||||
useTimeSystem(openmct);
|
observeTimeSystem,
|
||||||
const { observeTimeMode, timeMode, isFixedTimeMode, isRealTimeMode } = useTimeMode(openmct);
|
timeSystemFormatter,
|
||||||
|
timeSystemDurationFormatter,
|
||||||
|
isTimeSystemUTCBased
|
||||||
|
} = useTimeSystem(openmct);
|
||||||
|
const {
|
||||||
|
observeTimeMode,
|
||||||
|
timeMode,
|
||||||
|
isFixedTimeMode,
|
||||||
|
isRealTimeMode,
|
||||||
|
getAllModeMetadata,
|
||||||
|
getModeMetadata
|
||||||
|
} = useTimeMode(openmct);
|
||||||
const { observeTimeBounds, bounds, isTick } = useTimeBounds(openmct);
|
const { observeTimeBounds, bounds, isTick } = useTimeBounds(openmct);
|
||||||
const { observeClockOffsets, offsets } = useClockOffsets(openmct);
|
const { observeClockOffsets, offsets } = useClockOffsets(openmct);
|
||||||
|
|
||||||
@ -117,9 +128,12 @@ export default {
|
|||||||
|
|
||||||
provide('timeSystemFormatter', timeSystemFormatter);
|
provide('timeSystemFormatter', timeSystemFormatter);
|
||||||
provide('timeSystemDurationFormatter', timeSystemDurationFormatter);
|
provide('timeSystemDurationFormatter', timeSystemDurationFormatter);
|
||||||
|
provide('isTimeSystemUTCBased', isTimeSystemUTCBased);
|
||||||
provide('timeMode', timeMode);
|
provide('timeMode', timeMode);
|
||||||
provide('isFixedTimeMode', isFixedTimeMode);
|
provide('isFixedTimeMode', isFixedTimeMode);
|
||||||
provide('isRealTimeMode', isRealTimeMode);
|
provide('isRealTimeMode', isRealTimeMode);
|
||||||
|
provide('getAllModeMetadata', getAllModeMetadata);
|
||||||
|
provide('getModeMetadata', getModeMetadata);
|
||||||
provide('bounds', bounds);
|
provide('bounds', bounds);
|
||||||
provide('isTick', isTick);
|
provide('isTick', isTick);
|
||||||
provide('offsets', offsets);
|
provide('offsets', offsets);
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
<div v-if="readOnly === false" ref="modeButton" class="c-tc-input-popup__options">
|
<div v-if="readOnly === false" ref="modeButton" class="c-tc-input-popup__options">
|
||||||
<div class="c-menu-button c-ctrl-wrapper c-ctrl-wrapper--menus-left">
|
<div class="c-menu-button c-ctrl-wrapper c-ctrl-wrapper--menus-left">
|
||||||
<button
|
<button
|
||||||
class="c-button--menu js-mode-button"
|
class="c-button--menu js-mode-button c-icon-button"
|
||||||
:class="[buttonCssClass, selectedMode.cssClass]"
|
:class="selectedMode.cssClass"
|
||||||
aria-label="Time Conductor Mode Menu"
|
aria-label="Time Conductor Mode Menu"
|
||||||
@click.prevent.stop="showModesMenu"
|
@click.prevent.stop="showModesMenu"
|
||||||
>
|
>
|
||||||
@ -43,19 +43,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { FIXED_MODE_KEY } from '../../api/time/constants';
|
|
||||||
import modeMixin from './mode-mixin.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [modeMixin],
|
inject: [
|
||||||
inject: ['openmct', 'configuration', 'bounds', 'offsets', 'isFixedTimeMode'],
|
'openmct',
|
||||||
|
'configuration',
|
||||||
|
'bounds',
|
||||||
|
'offsets',
|
||||||
|
'timeMode',
|
||||||
|
'isFixedTimeMode',
|
||||||
|
'getAllModeMetadata',
|
||||||
|
'getModeMetadata'
|
||||||
|
],
|
||||||
props: {
|
props: {
|
||||||
mode: {
|
|
||||||
type: String,
|
|
||||||
default() {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default() {
|
default() {
|
||||||
@ -63,24 +62,20 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['mode-updated'],
|
|
||||||
data() {
|
data() {
|
||||||
const mode = this.openmct.time.getMode();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedMode: this.getModeMetadata(mode),
|
selectedMode: this.getModeMetadata(this.timeMode)
|
||||||
modes: []
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
mode: {
|
timeMode: {
|
||||||
handler(mode) {
|
handler() {
|
||||||
this.setMode(mode, this.getBoundsForMode(mode));
|
this.setView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loadModes();
|
this.modes = this.getAllModeMetadata();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showModesMenu() {
|
showModesMenu() {
|
||||||
@ -95,15 +90,8 @@ export default {
|
|||||||
|
|
||||||
this.dismiss = this.openmct.menus.showSuperMenu(x, y, this.modes, menuOptions);
|
this.dismiss = this.openmct.menus.showSuperMenu(x, y, this.modes, menuOptions);
|
||||||
},
|
},
|
||||||
setViewFromMode(mode) {
|
setView() {
|
||||||
this.selectedMode = this.getModeMetadata(mode);
|
this.selectedMode = this.getModeMetadata(this.timeMode);
|
||||||
},
|
|
||||||
setMode(mode) {
|
|
||||||
this.openmct.time.setMode(mode);
|
|
||||||
this.setViewFromMode(mode);
|
|
||||||
},
|
|
||||||
getBoundsForMode(mode) {
|
|
||||||
return mode === FIXED_MODE_KEY ? this.bounds : this.offsets;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -55,6 +55,35 @@ export function useTimeMode(openmct, options) {
|
|||||||
stopObservingTimeMode = () => openmct.time.off(TIME_CONTEXT_EVENTS.modeChanged, updateTimeMode);
|
stopObservingTimeMode = () => openmct.time.off(TIME_CONTEXT_EVENTS.modeChanged, updateTimeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAllModeMetadata() {
|
||||||
|
return [FIXED_MODE_KEY, REALTIME_MODE_KEY].map(getModeMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getModeMetadata(key) {
|
||||||
|
const fixedModeMetadata = {
|
||||||
|
key: FIXED_MODE_KEY,
|
||||||
|
name: 'Fixed Timespan',
|
||||||
|
description: 'Query and explore data that falls between two fixed datetimes.',
|
||||||
|
cssClass: 'icon-tabular',
|
||||||
|
onItemClicked: () => setTimeMode(key)
|
||||||
|
};
|
||||||
|
|
||||||
|
const realTimeModeMetadata = {
|
||||||
|
key: REALTIME_MODE_KEY,
|
||||||
|
name: 'Real-Time',
|
||||||
|
description:
|
||||||
|
'Monitor streaming data in real-time. The Time Conductor and displays will automatically advance themselves based on the active clock.',
|
||||||
|
cssClass: 'icon-clock',
|
||||||
|
onItemClicked: () => setTimeMode(key)
|
||||||
|
};
|
||||||
|
|
||||||
|
return key === FIXED_MODE_KEY ? fixedModeMetadata : realTimeModeMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTimeMode(_timeMode) {
|
||||||
|
openmct.time.setMode(_timeMode);
|
||||||
|
}
|
||||||
|
|
||||||
function updateTimeMode(_timeMode) {
|
function updateTimeMode(_timeMode) {
|
||||||
timeMode.value = _timeMode;
|
timeMode.value = _timeMode;
|
||||||
}
|
}
|
||||||
@ -62,6 +91,8 @@ export function useTimeMode(openmct, options) {
|
|||||||
return {
|
return {
|
||||||
observeTimeMode,
|
observeTimeMode,
|
||||||
timeMode,
|
timeMode,
|
||||||
|
getAllModeMetadata,
|
||||||
|
getModeMetadata,
|
||||||
isFixedTimeMode,
|
isFixedTimeMode,
|
||||||
isRealTimeMode
|
isRealTimeMode
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user