mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +00:00
chore: add prettier
(2/3): apply formatting, re-enable lint ci step (#6682)
* style: apply prettier formatting * fix: re-enable lint ci check
This commit is contained in:
@ -20,114 +20,115 @@
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<template>
|
||||
<div
|
||||
<div
|
||||
v-if="selectedTimeSystem.name"
|
||||
ref="timeSystemButton"
|
||||
class="c-ctrl-wrapper c-ctrl-wrapper--menus-up"
|
||||
>
|
||||
>
|
||||
<button
|
||||
class="c-button--menu c-time-system-button"
|
||||
:class="selectedTimeSystem.cssClass"
|
||||
@click.prevent.stop="showTimeSystemMenu"
|
||||
class="c-button--menu c-time-system-button"
|
||||
:class="selectedTimeSystem.cssClass"
|
||||
@click.prevent.stop="showTimeSystemMenu"
|
||||
>
|
||||
<span class="c-button__label">{{ selectedTimeSystem.name }}</span>
|
||||
<span class="c-button__label">{{ selectedTimeSystem.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
inject: ['openmct', 'configuration'],
|
||||
data: function () {
|
||||
inject: ['openmct', 'configuration'],
|
||||
data: function () {
|
||||
let activeClock = this.openmct.time.clock();
|
||||
|
||||
return {
|
||||
selectedTimeSystem: JSON.parse(JSON.stringify(this.openmct.time.timeSystem())),
|
||||
timeSystems: this.getValidTimesystemsForClock(activeClock)
|
||||
};
|
||||
},
|
||||
mounted: function () {
|
||||
this.openmct.time.on('timeSystem', this.setViewFromTimeSystem);
|
||||
this.openmct.time.on('clock', this.setViewFromClock);
|
||||
},
|
||||
destroyed: function () {
|
||||
this.openmct.time.off('timeSystem', this.setViewFromTimeSystem);
|
||||
this.openmct.time.on('clock', this.setViewFromClock);
|
||||
},
|
||||
methods: {
|
||||
showTimeSystemMenu() {
|
||||
const elementBoundingClientRect = this.$refs.timeSystemButton.getBoundingClientRect();
|
||||
const x = elementBoundingClientRect.x;
|
||||
const y = elementBoundingClientRect.y;
|
||||
|
||||
const menuOptions = {
|
||||
placement: this.openmct.menus.menuPlacement.TOP_RIGHT
|
||||
};
|
||||
|
||||
this.openmct.menus.showMenu(x, y, this.timeSystems, menuOptions);
|
||||
},
|
||||
getValidTimesystemsForClock(clock) {
|
||||
return this.configuration.menuOptions
|
||||
.filter((menuOption) => menuOption.clock === (clock && clock.key))
|
||||
.map((menuOption) => {
|
||||
const timeSystem = JSON.parse(
|
||||
JSON.stringify(this.openmct.time.timeSystems.get(menuOption.timeSystem))
|
||||
);
|
||||
timeSystem.onItemClicked = () => this.setTimeSystemFromView(timeSystem);
|
||||
|
||||
return timeSystem;
|
||||
});
|
||||
},
|
||||
setTimeSystemFromView(timeSystem) {
|
||||
if (timeSystem.key !== this.selectedTimeSystem.key) {
|
||||
let activeClock = this.openmct.time.clock();
|
||||
let configuration = this.getMatchingConfig({
|
||||
clock: activeClock && activeClock.key,
|
||||
timeSystem: timeSystem.key
|
||||
});
|
||||
if (activeClock === undefined) {
|
||||
let bounds;
|
||||
|
||||
return {
|
||||
selectedTimeSystem: JSON.parse(JSON.stringify(this.openmct.time.timeSystem())),
|
||||
timeSystems: this.getValidTimesystemsForClock(activeClock)
|
||||
};
|
||||
},
|
||||
mounted: function () {
|
||||
this.openmct.time.on('timeSystem', this.setViewFromTimeSystem);
|
||||
this.openmct.time.on('clock', this.setViewFromClock);
|
||||
},
|
||||
destroyed: function () {
|
||||
this.openmct.time.off('timeSystem', this.setViewFromTimeSystem);
|
||||
this.openmct.time.on('clock', this.setViewFromClock);
|
||||
},
|
||||
methods: {
|
||||
showTimeSystemMenu() {
|
||||
const elementBoundingClientRect = this.$refs.timeSystemButton.getBoundingClientRect();
|
||||
const x = elementBoundingClientRect.x;
|
||||
const y = elementBoundingClientRect.y;
|
||||
if (this.selectedTimeSystem.isUTCBased && timeSystem.isUTCBased) {
|
||||
bounds = this.openmct.time.bounds();
|
||||
} else {
|
||||
bounds = configuration.bounds;
|
||||
}
|
||||
|
||||
const menuOptions = {
|
||||
placement: this.openmct.menus.menuPlacement.TOP_RIGHT
|
||||
};
|
||||
|
||||
this.openmct.menus.showMenu(x, y, this.timeSystems, menuOptions);
|
||||
},
|
||||
getValidTimesystemsForClock(clock) {
|
||||
return this.configuration.menuOptions
|
||||
.filter(menuOption => menuOption.clock === (clock && clock.key))
|
||||
.map(menuOption => {
|
||||
const timeSystem = JSON.parse(JSON.stringify(this.openmct.time.timeSystems.get(menuOption.timeSystem)));
|
||||
timeSystem.onItemClicked = () => this.setTimeSystemFromView(timeSystem);
|
||||
|
||||
return timeSystem;
|
||||
});
|
||||
},
|
||||
setTimeSystemFromView(timeSystem) {
|
||||
if (timeSystem.key !== this.selectedTimeSystem.key) {
|
||||
let activeClock = this.openmct.time.clock();
|
||||
let configuration = this.getMatchingConfig({
|
||||
clock: activeClock && activeClock.key,
|
||||
timeSystem: timeSystem.key
|
||||
});
|
||||
if (activeClock === undefined) {
|
||||
let bounds;
|
||||
|
||||
if (this.selectedTimeSystem.isUTCBased && timeSystem.isUTCBased) {
|
||||
bounds = this.openmct.time.bounds();
|
||||
} else {
|
||||
bounds = configuration.bounds;
|
||||
}
|
||||
|
||||
this.openmct.time.timeSystem(timeSystem.key, bounds);
|
||||
} else {
|
||||
this.openmct.time.timeSystem(timeSystem.key);
|
||||
this.openmct.time.clockOffsets(configuration.clockOffsets);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
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];
|
||||
},
|
||||
|
||||
setViewFromTimeSystem(timeSystem) {
|
||||
this.selectedTimeSystem = timeSystem;
|
||||
},
|
||||
|
||||
setViewFromClock(clock) {
|
||||
let activeClock = this.openmct.time.clock();
|
||||
this.timeSystems = this.getValidTimesystemsForClock(activeClock);
|
||||
this.openmct.time.timeSystem(timeSystem.key, bounds);
|
||||
} else {
|
||||
this.openmct.time.timeSystem(timeSystem.key);
|
||||
this.openmct.time.clockOffsets(configuration.clockOffsets);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
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];
|
||||
},
|
||||
|
||||
setViewFromTimeSystem(timeSystem) {
|
||||
this.selectedTimeSystem = timeSystem;
|
||||
},
|
||||
|
||||
setViewFromClock(clock) {
|
||||
let activeClock = this.openmct.time.clock();
|
||||
this.timeSystems = this.getValidTimesystemsForClock(activeClock);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user