Display UI version if possible

This commit is contained in:
Matthias 2021-07-06 07:20:47 +02:00
parent a753ed531a
commit e4283dd9a0
2 changed files with 27 additions and 2 deletions

View File

@ -29,6 +29,7 @@
</li> </li>
<li v-if="loggedIn" class="nav-item"> <li v-if="loggedIn" class="nav-item">
<b-nav-item-dropdown right> <b-nav-item-dropdown right>
<b-dropdown-item>V: {{ getUiVersion }}</b-dropdown-item>
<template #button-content> <template #button-content>
<b-avatar size="2em" button>FT</b-avatar> <b-avatar size="2em" button>FT</b-avatar>
</template> </template>
@ -51,7 +52,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator'; import { Component, Vue, Watch } from 'vue-property-decorator';
import LoginModal from '@/views/LoginModal.vue'; import LoginModal from '@/views/LoginModal.vue';
import { State, Action, namespace } from 'vuex-class'; import { State, Action, namespace, Getter } from 'vuex-class';
import userService from '@/shared/userService'; import userService from '@/shared/userService';
import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue'; import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue';
import { LayoutActions, LayoutGetters } from '@/store/modules/layout'; import { LayoutActions, LayoutGetters } from '@/store/modules/layout';
@ -75,6 +76,10 @@ export default class NavBar extends Vue {
@Action setLoggedIn; @Action setLoggedIn;
@Action loadUIVersion;
@Getter getUiVersion!: string;
@ftbot.Action ping; @ftbot.Action ping;
@ftbot.Action getState; @ftbot.Action getState;
@ -99,6 +104,7 @@ export default class NavBar extends Vue {
mounted() { mounted() {
this.ping(); this.ping();
this.loadUIVersion();
this.pingInterval = window.setInterval(this.ping, 60000); this.pingInterval = window.setInterval(this.ping, 60000);
if (this.loggedIn) { if (this.loggedIn) {

View File

@ -3,7 +3,7 @@ import Vuex from 'vuex';
import userService from '@/shared/userService'; import userService from '@/shared/userService';
import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes'; import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes';
import { AxiosInstance } from 'axios'; import axios, { AxiosInstance } from 'axios';
import ftbotModule, { BotStoreGetters } from './modules/ftbot'; import ftbotModule, { BotStoreGetters } from './modules/ftbot';
import alertsModule from './modules/alerts'; import alertsModule from './modules/alerts';
import layoutModule from './modules/layout'; import layoutModule from './modules/layout';
@ -22,6 +22,7 @@ export default new Vuex.Store({
autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || '{}'), autoRefresh: JSON.parse(localStorage.getItem(AUTO_REFRESH) || '{}'),
isBotOnline: false, isBotOnline: false,
currentTheme: initCurrentTheme, currentTheme: initCurrentTheme,
uiVersion: 'dev',
}, },
getters: { getters: {
isDarkTheme(state) { isDarkTheme(state) {
@ -34,6 +35,9 @@ export default new Vuex.Store({
getChartTheme(state, getters) { getChartTheme(state, getters) {
return getters.isDarkTheme ? 'dark' : 'light'; return getters.isDarkTheme ? 'dark' : 'light';
}, },
getUiVersion(state) {
return state.uiVersion;
},
}, },
modules: { modules: {
ftbot: ftbotModule, ftbot: ftbotModule,
@ -63,6 +67,9 @@ export default new Vuex.Store({
storeCurrentTheme(newTheme); storeCurrentTheme(newTheme);
state.currentTheme = newTheme; state.currentTheme = newTheme;
}, },
setUIVersion(state, uiVersion: string) {
state.uiVersion = uiVersion;
},
}, },
actions: { actions: {
setCurrentTheme({ commit }, newTheme: string) { setCurrentTheme({ commit }, newTheme: string) {
@ -85,6 +92,18 @@ export default new Vuex.Store({
refreshOnce({ dispatch }) { refreshOnce({ dispatch }) {
dispatch('ftbot/getVersion'); dispatch('ftbot/getVersion');
}, },
async loadUIVersion({ commit }) {
if (process.env.NODE_ENV !== 'development') {
try {
const result = await axios.get('/ui_version');
const { version } = result.data;
commit('setUIVersion', version);
} catch (error) {
//
}
}
},
async refreshAll({ dispatch, state, commit }, forceUpdate = false) { async refreshAll({ dispatch, state, commit }, forceUpdate = false) {
if (state.refreshing) { if (state.refreshing) {
return; return;