2020-12-16 16:54:41 +00:00
|
|
|
/*
|
2021-07-25 14:12:40 +00:00
|
|
|
* Copyright 2021 James Lyne
|
2020-12-16 16:54:41 +00:00
|
|
|
*
|
2021-07-25 14:12:40 +00:00
|
|
|
* 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
|
2020-12-16 16:54:41 +00:00
|
|
|
*
|
2021-07-25 14:12:40 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2020-12-16 16:54:41 +00:00
|
|
|
*
|
2021-07-25 14:12:40 +00:00
|
|
|
* 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.
|
2020-12-16 16:54:41 +00:00
|
|
|
*/
|
|
|
|
|
2020-11-20 18:43:30 +00:00
|
|
|
import { createApp } from 'vue'
|
2021-05-19 23:01:19 +00:00
|
|
|
import App from './App.vue';
|
2020-11-23 12:13:28 +00:00
|
|
|
import {store} from "@/store";
|
2020-11-20 18:43:30 +00:00
|
|
|
|
2021-09-08 18:28:39 +00:00
|
|
|
import 'modern-normalize/modern-normalize.css';
|
2020-11-23 12:13:28 +00:00
|
|
|
import 'leaflet/dist/leaflet.css';
|
2020-12-01 23:20:38 +00:00
|
|
|
import '@/scss/style.scss';
|
2021-05-24 23:22:49 +00:00
|
|
|
|
2021-05-17 02:39:25 +00:00
|
|
|
import {MutationTypes} from "@/store/mutation-types";
|
2021-05-27 00:41:58 +00:00
|
|
|
import {showSplashError} from "@/util/splash";
|
2021-05-25 13:21:37 +00:00
|
|
|
import { VueClipboard } from '@soerenmartius/vue3-clipboard';
|
|
|
|
import Notifications from '@kyvg/vue3-notification'
|
2021-07-20 20:12:08 +00:00
|
|
|
import {getServerDefinitions} from "@/util/config";
|
2020-12-16 22:40:44 +00:00
|
|
|
|
|
|
|
const splash = document.getElementById('splash'),
|
2021-05-15 19:25:03 +00:00
|
|
|
svgs = import.meta.globEager('/assets/icons/*.svg');
|
2020-12-16 22:40:44 +00:00
|
|
|
|
2021-05-20 21:25:46 +00:00
|
|
|
if(splash) {
|
2021-05-24 19:17:27 +00:00
|
|
|
splash.addEventListener('transitionend', e => {
|
2021-05-20 21:25:46 +00:00
|
|
|
if(e.target === splash && splash.style.opacity === '0') {
|
|
|
|
splash.hidden = true;
|
|
|
|
}
|
2021-05-24 19:17:27 +00:00
|
|
|
});
|
2021-05-20 21:25:46 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 14:35:06 +00:00
|
|
|
console.info(`LiveAtlas version ${store.state.version} - https://github.com/JLyne/LiveAtlas`);
|
2020-12-17 15:24:40 +00:00
|
|
|
|
2021-05-27 00:42:53 +00:00
|
|
|
store.subscribe((mutation, state) => {
|
|
|
|
if(mutation.type === 'toggleSidebarSectionCollapsedState' || mutation.type === 'setSidebarSectionCollapsedState') {
|
2022-01-10 19:36:06 +00:00
|
|
|
localStorage.setItem('uiSettings', JSON.stringify({
|
|
|
|
sidebar: state.ui.sidebar,
|
|
|
|
}));
|
2021-05-27 00:42:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-05-18 17:27:11 +00:00
|
|
|
try {
|
2021-07-20 20:12:08 +00:00
|
|
|
const config = window.liveAtlasConfig;
|
|
|
|
config.servers = getServerDefinitions(config);
|
2021-05-18 17:27:11 +00:00
|
|
|
|
2021-07-20 20:12:08 +00:00
|
|
|
store.commit(MutationTypes.INIT, config);
|
2021-05-17 02:39:25 +00:00
|
|
|
|
2021-07-20 20:12:08 +00:00
|
|
|
if(store.state.servers.size > 1) {
|
2021-05-17 02:39:25 +00:00
|
|
|
const lastSegment = window.location.pathname.split('/').pop(),
|
2021-07-20 20:12:08 +00:00
|
|
|
serverName = lastSegment && store.state.servers.has(lastSegment) ? lastSegment : store.state.servers.keys().next().value;
|
2021-05-17 02:39:25 +00:00
|
|
|
|
2021-05-18 15:49:22 +00:00
|
|
|
//Update url if server doesn't exist
|
|
|
|
if(serverName !== lastSegment) {
|
2021-05-18 19:16:44 +00:00
|
|
|
window.history.replaceState({}, '', serverName + window.location.hash);
|
2021-05-18 15:49:22 +00:00
|
|
|
}
|
|
|
|
|
2021-05-17 02:39:25 +00:00
|
|
|
store.commit(MutationTypes.SET_CURRENT_SERVER, serverName);
|
|
|
|
} else {
|
2021-07-20 20:12:08 +00:00
|
|
|
store.commit(MutationTypes.SET_CURRENT_SERVER, store.state.servers.keys().next().value);
|
2021-05-17 02:39:25 +00:00
|
|
|
}
|
|
|
|
|
2021-05-25 13:21:37 +00:00
|
|
|
const app = createApp(App)
|
|
|
|
.use(store)
|
|
|
|
.use(Notifications)
|
|
|
|
.use(VueClipboard);
|
2020-11-23 12:13:28 +00:00
|
|
|
|
2021-05-17 02:39:25 +00:00
|
|
|
// app.config.performance = true;
|
2021-05-18 14:45:27 +00:00
|
|
|
app.mount('#app');
|
2021-05-18 17:27:11 +00:00
|
|
|
} catch(e) {
|
2021-05-18 16:19:20 +00:00
|
|
|
console.error('LiveAtlas configuration is invalid: ', e);
|
2021-12-09 18:26:20 +00:00
|
|
|
showSplashError('LiveAtlas configuration is invalid:\n' + e, true);
|
2021-05-18 17:27:11 +00:00
|
|
|
}
|