2021-08-01 11:18:03 +00:00
|
|
|
/* eslint-disable no-multi-spaces */
|
2021-07-22 21:20:03 +00:00
|
|
|
// Import core framework and essential utils
|
2019-09-01 12:38:13 +00:00
|
|
|
import Vue from 'vue';
|
2021-07-22 21:20:03 +00:00
|
|
|
import VueI18n from 'vue-i18n'; // i18n for localization
|
2021-04-08 19:12:35 +00:00
|
|
|
|
2021-07-22 21:20:03 +00:00
|
|
|
// Import component Vue plugins, used throughout the app
|
2021-08-01 11:18:03 +00:00
|
|
|
import VTooltip from 'v-tooltip'; // A Vue directive for Popper.js, tooltip component
|
|
|
|
import VModal from 'vue-js-modal'; // Modal component
|
|
|
|
import VSelect from 'vue-select'; // Select dropdown component
|
|
|
|
import VTabs from 'vue-material-tabs'; // Tab view component, used on the config page
|
|
|
|
import Toasted from 'vue-toasted'; // Toast component, used to show confirmation notifications
|
2021-10-21 23:27:38 +00:00
|
|
|
import TreeView from 'vue-json-tree-view';
|
2021-06-14 19:44:07 +00:00
|
|
|
|
2021-07-22 21:20:03 +00:00
|
|
|
// Import base Dashy components and utils
|
2021-08-01 11:18:03 +00:00
|
|
|
import Dashy from '@/App.vue'; // Main Dashy Vue app
|
2021-10-05 19:24:51 +00:00
|
|
|
import store from '@/store'; // Store, for local state management
|
2022-08-19 09:04:38 +00:00
|
|
|
import router from '@/router'; // Router, for navigation
|
2021-08-01 11:18:03 +00:00
|
|
|
import serviceWorker from '@/utils/InitServiceWorker'; // Service worker initialization
|
|
|
|
import { messages } from '@/utils/languages'; // Language texts
|
|
|
|
import ErrorReporting from '@/utils/ErrorReporting'; // Error reporting initializer (off)
|
2022-03-30 20:54:01 +00:00
|
|
|
import clickOutside from '@/directives/ClickOutside'; // Directive for closing popups, modals, etc
|
2021-09-18 16:47:25 +00:00
|
|
|
import { toastedOptions, tooltipOptions, language as defaultLanguage } from '@/utils/defaults';
|
2022-01-01 22:32:48 +00:00
|
|
|
import { initKeycloakAuth, isKeycloakEnabled } from '@/utils/KeycloakAuth';
|
2023-11-17 06:00:48 +00:00
|
|
|
import { initHeaderAuth, isHeaderAuthEnabled } from '@/utils/HeaderAuth';
|
2022-08-19 09:04:38 +00:00
|
|
|
import Keys from '@/utils/StoreMutations';
|
2024-04-28 19:00:17 +00:00
|
|
|
import ErrorHandler from '@/utils/ErrorHandler';
|
2021-08-01 11:18:03 +00:00
|
|
|
|
|
|
|
// Initialize global Vue components
|
2021-07-22 21:20:03 +00:00
|
|
|
Vue.use(VueI18n);
|
2021-09-18 16:47:25 +00:00
|
|
|
Vue.use(VTooltip, tooltipOptions);
|
2021-04-06 14:47:34 +00:00
|
|
|
Vue.use(VModal);
|
2021-05-16 17:29:30 +00:00
|
|
|
Vue.use(VTabs);
|
2021-10-21 23:27:38 +00:00
|
|
|
Vue.use(TreeView);
|
2021-05-17 18:38:18 +00:00
|
|
|
Vue.use(Toasted, toastedOptions);
|
2021-04-08 19:12:35 +00:00
|
|
|
Vue.component('v-select', VSelect);
|
2021-06-24 19:50:48 +00:00
|
|
|
Vue.directive('clickOutside', clickOutside);
|
2021-04-08 19:12:35 +00:00
|
|
|
|
2021-12-21 19:47:12 +00:00
|
|
|
// When running in dev mode, enable Vue performance tools
|
|
|
|
const isDevMode = process.env.NODE_ENV === 'development';
|
|
|
|
Vue.config.performance = isDevMode;
|
|
|
|
Vue.config.productionTip = isDevMode;
|
2019-09-01 12:38:13 +00:00
|
|
|
|
2021-07-24 15:47:14 +00:00
|
|
|
// Setup i18n translations
|
2021-07-22 21:20:03 +00:00
|
|
|
const i18n = new VueI18n({
|
2021-07-24 20:41:16 +00:00
|
|
|
locale: defaultLanguage,
|
|
|
|
fallbackLocale: defaultLanguage,
|
2021-07-22 21:20:03 +00:00
|
|
|
messages,
|
|
|
|
});
|
|
|
|
|
2021-08-01 11:18:03 +00:00
|
|
|
// Checks if service worker not disable, and if so will registers it
|
|
|
|
serviceWorker();
|
|
|
|
|
|
|
|
// Checks if user enabled error reporting, and if so will initialize it
|
|
|
|
ErrorReporting(Vue, router);
|
2021-06-22 21:30:46 +00:00
|
|
|
|
2021-07-22 21:20:03 +00:00
|
|
|
// Render function
|
|
|
|
const render = (awesome) => awesome(Dashy);
|
|
|
|
|
2021-10-09 17:30:47 +00:00
|
|
|
// Mount the app, with router, store i18n and render func
|
|
|
|
const mount = () => new Vue({
|
2021-10-10 13:32:54 +00:00
|
|
|
store, router, render, i18n,
|
2021-10-09 17:30:47 +00:00
|
|
|
}).$mount('#app');
|
|
|
|
|
2024-04-08 19:37:09 +00:00
|
|
|
store.dispatch(Keys.INITIALIZE_CONFIG).then(() => {
|
2024-04-28 19:00:17 +00:00
|
|
|
if (isKeycloakEnabled()) { // If Keycloak is enabled, initialize auth
|
2023-11-17 06:00:48 +00:00
|
|
|
initKeycloakAuth()
|
|
|
|
.then(() => mount())
|
2024-04-28 19:00:17 +00:00
|
|
|
.catch((e) => {
|
|
|
|
ErrorHandler('Failed to authenticate with Keycloak', e);
|
|
|
|
});
|
|
|
|
} else if (isHeaderAuthEnabled()) { // If header auth is enabled, initialize auth
|
2023-11-17 06:00:48 +00:00
|
|
|
initHeaderAuth()
|
|
|
|
.then(() => mount())
|
2024-04-28 19:00:17 +00:00
|
|
|
.catch((e) => {
|
|
|
|
ErrorHandler('Failed to authenticate with server', e);
|
|
|
|
});
|
|
|
|
} else { // If no third-party auth, just mount the app as normal
|
2023-11-17 06:00:48 +00:00
|
|
|
mount();
|
|
|
|
}
|
|
|
|
});
|